コード例 #1
0
ファイル: shrimpPop.cpp プロジェクト: KellyBlack/SUNYSDE2014
void singleApprox(double x0, double y0,
                  double alpha, double beta,
                  double gamma, double delta,
                  double R, double D,
                  double rho,
                  double x[2],
				  std::ofstream* dataFile)

{
	int outerLupe=0;
    int lupe=0;
    int N=1000;
    double T=6.0;
    double xinter[2];
    double dt = T/((double)N);
    double stdDev=sqrt(dt);
    double kappa=0.06;
    double upsilon=0.05;
    double dw[2];
    

	for(outerLupe=0;outerLupe<45000;++outerLupe)
		{


			x[0]=x0;
			x[1]=y0;
    
			for (lupe=0;lupe < N;++lupe)
				{
					xinter[0]=x[0];
					xinter[1]=x[1];
        
					normalDistRand(stdDev,dw);
        
#ifdef MULTIPLICATIVE_NOISE
					x[0] += f1(xinter[0], xinter[1], alpha, gamma, D)*dt +
						upsilon*xinter[0]*dw[0] +
						upsilon*upsilon*xinter[0]*0.5*(dw[0]*dw[0]-dt);
					x[1] += f2(xinter[0], xinter[1], beta, rho, delta, R)*dt +
						kappa*xinter[1]*dw[1] +
						kappa*kappa*xinter[1]*0.5*(dw[1]*dw[1]-dt);
#else
					x[0] += f1(xinter[0], xinter[1], alpha, gamma, D)*dt +
						upsilon*dw[0];
					x[1] += f2(xinter[0], xinter[1], beta, rho, delta, R)*dt +
						kappa*dw[1];
#endif

					if (x[0]< 0.0) x[0] = 0.0;
					if (x[1]< 0.0) x[1] = 0.0;
            
				}

			printResultsCSV(x,gamma,delta,dataFile);

		}
    
}
コード例 #2
0
///////////////////////////////////////////////////////////////////////
//  Run a range mode bandwidth test
//////////////////////////////////////////////////////////////////////
void
testBandwidthRange(unsigned int start, unsigned int end, unsigned int increment, 
                   memcpyKind kind, printMode printmode, accessMode accMode, memoryMode memMode, int startDevice, int endDevice)
{
    //count the number of copies we're going to run
    unsigned int count = 1 + ((end - start) / increment);
    
    unsigned int * memSizes = (unsigned int *)malloc(count * sizeof( unsigned int ));
    double* bandwidths = (double*)malloc(count * sizeof(double));

    // Before calculating the cumulative bandwidth, initialize bandwidths array to NULL
    for (unsigned int i = 0; i < count; i++)
        bandwidths[i] = 0.0;

    // Use the device asked by the user
    for (int currentDevice = startDevice; currentDevice <= endDevice; currentDevice++)
    {
        // Allocate command queue for the device (dealloc first if already allocated)
        createQueue(currentDevice);

        //run each of the copies
        for(unsigned int i = 0; i < count; i++)
        {
            memSizes[i] = start + i * increment;
            switch(kind)
            {
            case DEVICE_TO_HOST:    bandwidths[i] += testDeviceToHostTransfer(memSizes[i], accMode, memMode);
                break;
            case HOST_TO_DEVICE:    bandwidths[i] += testHostToDeviceTransfer(memSizes[i], accMode, memMode);
                break;
            case DEVICE_TO_DEVICE:  bandwidths[i] += testDeviceToDeviceTransfer(memSizes[i]);
                break;
            }
        }
    } // Complete the bandwidth computation on all the devices

    //print results
    if(printmode == CSV)
    {
        printResultsCSV(memSizes, bandwidths, count, kind, accMode, memMode, (1 + endDevice - startDevice));
    }
    else
    {
        printResultsReadable(memSizes, bandwidths, count, kind, accMode, memMode, (1 + endDevice - startDevice));
    }

    //clean up
    free(memSizes);
    free(bandwidths);
}
コード例 #3
0
//////////////////////////////////////////////////////////////////////////////
// Intense shmoo mode - covers a large range of values with varying increments
//////////////////////////////////////////////////////////////////////////////
void testBandwidthShmoo(memcpyKind kind, printMode printmode, accessMode accMode, 
                   memoryMode memMode, int startDevice, int endDevice)
{
    //count the number of copies to make
    unsigned int count = 1 + (SHMOO_LIMIT_20KB  / SHMOO_INCREMENT_1KB)
        + ((SHMOO_LIMIT_50KB - SHMOO_LIMIT_20KB) / SHMOO_INCREMENT_2KB)
        + ((SHMOO_LIMIT_100KB - SHMOO_LIMIT_50KB) / SHMOO_INCREMENT_10KB)
        + ((SHMOO_LIMIT_1MB - SHMOO_LIMIT_100KB) / SHMOO_INCREMENT_100KB)
        + ((SHMOO_LIMIT_16MB - SHMOO_LIMIT_1MB) / SHMOO_INCREMENT_1MB)
        + ((SHMOO_LIMIT_32MB - SHMOO_LIMIT_16MB) / SHMOO_INCREMENT_2MB)
        + ((SHMOO_MEMSIZE_MAX - SHMOO_LIMIT_32MB) / SHMOO_INCREMENT_4MB);

    unsigned int *memSizes = (unsigned int *)malloc(count * sizeof(unsigned int));
    double* bandwidths = (double*)malloc(count * sizeof(double));

    // Before calculating the cumulative bandwidth, initialize bandwidths array to NULL
    for (unsigned int i = 0; i < count; i++)
        bandwidths[i] = 0.0;
   
    // Use the device asked by the user
    for (int currentDevice = startDevice; currentDevice <= endDevice; currentDevice++)
    {
        // Allocate command queue for the device (dealloc first if already allocated)
        createQueue(currentDevice);

        //Run the shmoo
        int iteration = 0;
        unsigned int memSize = 0;
        while(memSize <= SHMOO_MEMSIZE_MAX )
        {
            if(memSize < SHMOO_LIMIT_20KB )
            {
                memSize += SHMOO_INCREMENT_1KB;
            }
            else if( memSize < SHMOO_LIMIT_50KB)
            {
                memSize += SHMOO_INCREMENT_2KB;
            }
            else if( memSize < SHMOO_LIMIT_100KB)
            {
                memSize += SHMOO_INCREMENT_10KB;
            }
            else if( memSize < SHMOO_LIMIT_1MB)
            {
                memSize += SHMOO_INCREMENT_100KB;
            }
            else if( memSize < SHMOO_LIMIT_16MB)
            {
                memSize += SHMOO_INCREMENT_1MB;
            }
            else if( memSize < SHMOO_LIMIT_32MB)
            {
                memSize += SHMOO_INCREMENT_2MB;
            }
            else 
            {
                memSize += SHMOO_INCREMENT_4MB;
            }

            memSizes[iteration] = memSize;
            switch(kind)
            {
            case DEVICE_TO_HOST:    bandwidths[iteration] += testDeviceToHostTransfer(memSizes[iteration], accMode, memMode);
                break;
            case HOST_TO_DEVICE:    bandwidths[iteration] += testHostToDeviceTransfer(memSizes[iteration], accMode, memMode);
                break;
            case DEVICE_TO_DEVICE:  bandwidths[iteration] += testDeviceToDeviceTransfer(memSizes[iteration]);
                break;
            }
            iteration++;
            shrLog(".");
        }
    } // Complete the bandwidth computation on all the devices

    //print results
    shrLog("\n");
    if( CSV == printmode)
    {
        printResultsCSV(memSizes, bandwidths, count,  kind, accMode, memMode, (endDevice - startDevice));
    }
    else
    {
        printResultsReadable(memSizes, bandwidths, count, kind, accMode, memMode, (endDevice - startDevice));
    }

    //clean up
    free(memSizes);
    free(bandwidths);
}