InclusiveScanはGenericScanKernelのパラメータの設定が煩雑なため用意された関数だと筆者は考えています。基本的な機能はGenericScanKernelと同じものと考えて良いかと思います。
以下がInclusiveScanの実装例です。
CLInclusiveScanKernelTest.py.
import pyopencl.array as clarr import pyopencl as cl import numpy as np ctx = cl.Context(cl.get_platforms()[0].get_devices(cl.device_type.GPU)) queue = cl.CommandQueue(ctx) from pyopencl.scan import InclusiveScanKernel iscan = InclusiveScanKernel(ctx, np.int32, "a+b", "0") a = np.arange(10).astype(np.int32) a_mem = clarr.to_device(queue, a) iscan(a_mem) print(a_mem.get())
出力.
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/komatsu/PycharmProjects/MyPythonProject/CLInclusiveScanKernelTest.py [ 0 1 3 6 10 15 21 28 36 45]
Copyright 2018-2019, by Masaki Komatsu