一 代码
需要注意的是在cuda中,二维指针的用法和一维的不同,需要增加一个转换的过程
#include<stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
template <typename T>
__global__ void my_index_put_kernel(T** src,
int * idx, int row_idx, int col_idx,
T** value,
T** dst, bool accumulate) {
// if(blockIdx.x == idx)
// printf("hello cuda\n ");
// for(int i = 0 ; i < row_idx; i ++)
for(int j = 0; j < col_idx; j ++)
{
// printf("value = %f\n",value[blockIdx.x][i]);
dst[blockIdx.x][j] = value[blockIdx.x][j];
// printf("dst = %f\n