simple nested for loop understanding problem

hi there,

I think I still have some understanding problem with parallel computing.

so here is my simple task. I prepare 2 struct mday arrays and fill them.

both arrays do not have the same size. now my cuda global function

should “sprintf” (replace with cool algo) all possible combinations of

date1 and date2 (of course after cudaMalloc, cudaMemcpyHostToDevice the

arrays date1 and date2).

I played around with diffrent dimBlock and dimGrid settings…without

succsess. using dim3 dimGrid( N / dimBlock.x, N / dimBlock.y ) and inside

global

int i = blockIdx.x * blockDim.x + threadIdx.x;

int j = blockIdx.y * blockDim.y + threadIdx.y;

and accessing

…date1[a].month, date1[a].day, date2[b].year,…

does not work (?) beacuse date1 and date2 have a different size/cnt ?

can someone help pls.

#include <stdio.h>

int main() {

   int a,b,c,x;

struct mday {

	  int year;

	  int month;

	  int day;

   } date1[3720], date2[2232];

/* i prepare arrays */

   x=0;

for(a=1; a <= 10; a++) {

	  for(b=1; b <= 12; b++) {

		 for(c=1; c <= 31; c++) {

			date1[x].year = a;

			date1[x].month = b;

			date1[x].day = c;

			x++;

		 }

	  }

   }

printf("date1[%d]\n", x);

x=0;

   for(a=31; a <= 36; a++) {

	  for(b=1; b <= 12; b++) {

		 for(c=1; c <= 31; c++) {

			date2[x].year = a;

			date2[x].month = b;

			date2[x].day = c;

			x++;

		 }

	  }

   }

   printf("date2[%d]\n", x);

/* print loop -> cuda me !!!*/

for(a = 0; a < 3720; a++) {

	  for(b = 0; b < 2232; b++) {

		 printf("%02d%02d%02d%02d%02d%02d\n", date1[a].year, date1[a].month, date1[a].day, date2[b].year, date2[a].month, date2[b].day);

	  }

   }

}

Can you post your global function? That would really help a lot!