Here’s my kernel function code. Every time I compile and run it, I get different results. Is there something wrong with my program?
#define MAX_THREAD_PER_BLOCK 396
#define MIN_BLOCK_PER_MULTIPROCESSOR 591
static const int SIZE = 2211;
static const int FN = 1;
static __device__ __forceinline__ void transGlobalFuncRes(double *result, double v, int index, int parentId) {
result[index + parentId] = v + get_linear_global_id();
}
__forceinline__ __global__ void func_186(double* param1, int param2) {
transGlobalFuncRes(param1, 100, 20, param2);
}
__global__ __launch_bounds__(MAX_THREAD_PER_BLOCK, MIN_BLOCK_PER_MULTIPROCESSOR) void entry(const double input, double* result, double* oval, int* fence, ulong fptr, ushort2* ldst, const int deep) {
int *X = (int*)malloc(sizeof(int) * FN);
memset(X, 2333, sizeof(int) * FN);
__syncthreads();
int ind = 2;
do {
func_186<<<1, 1>>>((result), (get_linear_global_id()));
}
while (ind--);
free(X);
}
By the way, get_linear_global_id() is used to get the thread’s index in the entire thread grid.
The program writes some data into the result array, but I noticed that every time I recompile and run it, I get different results.
check failed with: index=60 absErr=100.0 relErr=1.0 data1=100.0 data2=0.0
The data in the result appeared to be of different values.