Hey guys, I’m new to cuda programming; below is my code for a game of life program. When I run it I get a Segmentation fault error, the debugger says the error is with the hBlockAll[i][j] = 0; line, but I’m not sure what this means or why I am getting this error.
Hey guys, I’m new to cuda programming; below is my code for a game of life program. When I run it I get a Segmentation fault error, the debugger says the error is with the hBlockAll[i][j] = 0; line, but I’m not sure what this means or why I am getting this error.
Yes, I figured that would be an issue and I was going to tackle that later on, but the error occurs before those lines are even reached. I think the problem might be that I’m allocating memory for a two-dimensional array wrong. I am use to programming in java and not having to worry about that.
Yes, I figured that would be an issue and I was going to tackle that later on, but the error occurs before those lines are even reached. I think the problem might be that I’m allocating memory for a two-dimensional array wrong. I am use to programming in java and not having to worry about that.
So what nvidia can learn from this is: “noobies and beginners and average programmers” want to program cuda too…
But C/C++ is probably way to difficult for them.
So NVIDIA would be wise to add other languages like free basic/basic and/or pascal or perhaps even java or anything that’s easier to program External Image
So what nvidia can learn from this is: “noobies and beginners and average programmers” want to program cuda too…
But C/C++ is probably way to difficult for them.
So NVIDIA would be wise to add other languages like free basic/basic and/or pascal or perhaps even java or anything that’s easier to program External Image
C has multi-dimensional arrays. However, the commonly used “a one-dimensional array and a pointer can be used interchangeably” trick doesn’t apply there, so the double pointer [font=“Courier New”]**a[/font] cannot be used in place of a two-dimensional array.
Declare a 2-dimensional array with
int a;
and a pointer to a 2-dimensional array with
int (*p);
Note that SIZE_X and SIZE_Y must be known at compile time. Variable size arrays were only introduced with C99 and AFAIK are not available in CUDA. If you want to set the array size at runtime, you need to flatten the array to a 1-dimensional array as Skybuck showed.
C has multi-dimensional arrays. However, the commonly used “a one-dimensional array and a pointer can be used interchangeably” trick doesn’t apply there, so the double pointer [font=“Courier New”]**a[/font] cannot be used in place of a two-dimensional array.
Declare a 2-dimensional array with
int a;
and a pointer to a 2-dimensional array with
int (*p);
Note that SIZE_X and SIZE_Y must be known at compile time. Variable size arrays were only introduced with C99 and AFAIK are not available in CUDA. If you want to set the array size at runtime, you need to flatten the array to a 1-dimensional array as Skybuck showed.