Ailos
September 4, 2009, 1:05pm
1
Hello, :ph34r:
I have a little doubt with the dimension of the block. could this be defined by a variable? I never see that, but I am not sure that it cannot be posible.
dim3 dimbloq (nseq, 1, 1);
where nseq is : int nseq = 32;
I mean, i think i cannot declare dimbloq with variables, i need constant like … ?
[b]
#define DIM_BLOQ 16
dim3 dimbloq (DIM_BLOQ, 1, 1);[/b]
Could this be a real problem?
Thanks a lot!!!
LSChien
September 4, 2009, 1:30pm
2
Hello, :ph34r:
I have a little doubt with the dimension of the block. could this be defined by a variable? I never see that, but I am not sure that it cannot be posible.
dim3 dimbloq (nseq, 1, 1);
where nseq is : int nseq = 32;
I mean, i think i cannot declare dimbloq with variables, i need constant like … ?
[b]
define DIM_BLOQ 16
dim3 dimbloq (DIM_BLOQ, 1, 1);[/b]
Could this be a real problem?
Thanks a lot!!!
in C:/CUDA/include/vector_types.h
struct dim3
{
unsigned int x, y, z;
#if defined(__cplusplus)
__host__ __device__ dim3(unsigned int x = 1, unsigned int y = 1, unsigned int z = 1) : x(x), y(y), z(z) {}
__host__ __device__ dim3(uint3 v) : x(v.x), y(v.y), z(v.z) {}
__host__ __device__ operator uint3(void) { uint3 t; t.x = x; t.y = y; t.z = z; return t; }
endif /* __cplusplus */
};
if you use C++ compiler, then
dim3 dimbloq (DIM_BLOQ, 1, 1);
is reasonable, it is constructor.
if you use C compiler, then you can write
dim3 dimbloq ;
dimbloq.x = DIM_BLOQ ;
dimbloq.y = 1 ;
dimbloq.z = 1 ;
Ailos
September 4, 2009, 3:30pm
3
Thats a lot.
But you can, for exaple, do something like that…?
int main(){
int n=0;
dim3 dimbloq ;
while (‘some reasonable condition’){
n++;
}
if (n<32){
dimbloq.x = DIM_BLOQ ;
dimbloq.y = 1 ;
dimbloq.z = 1 ;}
call_some_kernel<<<dimgrid, dimbloq1>>> ( … );
}
i think, this can generate troubles, but I am not sure.
Thank you!
Pedro
:ninja:
in C:/CUDA/include/vector_types.h
struct dim3
{
unsigned int x, y, z;
#if defined(__cplusplus)
__host__ __device__ dim3(unsigned int x = 1, unsigned int y = 1, unsigned int z = 1) : x(x), y(y), z(z) {}
__host__ __device__ dim3(uint3 v) : x(v.x), y(v.y), z(v.z) {}
__host__ __device__ operator uint3(void) { uint3 t; t.x = x; t.y = y; t.z = z; return t; }
endif /* __cplusplus */
};
if you use C++ compiler, then
dim3 dimbloq (DIM_BLOQ, 1, 1);
is reasonable, it is constructor.
if you use C compiler, then you can write
dim3 dimbloq ;
dimbloq.x = DIM_BLOQ ;
dimbloq.y = 1 ;
dimbloq.z = 1 ;
LSChien
September 5, 2009, 4:02am
4
Thats a lot.
But you can, for exaple, do something like that…?
int main(){
int n=0;
dim3 dimbloq ;
while (‘some reasonable condition’){
n++;
}
if (n<32){
dimbloq.x = DIM_BLOQ ;
dimbloq.y = 1 ;
dimbloq.z = 1 ;}
call_some_kernel<<<dimgrid, dimbloq1>>> ( … );
}
i think, this can generate troubles, but I am not sure.
Thank you!
Pedro
:ninja:
in fact, you can set
dimbloq.x = nx ;
dimbloq.y = ny ;
dimbloq.z = nz ;
where nx, ny, nz read from a file
you don’t need to determine value of dimbloq in compilation time, nvcc will
put value of execution configuration into shared memory