'hipLaunchKernel failed

I am using ROCM's hip for programming.

When I use hipLaunchKernelGGL, everything works fine. But when I use hipLaunchKernel(), I always get bizarre errors.

Error 1 says that the GPU accesses the wrong address.

Error 2 says that Result verification failed at element 0. Can someone help me see what's going wrong?

__global__ void vectorAdd(const float *A, const float *B, float *C, int numElements) 
{
    int i = blockDim.x * blockIdx.x + threadIdx.x;

    if (i < numElements) {
        C[i] = A[i] + B[i] + 0.0f;
    }
}

//    hipLaunchKernelGGL(vectorAdd, blocksPerGrid, threadsPerBlock, 0, 0, d_A, d_B, d_C, numElements);
void *args[] = {&d_A, &d_B, &d_C, &numElements};
hipLaunchKernel((void *)vectorAdd, dim3(blocksPerGrid), dim3(threadsPerBlock), args, 0, NULL);

for (int i = 0; i < numElements; ++i) {
    if (fabs(h_A[i] + h_B[i] - h_C[i]) > 1e-5) {
        fprintf(stderr, "Result verification failed at element %d!\n", i);
        exit(EXIT_FAILURE);
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source