CUDA - Multiple Threads
===

I am trying to make an LCG Random Number Generator run in parallel using CUDA & GPU's. However, I am having trouble actually getting multiple threads running at the same time.Here is a copy of the code:

    #include <iostream>
    #include <math.h>
    
    __global__ void rng(long *cont)
    {
    
        int a=9, c=3, F, X=1; 
        long M=524288, Y;     
        printf("\nKernel X is %d\n", X[0]);     
        F=X;
        Y=X;
        printf("Kernel F is %d\nKernel Y is %d\n", F, Y);
        Y=(a*Y+c)%M;
        printf("%ld\t", Y);
        while(Y!=F)
        {
            Y=(a*Y+c)%M;
            printf("%ld\t", Y);
    	cont[0]++;
        }
    }
    int main()
    {
        long cont[1]={1};
        int X[1];
        long *dev_cont;
        int *dev_X;
        cudaEvent_t beginEvent;
        cudaEvent_t endEvent;
        cudaEventCreate( &beginEvent );
        cudaEventCreate( &endEvent );
        printf("Please give the value of the seed X ");
        scanf("%d", &X[0]);
        printf("Host X is: %d", *X);
        cudaEventRecord( beginEvent, 0);
        cudaMalloc( (void**)&dev_cont, sizeof(long) );
        cudaMalloc( (void**)&dev_X, sizeof(int) );
        cudaMemcpy(dev_cont, cont, 1 * sizeof(long), cudaMemcpyHostToDevice);
        cudaMemcpy(dev_X, X, 1 * sizeof(int), cudaMemcpyHostToDevice);
        rng<<<1,1>>>(dev_cont);
        cudaMemcpy(cont, dev_cont, 1 * sizeof(long), cudaMemcpyDeviceToHost);
        cudaEventRecord( endEvent, 0);
        cudaEventSynchronize (endEvent );
        float timevalue;
        cudaEventElapsedTime (&timevalue, beginEvent, endEvent);
        printf("\n\nYou generated a total of %ld numbers", cont[0]);
        printf("\nCUDA Kernel Time: %.2f ms\n", timevalue);
        cudaFree(dev_cont);
        cudaFree(dev_X);
        cudaEventDestroy( endEvent );
        cudaEventDestroy( beginEvent );
        return 0;
    }

Right now I am only sending one block with one thread. However, if I send 100 threads, the only thing that will happen is that it will produce the same number 100 times and then proceed to the next number. In theory this is what is meant to be expected but it automatically disregards the purpose of "random numbers" when a number is repeated.

The idea I want to implement is to have multiple threads. One thread will use that formula:
Y=(a*Y+c)%M but using an initial value of Y=1, then another thread will use the same formula but with an initial value of Y=1000, etc etc. However, once the first thread produces 1000 numbers, it needs to stop making more calculations because if it continues it will interfere with the second thread producing numbers with a value of Y=1000.

If anyone can point in the right direction, at least in the way of creating multiple threads with different functions or instructions inside of them, to run in parallel, I will try to figure out the rest. 

Thanks!
