动态数组获取"错误代码未指定启动失败"

时间:2018-02-28 11:18:03

标签: c++ cuda

我想在我的内核中使用动态数组和c变量,但我总是得到这个错误"错误代码未指定启动失败"当我使用超过1个threa的线程。如果我评论这段代码c [letak] = 5;我没有收到此错误。

如何解决?

__global__ void FillMatrix(char **sequence,int *s_length, int n, int *score)
{
 int b = threadIdx.x + blockIdx.x*blockDim.x;
 int a = threadIdx.y + blockIdx.y*blockDim.y;
 const int rows = s_length[a],cols = s_length[b];
  char *X = sequence[a];
  char *Y = sequence[b];

  const int jum = (cols + 1)*(rows + 1);

  size_t sizeArr = jum;
  int *c;
  c = (int*)malloc(sizeArr);
  memset(c,0,sizeArr);
  printf("Thread %d got C pointer: %p\n", threadIdx.x, c);
  score[(a*(n)) + b] = 0;
  if(b < n){
    printf("index ke %d - %d = %d --- %d - %d \n", a,b, jum, cols, rows);
    int letak,kiri,atas,miring, n_letak, n_atas, n_kiri,x=0,y=0,i;
    for(i = 0; i < jum;i++)
    {   
      if(i > (cols + 1 )  && (i % (cols+1) != 0))
      {
          y = (i/(cols + 1) - 1);
          x = (i-1) % (cols + 1);

          letak = i ;
          kiri  = letak - 1;
          atas  = (letak - cols) - 1 ;
          miring = atas - 1;
          int scoring = scoringsMatrix[X[y] - 'A'][Y[x] - 'A'];    
          n_letak = c[miring] + scoring;
          n_kiri = c[kiri] + GAP;
          n_atas = c[atas] + GAP;
          c[letak] = 5;
      }
    } 
    printf("score %d - %d = %d \n", a,b,score[(a*(n)) + b]);
    free(c);
  }
 }

1 个答案:

答案 0 :(得分:1)

size_t sizeArr = jum;

不正确,因为您没有考虑数组元素的大小。尝试

size_t sizeArr = jum*sizeof(int);