How to use scan_expr
in InclusiveScanKernel
for more general operation
#376
-
I want to use a vector-valued binary operator in array_length = 4 # a fix number
def op(lhs:List[int], rhs:List[int]):
result = lhs.copy()
for i in range(1, array_length):
ridx = rhs[0]-lhs[i]
if ridx <= array_length - 1:
result[i] = rhs[ridx]
else:
result[i] = rhs[-1]
return result (It does have associative property for some carefully created vectors) but the given example can only apply to number-valued function knl = InclusiveScanKernel(np.int32, "a+b") which means, def op(a:int, b:int):
return a+b So, I got the following problems:
I want to utilize the implementation of ref: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Sure. The expression can be a call to a function defined in the preamble.
As long as it's fixed-size, yes. Make a struct containing your fixed-size vector, and then register the type with pycuda.
Sure. Simple struct assignment would do that. |
Beta Was this translation helpful? Give feedback.
Sure. The expression can be a call to a function defined in the preamble.
As long as it's fixed-size, yes. Make a struct containing your fixed-size vector, and then register the type with pycuda.
Sure. Simple struct assignment would do that.