Is it possibel to parallelize this code?

Hi,

I’m trying to port this code to cuda, but I find difficult to do it, is there a way to do that?

unsigned int i, j=1, c,x;
c = (unsigned int
)malloc( (9) * sizeof(unsigned int));
c[1] = 1;
c[2] = 2;
c[3] = 3;
c[4] = 4;
c[5] = 5;
c[6] = 6;
c[7] = 50;
c[8] = 0;
j = 6;
visit:
for (i=1; i <= 6; i++) printf( “%3d”, c[i]);
printf( “\n”);
if (j > 0) {x = j+1; goto incr;}
if (c[1] + 1 < c[2])
{
c[1] += 1;
goto visit;
}
j = 2;
do_more:
c[j-1] = j-1;
x = c[j] + 1;
if (x == c[j+1]) {j++; goto do_more;}
if (j > 6) goto end;
incr:
c[j] = x;
j–;
goto visit;
end:

Thanks

In general, it is not a good programming style to abuse branches.

Is there a way better to code a combination generator and better yet to cuda it?

/* Algorithm by Donald Knuth. */

but Donald Knuth did it, so it must be right ;)

Hint: google for “parallel combination generator”

Sorry, I mean goto operator mostly.