I have a problem with the following code, when executing the call to cublasSrotg it throws an exception: “Access violation writing location 0x05200600”, which is the address of the ‘dA’ pointer. When running the debugger it appears to be skipping the call to cudaMalloc, but I can’t figure out what I’m doing wrong.
cublasHandle_t handle;
cublasCreate(&handle);
float hA[SIZE] = { 1.0f, 2.0f, 3.0f, 4.0f };
int sizef = sizeof(float);
float* dA;
cudaMalloc((void**)&dA, SIZE * sizef);
cublasSetVector(SIZE, sizef, hA, 1, dA, 1);
float s, c;
cublasSrotg(handle, dA, dA + N, &c, &s);
cublasSrot(handle, N, dA, 1, dA + N, 1, &c, &s);
cublasGetVector(SIZE, sizef, dA, 1, hA, 1);
...
From the following line of code I gather that
SIZEis equal to4.But then here, you do two strange things:
You mix host and device parameters to the same cublas function (I don’t know if this is legal or not).
dAis a device pointer andsandcare host variables.You pass
dAanddA + N. UnlessNis less than4, you will be indexing out of bounds, so that could be your problem. Also, note that the first two inputs to cublasSrotg are in/out variables — their initial value is used, but then overwritten.Since they are overwritten, it’s strange that you would then pass the same pointers to
cublasSrot…See the CUBLAS Documentation for full details.
Edit:
OP reveals that the problem was mixing device and host pointers, as well as not calling cudaMalloc to allocate the
candsvalues on the device.