您现在的位置是:首页 > 文章详情

计算机图形学编程语言 Taichi(太极)v1.2.0 发布

日期:2022-10-31点击:264

Taichi(太极)v1.2.0 已经发布,这是专为高性能计算机图形学设计的编程语言。从 v1.2.0 版本开始,Taichi 遵循语义版本控制,其中从 master 分支 cutting 的常规版本会增加 MINOR 版本,而 PATCH 版本只有在挑出关键的 bug 修复时才会增加。

具体更新内容如下:

弃用通知

  • 在未来的版本中将不允许使用单个循环索引对多维的ti.ndrange()进行索引。

新的功能

离线缓存

v1.1.0 中引入了 CPU 和 CUDA 后端的离线缓存。在新版本中,Vulkan、OpenGL 和 Metal 后端也支持此功能。

  • 如果你的代码行为异常,官方建议通过在 ti.init() 方法调用中设置环境变量 TI_OFFLINE_CACHE=0 或 offline_cache=False 来禁用离线缓存,并在 Taichi 的 GitHub repo 上向提交一个 issue。
  • 有关详细信息,可参阅 Offline cache

GDAR (Global Data Access Rule)

提供了一个 checker,用于检测可能违反全局数据访问规则的情况。

  1. 该 checker 仅在调试模式下工作。要启用它,可在调用ti.init()时设置debug=True
  2. 在使用时ti.ad.Tape()设置validation=True,以验证ti.ad.Tape()所捕获的内核
    如果发生违规,检查器会查明违反规则的代码行。

例如:

 

 import taichi as ti ti.init(debug=True) N = 5 x = ti.field(dtype=ti.f32, shape=N, needs_grad=True) loss = ti.field(dtype=ti.f32, shape=(), needs_grad=True) b = ti.field(dtype=ti.f32, shape=(), needs_grad=True) @ti.kernel def func_1(): for i in range(N): loss[None] += x[i] * b[None] @ti.kernel def func_2(): b[None] += 100 b[None] = 10 with ti.ad.Tape(loss, validation=True): func_1() func_2() """ taichi.lang.exception.TaichiAssertionError: (kernel=func_2_c78_0) Breaks the global data access rule. Snode S10 is overwritten unexpectedly. File "across_kernel.py", line 16, in func_2: b[None] += 100 ^^^^^^^^^^^^^^ """

Performance

  • 改进 Vulkan performance with loops (#6072)

Python Frontend

  • 添加了 PrefixSumExecutor 以 prefix-sum operations 的性能。传统的 prefix-sum function 在每次函数调用时都会分配辅助 gpu 缓冲区,这会导致明显的性能问题。新的 PrefixSumExecutor 能够避免一次又一次地分配缓冲区。对于长度相同的数组,PrefixSumExecutor 只需要初始化一次,就可以执行任意次数的prefix-sum operations,而无需多余的字段分配。目前仅 CUDA 后端支持 prefix-sum operation。(#6132

    用法:

     N = 100 arr0 = ti.field(dtype, N) arr1 = ti.field(dtype, N) arr2 = ti.field(dtype, N) arr3 = ti.field(dtype, N) arr4 = ti.field(dtype, N) # initialize arr0, arr1, arr2, arr3, arr4, ... # ... # Performing an inclusive in-place's parallel prefix sum, # only one executor is needed for a specified sorting length. executor = ti.algorithms.PrefixSumExecutor(N) executor.run(arr0) executor.run(arr1) executor.run(arr2) executor.run(arr3) executor.run(arr4) 
  • 当调试模式打开时,现在可以对 Vulkan、CPU 和 CUDA 后端上的加法、减法、乘法和左移运算符进行运行时整数溢出检测。Vulkan 后端使用溢出检测需要弃用 printing,Vulkan 后端 64 位乘法溢出检测需要 NVIDIA driver 510 以上。(#6178) (#6279)

    For the following program:

     import taichi as ti ti.init(debug=True) @ti.kernel def add(a: ti.u64, b: ti.u64)->ti.u64: return a + b add(2 ** 63, 2 ** 63) The following warning is printed at runtime: Addition overflow detected in File "/home/lin/test/overflow.py", line 7, in add: return a + b ^^^^^ 
  • Unix/Windows 平台上的 Vulkan 后端现在支持 Printing。要在 vulkan 后端启用 printing,需要按照 https://docs.taichi-lang.org/docs/master/debugging#applicable-backends 中的说明进行操作 (#6075)

GGUI

更多详情可查看发布说明:https://github.com/taichi-dev/taichi/releases/tag/v1.2.0

 

原文链接:https://www.oschina.net/news/215908/taichi-1-2-0-released
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章