当使用来自 SourceModule 的函数依赖于 SourceModule 中的另一个函数时,我如何在函数调用中传递它,即什么是“???” 在以下代码中:
import numpy
import pycuda.autoinit
import pycuda.driver as drv
from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void make_square(float *in_array, float *out_array)
{
int i;
int N = 5;
for (i=0; i<N; i++)
{
out_array[i] = pow(in_array[i],2);
}
}
__global__ void make_square_add_one(float *in_array, float *out_array, void make_square(float *, float *))
{
int N = 5;
make_square(in_array,out_array);
for (int i=0; i<N; i++)
out_array[i] = out_array[i] + 1;
}
""")
make_square = mod.get_function("make_square")
make_square_add_one = mod.get_function("make_square_add_one")
in_array = numpy.array([1.,2.,3.,4.,5.]).astype(numpy.float32)
out_array = numpy.zeros_like(in_array).astype(numpy.float32)
make_square_add_one(drv.In(in_array), drv.Out(out_array), ??? , block = (1,1,1), grid = (1,1))
感谢您提供任何信息。