int PrefixSum::run() { int status = 0; // Warm up for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); for(int i = 0; i < iterations; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } sampleCommon->stopTimer(timer); totalKernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; if(!quiet) { sampleCommon->printArray<cl_float>("Output", output, length, 1); } return SDK_SUCCESS; }
int FloydWarshall::run() { for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); for(int i = 0; i < iterations; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } sampleCommon->stopTimer(timer); totalKernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; if(!quiet) { sampleCommon->printArray<cl_uint>("Output Path Distance Matrix", pathDistanceMatrix, numNodes, 1); sampleCommon->printArray<cl_uint>("Output Path Matrix", pathMatrix, numNodes, 1); } return SDK_SUCCESS; }
int BinomialOption::run() { // Warm up for(int i = 0; i < 2 && iterations != 1; i++) { if(runCLKernels()) return SDK_FAILURE; } std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); for(int i = 0; i < iterations; i++) { if(runCLKernels()) return SDK_FAILURE; } sampleCommon->stopTimer(timer); // Compute average kernel time kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; if(!quiet) sampleCommon->printArray<cl_float>("Output", output, numSamples, 1); return SDK_SUCCESS; }
int ScanLargeArrays::run() { for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } // create and initialize timers int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; for(int i = 0; i < iterations; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } sampleCommon->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; if(!quiet) { sampleCommon->printArray<cl_float>("Output", output, length, 1); } return SDK_SUCCESS; }
int NBody::run() { /* Arguments are set and execution call is enqueued on command buffer */ if(setupCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } if(verify || timing) { int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); for(int i = 0; i < iterations; ++i) { runCLKernels(); } sampleCommon->stopTimer(timer); /* Compute kernel time */ kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; } if(!quiet) { sampleCommon->printArray<cl_float>("Output", pos, numBodies, 1); } return SDK_SUCCESS; }
int DeviceFission::run() { // Execute kernel on device if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; if(!quiet) { sampleCommon->printArray<cl_int>("Sub devices first half output:", subOutput, half_length, 1); sampleCommon->printArray<cl_int>("Sub devices second half output:", subOutput + half_length, half_length, 1); if(gpuAvailable) { sampleCommon->printArray<cl_int>("GPU device first half output:", gpuOutput, half_length, 1); sampleCommon->printArray<cl_int>("GPU device second half output:", gpuOutput + half_length, half_length, 1); } else { sampleCommon->printArray<cl_int>("CPU device first half output:", gpuOutput, half_length, 1); sampleCommon->printArray<cl_int>("CPU device second half output:", gpuOutput + half_length, half_length, 1); } } return SDK_SUCCESS; }
int BinomialOption::run() { int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; for(int i = 0; i < iterations; i++) { /* Arguments are set and execution call is enqueued on command buffer */ if(runCLKernels()!=SDK_SUCCESS) { return SDK_FAILURE; } } sampleCommon->stopTimer(timer); /* Compute average kernel time */ kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; if(!quiet) { sampleCommon->printArray<cl_float>("Output", output, numSamples, 1); } return SDK_SUCCESS; }
int ImageOverlap::run() { int status; // create and initialize timers int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); std::cout << "Executing kernel for " << iterations << " iterations" <<std::endl; std::cout << "-------------------------------------------" << std::endl; for(int i = 0; i < iterations; i++) { // Set kernel arguments and run kernel status = runCLKernels(); CHECK_ERROR(status, SDK_SUCCESS, "OpenCL run Kernel failed"); } sampleCommon->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; return SDK_SUCCESS; }
int SimpleImage::run() { if(!byteRWSupport) return SDK_SUCCESS; /* create and initialize timers */ int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); std::cout << "Executing kernel for " << iterations << " iterations" <<std::endl; std::cout << "-------------------------------------------" << std::endl; for(int i = 0; i < iterations; i++) { /* Set kernel arguments and run kernel */ if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } sampleCommon->stopTimer(timer); /* Compute kernel time */ kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; /* write the output image to bitmap file */ if(writeOutputImage(OUTPUT_IMAGE) != SDK_SUCCESS) { return SDK_FAILURE; } return SDK_SUCCESS; }
int BoxFilterSeparable::run() { if(!byteRWSupport) { return SDK_SUCCESS; } for(int i = 0; i < 2 && iterations != 1; i++) { // Set kernel arguments and run kernel if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } std::cout << "Executing kernel for " << iterations << " iterations" <<std::endl; std::cout << "-------------------------------------------" << std::endl; // create and initialize timers int timer =sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); for(int i = 0; i < iterations; i++) { // Set kernel arguments and run kernel if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } sampleTimer->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleTimer->readTimer(timer)) / iterations; // write the output image to bitmap file if(writeOutputImage(OUTPUT_IMAGE) != SDK_SUCCESS) { return SDK_FAILURE; } return SDK_SUCCESS; }
int URNG::run() { cl_int status = 0; if(!byteRWSupport) { return SDK_SUCCESS; } // Warm up for(int i = 0; i < 2 && iterations != 1; i++) { // Set kernel arguments and run kernel if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } std::cout << "Executing kernel for " << iterations << " iterations" <<std::endl; std::cout << "-------------------------------------------" << std::endl; // create and initialize timers int timer = sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); for(int i = 0; i < iterations; i++) { // Set kernel arguments and run kernel if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } sampleTimer->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleTimer->readTimer(timer)) / iterations; // write the output image to bitmap file status = writeOutputImage(OUTPUT_IMAGE); CHECK_ERROR(status , SDK_SUCCESS, "Write Output Image"); return SDK_SUCCESS; }
int Histogram::run() { if(!byteRWSupport) { return SDK_SUCCESS; } for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; int timer = sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); for(int i = 0; i < iterations; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } sampleTimer->stopTimer(timer); // Compute average kernel time kernelTime = (double)(sampleTimer->readTimer(timer)); if(!sampleArgs->quiet) { printArray<cl_uint>("deviceBin", deviceBin, binSize, 1); } return SDK_SUCCESS; }
int MersenneTwister::run() { //Warm up for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } int timer = sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; for(int i = 0; i < iterations; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } sampleTimer->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleTimer->readTimer(timer)) / iterations; if(!sampleArgs->quiet) { printArray<cl_float>("Output", deviceResult, width * mulFactor * 4, 1); } return SDK_SUCCESS; }
int PrefixSum::run() { /* Arguments are set and execution call is enqueued on command buffer */ if(runCLKernels()!=SDK_SUCCESS) return SDK_FAILURE; if(!quiet) { sampleCommon->printArray<cl_float>("Output", output, length, 1); } return SDK_SUCCESS; }
int Reduction::run() { /* Arguments are set and execution call is enqueued on command buffer */ if(runCLKernels()!=SDK_SUCCESS) return SDK_FAILURE; if(!quiet) sampleCommon->printArray<cl_uint>("Output", &output, 1, 1); return SDK_SUCCESS; }
int DwtHaar1D::run() { // Warm up for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; int timer = sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); for(int i = 0; i < iterations; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } sampleTimer->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleTimer->readTimer(timer)) / iterations; if(!sampleArgs->quiet) { printArray<cl_float>("dOutData", dOutData, 256, 1); } return SDK_SUCCESS; }
int MatrixMulDouble::run() { // Warm up for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer int kernelRun = runCLKernels(); CHECK_ERROR(kernelRun, SDK_SUCCESS, "OpenCL's runCLKernels failed"); } kernelTime = 0; int timer = sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); std::cout << "Executing kernel for " << iterations << " iterations" << std::endl; std::cout << "-------------------------------------------" << std::endl; for(int i = 0; i < iterations; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } sampleTimer->stopTimer(timer); appTime = (double)(sampleTimer->readTimer(timer)) / iterations; kernelTime /= iterations; if(!sampleArgs->quiet) { printArray<cl_double>("Output", output, widthB, 1); } return SDK_SUCCESS; }
int NBody::run() { /* Arguments are set and execution call is enqueued on command buffer */ setupCLKernels(); if(verify || timing) { for(int i = 0; i < iterations; ++i) { runCLKernels(); } } return 0; }
int SobelFilterImage::run() { for(int i = 0; i < iterations; i++) { // Set kernel arguments and run kernel if(runCLKernels() != 0) { return -1; } } return 0; }
int FluidSimulation2D::run() { if(!reqdExtSupport) return SDK_SUCCESS; // Arguments are set and execution call is enqueued on command buffer if(setupCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } if(display == 0) { // Warm up for(int i = 0; i < 2 && iterations != 1; ++i) { runCLKernels(); } int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); for(int i = 0; i < iterations; ++i) { runCLKernels(); } sampleCommon->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; } return SDK_SUCCESS; }
int GlobalMemoryBandwidth::run() { int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; sampleCommon->stopTimer(timer); totalKernelTime = (double)(sampleCommon->readTimer(timer)); return SDK_SUCCESS; }
int ComputeBench::run() { bool useSVM = false; // Arguments are set and execution call is enqueued on command buffer if (runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } if (sampleArgs->verify && verifyResults() != SDK_SUCCESS) { return SDK_FAILURE; } printStats(); return SDK_SUCCESS; }
int BoxFilterGLSeparable::run() { if(!byteRWSupport) return SDK_SUCCESS; /* create and initialize timers */ int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); if(!quiet) { std::cout << "Executing kernel for " << iterations << " iterations" <<std::endl; std::cout << "-------------------------------------------" << std::endl; } for(int i = 0; i < iterations; i++) { /* Set kernel arguments and run kernel */ if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } sampleCommon->stopTimer(timer); /* Compute kernel time */ kernelTime = (double)(sampleCommon->readTimer(timer)) / iterations; if(!verify && !quiet) { std::cout << "\nPress key w to increase the filter size \n"; std::cout << "Press key s to decrease the filter size \n"; std::cout << "Press ESC key to quit \n"; glutMainLoop(); } /* write the output image to bitmap file */ if(writeOutputImage(OUTPUT_SEPARABLE_IMAGE) != SDK_SUCCESS) { return SDK_FAILURE; } return SDK_SUCCESS; }
int LDSBandwidth::run() { int timer = sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } sampleTimer->stopTimer(timer); kernelTime = (double)(sampleTimer->readTimer(timer)); return SDK_SUCCESS; }
int MemoryOptimizations::run() { int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); /* Arguments are set and execution call is enqueued on command buffer */ int kernelRun = runCLKernels(); if(kernelRun != SDK_SUCCESS) { return kernelRun; } sampleCommon->stopTimer(timer); totalKernelTime = (double)(sampleCommon->readTimer(timer)); return SDK_SUCCESS; }
int UnsharpMask::run() { std::cout << "Executing kernel for " << iterations << " iterations" <<std::endl; std::cout << "-------------------------------------------" << std::endl; // create and initialize timers int timer = sampleTimer->createTimer(); sampleTimer->resetTimer(timer); sampleTimer->startTimer(timer); try { for(int i = 0; i < iterations; i++) { // Set kernel arguments and run kernel if(runCLKernels() != SDK_SUCCESS) { return SDK_FAILURE; } } } catch (cl::Error e) { std::cout << e.what() << std::endl; std::cout << "Error code: " << e.err() << std::endl; return SDK_FAILURE; } queue.finish(); sampleTimer->stopTimer(timer); // Compute kernel time kernelTime = (double)(sampleTimer->readTimer(timer))/ iterations; return SDK_SUCCESS; }
int MathBenchmark::run() { /* // Warm up for(int i = 0; i < 2 && iterations != 1; i++) { // Arguments are set and execution call is enqueued on command buffer if(runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; } */ int timer = sampleCommon->createTimer(); sampleCommon->resetTimer(timer); sampleCommon->startTimer(timer); if (runCLKernels() != SDK_SUCCESS) return SDK_FAILURE; sampleCommon->stopTimer(timer); totalKernelTime = (double) sampleCommon->readTimer(timer); //if(!quiet) { // sampleCommon->printArray<cl_float>("Output", eigenIntervals[1], 2*length, 1); //} return SDK_SUCCESS; }