void RandomValueBlock::updateRequestedSize() {
    Size s = m_outputNode->getRequestedSize();
    if (s == m_oldValues.size() && s == m_newValues.size()) return;

    m_oldValues.rescale(s);
    m_newValues.rescale(s);
    fillRandom(m_oldValues);
    fillRandom(m_newValues);
}
コード例 #2
0
int main()
{
	double x [100];
	double y [50];
	int i;
	
	srand(time(NULL));
		
	setToZero(x,100);
	/*fillArray(x, 10);*/
	
	fillRandom(&x[0],100);
	printArray(x,100);
	printf("The largest is %6.2f\n",largest(x,100));
	printf("Total is %6.2f\n",sumArray(x,100));
	printf("Ave is %6.2f\n",aveArray(x,100));
	printf("\n@@@@@@@@@@Sorted@@@@@@@@@@@@@@@@@@\n");
	doSort(x,100);
	
	printArray(x,100);
	/*
	fillRandom(y,50);
	printArray(y,50);
	*/
	
	
	
	
	
	
	return 0;
}
コード例 #3
0
ファイル: averageUL.c プロジェクト: railsfanatic/SSE290E
int runAverageWithUpperLimit()
{
	int a[ARRAY_SIZE];
	double average = 0;	// for storing the average
	int limit = 0;		// for storing the limit
	
	printf("9. AVERAGE WITH UPPER LIMIT\n\n");
	printf("Function that accepts an array of integers and an upper limit\n"
		"as its parameters and returns the average of all the elements with\n"
		"values less than or equal to the upper limit.\n\n");
	
	// fill & print an array with random numbers
	fillRandom(ARRAY_SIZE, a, -1000, 1000);
	printArray(ARRAY_SIZE, a);
	
	// get upper limit from the user
	limit = getInteger("Enter upper limit: ");
	
	// calculate the average with upper limit
	average = averageUL(ARRAY_SIZE, a, limit);
	
	// print the result
	printf("The average of the numbers less than %d in the above array is %0.2lf.\n", limit, average);
	
	return 0;
}
コード例 #4
0
int main()
{
	double x[100];
	double y[30];
	double z[10];
	
	int i;
	srand(time(NULL));
	
	/* set element to zero	*/
	init(x,100);
	init(y,30);
	init(z , 10);
	
	/*fillArray(&z[0],10);*/
	fillRandom(x,100);
	/*fillRandom(y, 30);*/
	printArray(x,100);
	printf("The largest is :%6.2f\n",largest(x,100));
	doSort(x,100);
	printf("@@@@@@@@@@@  Sorted @@@@@@@@@@@@@@@@@@\n");
	printArray(x,100);
	
	
	
	/*
	printf("Total is :%6.2f\n",sumArray(x,100)+sumArray(y,30)); 
	printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("Total is :%6.2f\n",aveArray(x,100));
	*/
	
	return 0;
}
void RandomValueBlock::eachFrame(double timeSinceLastFrame) {
    // advance position value:
    double stepTime = m_currentStepTime;
    if (m_inputNode->isConnected() && !m_inputNode->constData().absoluteMaximumIsProvided()) {
        // there is a non-absolute Block connected:
        stepTime *= m_inputNode->getValue();
    }
    if (stepTime == 0) return;
    double progress = timeSinceLastFrame / stepTime;
	if ((m_pos + progress) > 1) {
		// get new values:
        m_oldValues = m_newValues;
        fillRandom(m_newValues);
        m_currentStepTime = m_stepTime + m_stepTime * m_timeVaration * (getRandomValue() * 2 - 1);
        if (m_currentStepTime <= 0) {
            m_currentStepTime = 0.1;
        }
	}
	m_pos = fmod(m_pos + progress, 1.0);

	// calculate current value:
    double fadePos = m_pos / m_fadeRatio;
    HsvDataModifier out(m_outputNode);
	if (fadePos < 1) {
        for (int x=0; x < out.width; ++x) {
            for (int y=0; y < out.height; ++y) {
                double newValue = m_oldValues.at(x, y).v * (1 - fadePos) + m_newValues.at(x, y).v * fadePos;
                out.set(x, y, 0, 0, newValue);
            }
        }
	} else {
        out.setFrom(m_newValues);
    }
}
コード例 #6
0
Uint32 WiiSave::writeFile(WiiFile* file)
{
    Uint32 ret = 0x80;

    m_writer->writeUInt32(0x03ADF17E);
    m_writer->writeUInt32(file->length());
    m_writer->writeByte(file->permissions());
    m_writer->writeByte(file->attributes());
    m_writer->writeByte(file->type());

    Uint8 name[0x45];
    fillRandom(name, 0x45);
    memcpy(name, file->filename().c_str(), file->filename().size());
    name[file->filename().size()] = '\0';
    m_writer->writeBytes((Int8*)name, 0x45);
    Uint8 iv[16];
    fillRandom(iv, 0x10);
    m_writer->writeBytes((Int8*)iv, 0x10);
    Uint8 crap[0x20];
    fillRandom(crap, 0x20);
    m_writer->writeBytes((Int8*)crap, 0x20);

    if (file->type() == WiiFile::File)
    {
        int roundedSize = (file->length() + 63) & ~63;
        Uint8* data = new Uint8[roundedSize];
        memset(data, 0, roundedSize);

        aes_set_key(sd_key);
        aes_encrypt(iv, file->data(), data, roundedSize);

        m_writer->writeBytes((Int8*)data, roundedSize);
        ret += roundedSize;
        delete[] data;
    }

    return ret;
}
コード例 #7
0
ファイル: mtbb101_fillNtuples.C プロジェクト: MycrofD/root
Int_t mtbb101_fillNtuples()
{
   ROOT::EnableThreadSafety();
   // No nuisance for batch execution
   gROOT->SetBatch();

   // Perform the operation sequentially ---------------------------------------

   // Create a random generator and and Ntuple to hold the numbers
   TRandom3 rndm(1);
   TFile ofile("mp101_singleCore.root", "RECREATE");
   TNtuple randomNumbers("singleCore", "Random Numbers", "r");
   fillRandom(randomNumbers, rndm, nNumbers);
   randomNumbers.Write();
   ofile.Close();

   // We now go MP! ------------------------------------------------------------

   // We define our work item
   auto workItem = [](UInt_t workerID) {
      // One generator, file and ntuple per worker
      TRandom3 workerRndm(workerID); // Change the seed
      TFile ofile(Form("mp101_multiCore_%u.root", workerID), "RECREATE");
      TNtuple workerRandomNumbers("multiCore", "Random Numbers", "r");
      fillRandom(workerRandomNumbers, workerRndm, workSize);
      workerRandomNumbers.Write();
      return 0;
   };

   // Create the pool of workers
   ThreadPool pool(nThreads);

   // Fill the pool with work
   pool.Map(workItem, ROOT::TSeqI(nThreads));

   return 0;

}
コード例 #8
0
ファイル: sa.c プロジェクト: RGassmann/Simulated-Annealing
double generateInitialTemp(int amount, Simulated_Annealing_Param_t *param) {
    int i =0;
    double *x;
    double temp;
    double temptemp;
    printf("Generated Temp\n");
    for(i =0; i< amount; i++) {
        x = (double*) calloc( param->optim->n , sizeof(double));
        fillRandom( param->optim->n , param->optim->min , param->optim->max , x );
        temptemp = param->optim->f(param->optim,x);
        printf("Generated: %lf\n",temptemp);
        temp += temptemp;
        free(x);
    }
    temp/=amount;
    return temp;
}
コード例 #9
0
ファイル: plant.cpp プロジェクト: TheBrooks/Graphics
int main (int argc, char** argv) {
  _x_pos = 0;
  fillRandom();
  glutInit(&argc,argv);
  glutInitWindowSize(W, H);
  glutInitWindowPosition(X_OFF, Y_OFF);
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  glutCreateWindow("plant");
  init();
  //glFrustum(-100.0, 100.0, -50.0,50.0,-50.0,50.0  );
  glutDisplayFunc(display);
  glutKeyboardFunc(myKeyHandler);
  glutMotionFunc(mouseTrack);

  glutMainLoop();
  return 0;
}
コード例 #10
0
ファイル: gtetrix.cpp プロジェクト: opieproject/qte-opie
void GenericTetrix::clearBoard(int fillRandomLines)
{
    int i,j;

    if (fillRandomLines >= height)
        fillRandomLines = height - 1;

    erasePiece();
    for(i = height - nClearLines - 1 ; i >= fillRandomLines ; i--)
        for(j = 0 ; j < width ; j++)
            if (board(j,i) != 0) {
                draw(j,i,0);
                board(j,i) = 0;
            }
    if (fillRandomLines != 0)
        for (i = 0 ; i < fillRandomLines ; i++) {
            fillRandom(i);
    }
    nClearLines = height - fillRandomLines;
}
コード例 #11
0
ファイル: stateArray.hpp プロジェクト: jeez/iqr
	/*
	 * Fill the current valarray ([0]) with 0 or 1 using the
	 * specified probability of 1 occuring.
	 */
	void fillProbabilityMask(double probability)
	{
	    fillRandom();

	    // Ensure that no errors occur for probability=1 by
	    // scaling the random values to 0<=value<1.  Use a value
	    // just under 1, we only need to ensure that probability 1
	    // gives a mask with all 1s.
	    static const double PROBABILITY_MASK_SCALE = 0.99999999;
	    buffer[0] *= PROBABILITY_MASK_SCALE;

	    // For probability=1, no values in the random buffer are
	    // less than 1-P=0 => no entries will be 0.0
	    buffer[0][buffer[0] < (1.0 - probability)] = 0.0;
	    // For probability=0, the scaling above ensures that no
	    // random value is equal to 1-P=1 => no entries will be 1.0

	    // For probability=1, all values in the buffer are at
	    // least equal to 1-P=0 => all entries are 1.0
	    buffer[0][buffer[0] >=  (1.0 - probability)] = 1.0;	    
	}
コード例 #12
0
ファイル: aca.cpp プロジェクト: hezihertz/fmmtl
int main() {
  using value_type = double;

  const unsigned N = 5;
  const unsigned M = 5;
  const unsigned r = 3;

  flens::matrix<value_type> A(N,M);
#if 0
  A = 2.0;
#endif
#if 1
  fillRandom(A);
#endif
#if 0
  A[1][1] = 1;
  A[1][3] = 2;
  A[3][1] = 1;
  A[3][3] = 4;
#endif

  std::cout << "A = \n" << A << std::endl;

  flens::matrix<double> U, V;

  std::tie(U, V) = adaptive_cross_approx(A, 1e-10, r);

  std::cout << "FINAL RANK = " << num_cols(U) << std::endl;
  std::cout << "U = \n" << U << std::endl;
  std::cout << "V = \n" << V << std::endl;
  std::cout << "UV = \n" << flens::matrix<value_type>(U*V) << std::endl;

  flens::matrix<value_type> Res;
  Res = A - U*V;

  std::cout << "Residual = \n" << Res << std::endl;
  std::cout << "norm_F = " << frobenius_norm(Res) << std::endl;

  return 0;
}
コード例 #13
0
int runSmallestRandomNumber() {
	// declarations
	int a[ARRAY_SIZE] = {0}; // array of integers
	int index = 0; // index of smallest value
	
	// print banner
	printf("1. SMALLEST RANDOM NUMBER\n\n");
	printf("Fills an array with random integers and then finds the\n"
		"position of the smallest element in the array. Prints the\n"
		"value of the smallest number.\n\n");
	
	// fill & print array with random ints
	fillRandom(ARRAY_SIZE, a, -1000, 1000);
	printArray(ARRAY_SIZE, a);
	
	// set index of smallest value
	index = findLowest(ARRAY_SIZE, a);
	
	// print the result
	printf("The smallest value is a[%d] = %d\n", index, a[index]);
	return 0;
}
コード例 #14
0
ファイル: probe.cpp プロジェクト: hezihertz/fmmtl
int main() {
  using value_type = double;

  const unsigned N = 10;
  const unsigned M = 10;
  const unsigned r = 5;
  const double eps = 1e-10;

  flens::matrix<value_type> A(N,M);
#if 0
  A = 2.0;
#endif
#if 0
  fillRandom(A);
#endif
#if 1
  A(1,1) = 1;
  A(1,3) = 2;
  A(3,1) = 1;
  A(3,3) = 4;
#endif

  std::cout << "A(" << A.rows() << ", " << A.cols() << ") = " << A << std::endl;

  flens::matrix<double> U, V;

  std::tie(U, V) = probe_svd(A, r, eps);

  std::cout << "U(" << U.rows() << ", " << U.cols() << ") = " << U << std::endl;
  std::cout << "V(" << V.rows() << ", " << V.cols() << ") = " << V << std::endl;

  if (num_rows(U) != 0)
    std::cout << flens::matrix<double>(A - U*V) << std::endl;

  return 0;
}
コード例 #15
0
ファイル: testKernels.c プロジェクト: Pitxyoki/Cheetah
bool createTestFFT (JobToPUM *job) {
  job->probID = myid;

//  job->runOn = CL_DEVICE_TYPE_CPU; //TO BE FILLED BY THE JS

  job->nDimensions = 1;
  job->nItems[0] = 64;
  job->nGroupItems[0] = 64;

  job->startingKernel = malloc(sizeof("kfft"));
  strcpy(job->startingKernel,"kfft");
  job->startingNameSize = strlen(job->startingKernel)+1;

  job->taskSource = fileToString(DATADIR"/pumanager/FFT_Kernels.cl");
  if (job->taskSource == NULL) {
    fprintf(stderr,"FILE NOT FOUND! (building testFFT)\n");
    return false;
  }
  job->taskSourceSize = strlen(job->taskSource)+1;

  ///Setting up arguments
  job->nTotalArgs = 2;
  job->argTypes = calloc(job->nTotalArgs, sizeof(argument_type));
  job->argTypes[0] = INPUT_OUTPUT;
  job->argTypes[1] = INPUT_OUTPUT;

  job->argSizes = calloc(job->nTotalArgs, sizeof(int));
  job->argSizes[0] = job->argSizes[1] = 1024*sizeof(cl_uint);


  inBuff1 = calloc(1024, sizeof(cl_float));
  inBuff2 = calloc(1024, sizeof(cl_float));


  if (!fillRandom(inBuff1, 1024, 0, 255)) {
    fprintf(stderr, "Error filling input buffer 1 for FFT kernel\n");
    return false;
  }
  if (!fillRandom(inBuff2, 1024, 0, 0)) {
    fprintf(stderr, "Error filling input buffer 2 for FFT kernel\n");
    return false;
  }

  job->arguments = calloc(job->nTotalArgs, sizeof(void *));
  job->arguments[0] = calloc(1024, sizeof(cl_float));
  job->arguments[1] = calloc(1024, sizeof(cl_float));
  memcpy(job->arguments[0], inBuff1, 1024*sizeof(cl_float));
  memcpy(job->arguments[1], inBuff2, 1024*sizeof(cl_float));


  if(debug_PUM) {
    printf("Original Input Real: ");
    print1DArray(inBuff1, NUM_PRINT1DARRAY_ELEMS);
    printf("Original Input Imaginary: ");
    print1DArray(inBuff2, NUM_PRINT1DARRAY_ELEMS);
  }

//  job->returnTo = defaultRCID; //not used


  return true;
}
コード例 #16
0
ファイル: sa.c プロジェクト: RGassmann/Simulated-Annealing
void SimAnn(Simulated_Annealing_Param_t *param, const char *filename) {

    bool pingpong = 0;
    int i =0;
    int j =0;
    double delta =0;
    FILE *file;
    file = fopen(filename,"a+");
    if(file == NULL) {
        fprintf(stderr, "Could not open File!\n");
        exit(EXIT_FAILURE);
    }

    for(j=0; j < param->optim->n; j++) {
        printf("limit[%d]: %lf  --  %lf\n",j,param->optim->min[j] ,param->optim->max[j] );
    }

    if(param->temp == 0) param->temp = generateInitialTemp(10, param);

    enum {SAinit, SAnewDPoint, SAMetropolisCrit, SAReduceTemp, SAStop} state;

    state = SAinit;


    while(state != SAStop)
    {
        switch(state) {
        case SAinit:
            param->dP[pingpong].x = (double *) calloc(param->optim->n, sizeof(double));
            param->dP[!pingpong].x = (double *) calloc(param->optim->n, sizeof(double));
            if(param->dP[pingpong].x == NULL) {
                state = SAStop;
                printf("Error: Could not allocate Memory!");
                break;
            }

            fillRandom( param->optim->n , param->optim->min , param->optim->max , param->dP[pingpong].x );
            param->dP[pingpong].temp = param->optim->f( param->optim , param->dP[pingpong].x );

            printf("Starttemperatur = %lf\n", param->temp);
            state = SAnewDPoint;
            i=1;
            pingpong = 1;
            break;
        case SAnewDPoint:

            for(j=0; j < param->optim->n; j++) {
                param->dP[pingpong].x[j] = limit(param->optim->min[j], param->optim->max[j], 										param->dP[!pingpong].x[j]+(((double)gen_rand())/1000000.00*2.0*param->vicinity)-param->vicinity );

                if(param->dP[pingpong].x[j] > param->optim->max[j]) printf("Heep %lf\n", param->dP[pingpong].x[j]);

            }
            param->dP[pingpong].temp = param->optim->f(param->optim,param->dP[pingpong].x);

            delta = param->dP[pingpong].temp - param->dP[!pingpong].temp;


            if(delta > 0) { /* higher temp then before */
                if(pow(2.71828182845,-delta/param->temp) < ((double)gen_rand())/1000000.00)
                    break;
            }

            for (j=0; j<param->optim->n; j++) fprintf (file, "%lf, ",param->dP[pingpong].x[j]);

            fprintf(file,"%lf \n",param->dP[pingpong].temp);
            //printf("%lf %lf %lf\n", designPoints[index-1].x, designPoints[index-1].y, designPoints[index-1].res);
            pingpong =!pingpong;
            i++;
            if( i > param->iterations ) state = SAReduceTemp;
            break;
        case SAReduceTemp:
            param->temp *= param->tempCoeff;
            if(param->temp < param->stopTemp) {
                printf("Stoptemperatur = %lf\n",param->temp);
                state = SAStop;
                break;
            }
            i=1;
            state = SAnewDPoint;
            break;

        default:
            break;
        }


    }
    fclose(file);
    free(param->dP[pingpong].x);
    free(param->dP[!pingpong].x);
}
コード例 #17
0
int main(int argc, char** argv) {
    /* OpenCL 1.1 data structures */
    cl_platform_id* platforms;
    cl_program program;
    cl_device_id device;
    cl_context context;
    cl_command_queue queue;
    cl_uint numOfPlatforms;
    cl_int  error;

    cl_mem matrixAMemObj; // input matrix A mem buffer
    cl_mem matrixBMemObj; // input matrix B mem buffer
    cl_mem matrixCMemObj; // input matrix C mem buffer
    cl_int* matrixA;      // input matrix A
    cl_int* matrixB;      // input matrix B
    cl_int* matrixC;      // input matrix C
    cl_uint widthA = WIDTH_G;
    cl_uint heightA = HEIGHT_G;
    cl_uint widthB = WIDTH_G;
    cl_uint heightB = HEIGHT_G;

	{
	    // allocate memory for input and output matrices 
        // based on whatever matrix theory i know.
	    matrixA = (cl_int*)malloc(widthA * heightA * sizeof(cl_int));
	    matrixB = (cl_int*)malloc(widthB * heightB * sizeof(cl_int));
	    matrixC = (cl_int*)malloc(widthB * heightA * sizeof(cl_int));

	    memset(matrixA, 0, widthA * heightA * sizeof(cl_int));
	    memset(matrixB, 0, widthB * heightB * sizeof(cl_int));
	    memset(matrixC, 0, widthB * heightA * sizeof(cl_int));
        
        fillRandom(matrixA, widthA, heightA, 643);
        fillRandom(matrixB, widthB, heightB, 991);
    }

    /*
     Get the number of platforms
     Remember that for each vendor's SDK installed on the computer,
     the number of available platform also increased.
     */
    error = clGetPlatformIDs(0, NULL, &numOfPlatforms);
    if(error != CL_SUCCESS) {
        perror("Unable to find any OpenCL platforms");
        exit(1);
    }
    
    platforms = (cl_platform_id*) alloca(sizeof(cl_platform_id) * numOfPlatforms);
    printf("Number of OpenCL platforms found: %d\n", numOfPlatforms);
    
    error = clGetPlatformIDs(numOfPlatforms, platforms, NULL);
    if(error != CL_SUCCESS) {
        perror("Unable to find any OpenCL platforms");
        exit(1);
    }
    // Search for a GPU device through the installed platforms
    // Build a OpenCL program and do not run it.
    for(cl_int i = 0; i < numOfPlatforms; i++ ) {
        // Get the GPU device
        error = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, 1, &device, NULL);

        if(error != CL_SUCCESS) {
            perror("Can't locate a OpenCL compliant device i.e. GPU");
            exit(1);
        }
        /* Create a context */
        context = clCreateContext(NULL, 1, &device, NULL, NULL, &error);
        if(error != CL_SUCCESS) {
            perror("Can't create a valid OpenCL context");
            exit(1);
        }
        
        /* Load the two source files into temporary datastores */
        const char *file_names[] = {"simple_mm_mult.cl"};
        const int NUMBER_OF_FILES = 1;
        char* buffer[NUMBER_OF_FILES];
        size_t sizes[NUMBER_OF_FILES];
        loadProgramSource(file_names, NUMBER_OF_FILES, buffer, sizes);
        
        /* Create the OpenCL program object */
        program = clCreateProgramWithSource(context, NUMBER_OF_FILES, (const char**)buffer, sizes, &error);
	    if(error != CL_SUCCESS) {
            perror("Can't create the OpenCL program object");
            exit(1);
	    }
        /* Build OpenCL program object and dump the error message, if any */
        char *program_log;
        const char options[] = "";
        size_t log_size;

        error = clBuildProgram(program, 1, &device, options, NULL, NULL);
	    if(error != CL_SUCCESS) {
            // If there's an error whilst building the program, dump the log
            clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
            program_log = (char*) malloc(log_size+1);
            program_log[log_size] = '\0';
            clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,
                                  log_size+1, program_log, NULL);
            printf("\n=== ERROR ===\n\n%s\n=============\n", program_log);
            free(program_log);
            exit(1);
	    }
       
        // Queue is created with profiling enabled 
        cl_command_queue_properties props;
        props |= CL_QUEUE_PROFILING_ENABLE;

        queue = clCreateCommandQueue(context, device, props, &error);

        cl_kernel kernel = clCreateKernel(program, "mmmult", &error);

        matrixAMemObj = clCreateBuffer(context,
                                       CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR,
                                       widthA * heightA * sizeof(cl_int),
                                       matrixA,
                                       &error);

        matrixBMemObj = clCreateBuffer(context,
                                       CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR,
                                       widthB * heightB * sizeof(cl_int),
                                       matrixB,
                                       &error);

        matrixCMemObj = clCreateBuffer(context,
                                       CL_MEM_WRITE_ONLY|CL_MEM_ALLOC_HOST_PTR,
                                       widthB * heightA * sizeof(cl_int),
                                       0,
                                       &error);

        clSetKernelArg(kernel, 0, sizeof(cl_int),(void*)&widthB);
        clSetKernelArg(kernel, 1, sizeof(cl_int),(void*)&heightA);
        clSetKernelArg(kernel, 2, sizeof(cl_mem),(void*)&matrixAMemObj);
        clSetKernelArg(kernel, 3, sizeof(cl_mem),(void*)&matrixBMemObj);
        clSetKernelArg(kernel, 4, sizeof(cl_mem),(void*)&matrixCMemObj);
         
        size_t globalThreads[] = {widthB, heightA};

		cl_event exeEvt; 
        cl_ulong executionStart, executionEnd;
		error = clEnqueueNDRangeKernel(queue,
		                               kernel,
		                               2,
		                               NULL,
                                       globalThreads,
                                       NULL, 
                                       0,
                                       NULL,
                                       &exeEvt);
		clWaitForEvents(1, &exeEvt);
		if(error != CL_SUCCESS) {
			printf("Kernel execution failure!\n");
			exit(-22);
		}	

        // let's understand how long it took?
        clGetEventProfilingInfo(exeEvt, CL_PROFILING_COMMAND_START, sizeof(executionStart), &executionStart, NULL);
        clGetEventProfilingInfo(exeEvt, CL_PROFILING_COMMAND_END, sizeof(executionEnd), &executionEnd, NULL);
        clReleaseEvent(exeEvt);

//        printf("Execution the matrix-matrix multiplication took %lu.%lu s\n", (executionEnd - executionStart)/1000000000, (executionEnd - executionStart)%1000000000);
        printf("Execution the matrix-matrix multiplication took %lu s\n", (executionEnd - executionStart));
        clEnqueueReadBuffer(queue,
                            matrixCMemObj,
                            CL_TRUE,
                            0,
                            widthB * heightA * sizeof(cl_int),
                            matrixC,
                            0,
                            NULL,
                            NULL);
       
        if (compare(matrixC, matrixA, matrixB, heightA, widthA, widthB))
            printf("Passed!\n");
        else 
            printf("Failed!\n");
 
        /* Clean up */
        for(i=0; i< NUMBER_OF_FILES; i++) { free(buffer[i]); }
        clReleaseProgram(program);
        clReleaseContext(context);
        clReleaseMemObject(matrixAMemObj);
        clReleaseMemObject(matrixBMemObj);
        clReleaseMemObject(matrixCMemObj);
    }
    
    free(matrixA);
    free(matrixB);
    free(matrixC);
}