OpenCLaccelerated元胞自动机模拟器
clcell的Python项目详细描述
clcell公司
clcell是python3的OpenCL加速元胞自动机模拟器。
特点
- 基于OpenCL的硬件加速
- 通过
clcell.RuleSet
自定义规则集 - 通过
clcell.CASimulator.batch_simulate
进行并行模拟
局限性
- 仅二进制单元状态
- 不支持无限网格
- 必须取消填充栅格边界单元
安装
无论您选择什么安装方法,您都需要 OpenCL硬件的驱动程序。
使用pip
$ pip install --user clcell
源代码构建
要求:
克隆此存储库:
^{pr2}$输入项目目录:
$ cd clcell
生成并安装此包:
$ make install
使用
importnumpyasnpimportclcell# Instantiate a simulator using Conway's Game of Life as the ruleset.sim=clcell.CASimulator(clcell.LIFE)# Create a randomized game state to use as a seed.seed_state=np.random.randint(0,2,(1023,1023),dtype=np.int8)# Pad state with zeros (required for now).seed_state=np.pad(seed_state,1,constant_values=0)# Simulate 10,000 generations based on that seed.final_state=sim.simulate(10000,seed_state)# Create a batch of 1,000 randomized, padded game states to use as seeds.seed_states=np.array([np.pad(np.random.randint(0,2,(127,127),dtype=np.int8),1,constant_values=0)fornuminrange(1000)])# Simulate 1,000 generations based on each of those seeds.final_states=sim.batch_simulate(1000,seed_states)
变更日志
v1.0.1
- 简化了设备代码如何检查边界单元。在
- 重构设备代码以使用8位单元格网格,而不是32位单元格。在
- 修正了在一个设备函数中错误地放置尺寸标注。在
v1.0.0
- 初始版本。在
- 项目
标签: