int main(void) {
float *x, *y;
cudaMallocManaged(&x, sizeof(float));
cudaMallocManaged(&y, sizeof(float));
x[0] = 1.0f;
y[0] = 1.0f;
cudaFree(x);
cudaFree(y);
return 0;
}
nvcc main.cu -o main
./main
fish: “./main” terminated by signal SIGSEGV (Address boundary error)
& when I use bash (instead of fish), I get:
Segmentation fault (core dumped)
Weirdly, this error goes away when I remove the y variable completely…
int main(void) {
float *x;
cudaMallocManaged(&x, sizeof(float));
x[0] = 1.0f;
cudaFree(x);
return 0;
}