【发布时间】:2011-07-03 14:08:52
【问题描述】:
我正在运行这个简单的 CUDA 程序:
#include <cuda_runtime.h>
#include <cuda.h>
#include <stdio.h>
__global__ void
display(char *t[])
{
int v = blockIdx.x;
int p = blockIdx.y;
int offset = v+ p*gridDim.x;
t[offset] = "(";
//
}
void
main()
{
int c = 5;
cudaGetDeviceCount(&c);
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop,0);
printf("The device name is : %s\n", prop.name);
//bool value = prop.integrated;
char *x[6];
int i;
for (i = 0; i<6; i++)
cudaMalloc((void**)&x[i], 20*sizeof(char));
// Checking the meaning of grid(3,2)
dim3 grid(3,2);
display<<<grid,1>>>(x);
char y[30];
cudaMemcpy(y, x[0], 20*sizeof(char), cudaMemcpyDeviceToHost);
printf("The values is :%s\n", y);
cudaFree(x[0]);
getchar();
}
我不明白为什么数组 y 在执行结束时仍然为空。不应该是“(”吗?
【问题讨论】:
-
仍然面临问题...请帮助!
-
我们正在努力提供帮助!伙计,冷静下来,给我们一些时间