Numba Cuda 中的内置向量类型
Built-in Vector Types in Numba Cuda
我可以在 Numba Cuda 中使用 Cuda 文档中存在的内置向量类型 float3 吗?我知道可以与 PyCuda 一起使用,例如,像这样的内核:
addarrs_codetext = """
__global__ void add_3darrs_broadcast(float3 *out, float3 *a, float3 *b, int* SZ)
{
const int M = SZ[0];
const int N = SZ[1];
const int S = SZ[2];
const int tx = threadIdx.x;
const int bx = blockIdx.x;
const int BSZ = blockDim.x;
int t;
for (int s=0;s<S;s++)
{
t = s*BSZ+tx;
if(t<N)
dest[bx*N+t].x = b[t].x + a[bx].x;
dest[bx*N+t].y = b[t].y + a[bx].y;
dest[bx*N+t].z = b[t].z + a[bx].z;
__syncthreads();
}
}
"""
我怎样才能对 Numba Cuda 做同样的事情?
谢谢!
Can I use the built-in vector type float3 that exists in Cuda documentation with Numba Cuda?
不,你不能。
Numba CUDA Python 从 Numba 的 nopython 模式继承了 small subset of supported types。但仅此而已。 Numba(2021 年 10 月)未公开许多原生 CUDA 功能。其中包括纹理、视频 SIMD 指令和向量类型。
我可以在 Numba Cuda 中使用 Cuda 文档中存在的内置向量类型 float3 吗?我知道可以与 PyCuda 一起使用,例如,像这样的内核:
addarrs_codetext = """
__global__ void add_3darrs_broadcast(float3 *out, float3 *a, float3 *b, int* SZ)
{
const int M = SZ[0];
const int N = SZ[1];
const int S = SZ[2];
const int tx = threadIdx.x;
const int bx = blockIdx.x;
const int BSZ = blockDim.x;
int t;
for (int s=0;s<S;s++)
{
t = s*BSZ+tx;
if(t<N)
dest[bx*N+t].x = b[t].x + a[bx].x;
dest[bx*N+t].y = b[t].y + a[bx].y;
dest[bx*N+t].z = b[t].z + a[bx].z;
__syncthreads();
}
}
"""
我怎样才能对 Numba Cuda 做同样的事情? 谢谢!
Can I use the built-in vector type float3 that exists in Cuda documentation with Numba Cuda?
不,你不能。
Numba CUDA Python 从 Numba 的 nopython 模式继承了 small subset of supported types。但仅此而已。 Numba(2021 年 10 月)未公开许多原生 CUDA 功能。其中包括纹理、视频 SIMD 指令和向量类型。