I can allocated dynamic shared memory beacuse i don’t know dimension of this in compile time.
In my shared memory i must have a more type of variable (int,float…and more)
Now, as manual of CUDA 2.0 say, my code for allocate dynamic memory is:
[codebox]extern shared char *numeroIntero;
global void HelloCUDA(int *numeroDevice)
{
int *numero = (int *)numeroIntero;
*numero = 20;
*numeroDevice = *numero;
}[/codebox]
this code give me this error: “error: local and shared variables cannot have external linkage”
OK, change my code in this:
[codebox]global void HelloCUDA(int *numeroDevice)
{
__shared__ char numeroIntero[];
int *numero = (int *)numeroIntero;
*numero = 20;
*numeroDevice = *numero;
}[/codebox]
this code give me this error : “error: incomplete type is not allowed”
OK, change my code in this:
[codebox]shared char numeroIntero;
global void HelloCUDA(int *numeroDevice1)
{
int *numero = (int *)numeroIntero;
*numero = 20;
*numeroDevice1 = *numero;
}[/codebox]
this code give me this error: “Error: Unaligned memory accesses not supported”… but in cuda 2.0 is supported
OK, change my code in this:
[codebox]global void HelloCUDA(int *numeroDevice)
{
__shared__ char *numeroIntero;
int *numero = (int *)numeroIntero;
*numero = 20;
*numeroDevice = *numero;
}[/codebox]
this code give me nothing error, but when i call "cudaMemcpy(&numeroHost,numeroDevice,sizeof(int),cudaMemcpyDeviceToHo
st);" numeroHost don’t change and in emulation mode give me about this error “Access write violation”
BECAUSE? Please help me…
What allocate dynamic shared memory???