TEST_P(CopyTexImageTest, SubImageRGBToL)
{
    // TODO (geofflang): Figure out why CopyTex[Sub]Image doesn't work with
    // RGB->L on older Intel chips
    if (isIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
    {
        std::cout << "Test skipped on Intel OpenGL." << std::endl;
        return;
    }

    GLfloat color0[] = {
        0.25f, 1.0f, 0.75f, 0.5f,
    };
    GLuint fbo0 = createFramebuffer(GL_RGB, GL_UNSIGNED_BYTE, color0);
    GLuint tex  = createTextureFromCopyTexImage(fbo0, GL_LUMINANCE);

    GLfloat color1[] = {
        0.5f, 0.25f, 1.0f, 0.75f,
    };
    GLuint fbo1 = createFramebuffer(GL_RGB, GL_UNSIGNED_BYTE, color1);
    copyTextureWithCopyTexSubImage(fbo1, tex, 2, 4, 5, 6, 8, 8);

    GLubyte expected0[] = {
        64, 64, 64, 255,
    };
    verifyResults(tex, expected0, 0, 0);

    GLubyte expected1[] = {
        127, 127, 127, 255,
    };
    verifyResults(tex, expected1, 7, 7);
}
int BoxFilterSeparable::runSeparableVersion(int argc, char* argv[]) {
  if (initialize() != SDK_SUCCESS) {
    return SDK_FAILURE;
  }

  if (sampleArgs->parseCommandLine(argc, argv)) {
    return SDK_FAILURE;
  }

  if (sampleArgs->isDumpBinaryEnabled()) {
    return genBinaryImage();
  } else {
    if (setup() != SDK_SUCCESS) {
      return SDK_FAILURE;
    }

    if (run() != SDK_SUCCESS) {
      return SDK_FAILURE;
    }

    if (verifyResults() != SDK_SUCCESS) {
      return SDK_FAILURE;
    }

    if (cleanup() != SDK_SUCCESS) {
      return SDK_FAILURE;
    }

    printStats();
  }
  return SDK_SUCCESS;
}
Exemple #3
0
int main(int argc, char* argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <m> [<numTrials> <alpha> <epsilon>]\n", argv[0]);
    fprintf(stderr, "  m is the problem size\n");
    fprintf(stderr, "  numTrials is the number of trials to run\n");
    fprintf(stderr, "  alpha is the scalar multiplier\n");
    fprintf(stderr, "  epsilon is the tolerance for verification\n");
    exit(0);
  }

  m = atoi(argv[1]);
  if (argc >= 3) {
    numTrials = atoi(argv[2]);
    if (argc >= 4) {
      alpha = atof(argv[3]);
      if (argc >= 5) {
        epsilon = atof(argv[4]);
      }
    }
  }
  

  printConfiguration();
  elemType* const __restrict A = (elemType*)malloc(m*sizeof(elemType));
  elemType* const __restrict B = (elemType*)malloc(m*sizeof(elemType));
  elemType* const __restrict C = (elemType*)malloc(m*sizeof(elemType));
  
  initVectors(B, C);

  double execTime[numTrials];

  int trial;
  for (trial=0; trial<numTrials; trial++) {
    double startTime = getCurrentTime();

    int j;
    double* __restrict APtr = A;
    const double* __restrict BPtr = B;
    const double* __restrict CPtr = C;
    for (j=0; j<m; j++) {
      *(APtr++) = *(BPtr++) + alpha * *(CPtr++);
    }
    
    execTime[trial] = getCurrentTime() - startTime;
  }

  int validAnswer = verifyResults(A, B, C);
  printResults(validAnswer, execTime);

  return 0;
}
Exemple #4
0
TEST_P(CopyTexImageTest, RGBAToA)
{
    GLfloat color[] = {
        0.25f, 1.0f, 0.75f, 0.5f,
    };

    GLuint fbo = createFramebuffer(GL_RGBA, GL_UNSIGNED_BYTE, color);
    GLuint tex = createTextureFromCopyTexImage(fbo, GL_ALPHA);

    GLubyte expected[] = {
        0, 0, 0, 127,
    };
    verifyResults(tex, expected, 0, 0);
}
Exemple #5
0
TEST_P(CopyTexImageTest, RGBToL)
{
    GLfloat color[] = {
        0.25f, 1.0f, 0.75f, 0.5f,
    };

    GLuint fbo = createFramebuffer(GL_RGB, GL_UNSIGNED_BYTE, color);
    GLuint tex = createTextureFromCopyTexImage(fbo, GL_LUMINANCE);

    GLubyte expected[] = {
        64, 64, 64, 255,
    };
    verifyResults(tex, expected, 0, 0);
}
Exemple #6
0
TEST_P(CopyTexImageTest, SubImageRGBToL)
{
    GLfloat color0[] = {
        0.25f, 1.0f, 0.75f, 0.5f,
    };
    GLuint fbo0 = createFramebuffer(GL_RGB, GL_UNSIGNED_BYTE, color0);
    GLuint tex  = createTextureFromCopyTexImage(fbo0, GL_LUMINANCE);

    GLfloat color1[] = {
        0.5f, 0.25f, 1.0f, 0.75f,
    };
    GLuint fbo1 = createFramebuffer(GL_RGB, GL_UNSIGNED_BYTE, color1);
    copyTextureWithCopyTexSubImage(fbo1, tex, 2, 4, 5, 6, 8, 8);

    GLubyte expected0[] = {
        64, 64, 64, 255,
    };
    verifyResults(tex, expected0, 0, 0);

    GLubyte expected1[] = {
        127, 127, 127, 255,
    };
    verifyResults(tex, expected1, 7, 7);
}
Exemple #7
0
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;
}
Exemple #8
0
void thread_task(const int AS, const int num_of_nodes, int ingr_node_counter) 
{
    std::cout << std::endl << "------------ PROCESSING AS GRAPH --------------------" << std::endl << std::endl;

    // declare variables
    std::stringstream sstm;
    std::string ID_ = "AS";
    Graph * gr = NULL;

    std::uniform_real_distribution<double> RANDOM_GENERATOR(1, MAX_NUM_OF_INGRESS_);
    float multipleDeviceElapsedTime = 0, singleDeviceElapsedTime = 0, hostElapsedTime = 0, oldHostElapsedTime = 0;

    // create the AS id for the file name
    sstm << ID_ << AS;
    ID_ = sstm.str();

    std::cout << "Generating Topology..." << std::endl;

    // create brite and generate the topology
    Brite *b_topology = new Brite();
    
    if(num_of_nodes < 500000)
    {
	std::cout << "Generating" << std::endl;
        gr = b_topology->GenerateTopology(AS, num_of_nodes);
    }
    else
    {
	std::cout << "From File!" << std::endl;
        // convert number of nodes to a string
        std::string node = std::to_string(num_of_nodes);

        // read in the topology from BRITE file
        gr = b_topology->Populate_Topology_Result("../data/" + node +".brite");
    }

    std::cout << "Finished Generating" << std::endl;


    // get the number of vertices
    int numVertices = gr->numberOfVertex();


    // if no ingress nodes then generate a random amount (1 to 10)
    if (ingr_node_counter == 0) 
        {
            ingr_node_counter = RANDOM_GENERATOR(generator6);
        }

    // create memory for the results
    int ** gpuCost = new int * [ingr_node_counter];
    int ** sequentialCost = new int * [ingr_node_counter];
    int ** oldSequentialCost = new int * [ingr_node_counter];
    int ** multipleGPUResult = new int * [ingr_node_counter];
    
    for(int i = 0; i < ingr_node_counter; i++)
    {
        gpuCost[i] = new int[numVertices];
        sequentialCost[i] = new int[numVertices];
        oldSequentialCost[i] = new int[numVertices];
        multipleGPUResult[i] = new int[numVertices];
    }

    int * source = new int [ingr_node_counter];

    std::cout << std::endl << "Running Sequential Algorithm..." << std::endl;

    // loop for all ingress nodes
    for (int i = 0; i < ingr_node_counter; i++) 
    {
        source[i] = random_ingress_node_selector(*gr);
        hostElapsedTime += processGraphSequential(gr, source[i], sequentialCost[i]);
    }

    //totalOldBFSSequential += oldHostElapsedTime;
    totalNewBFSSequential += hostElapsedTime;

    std::cout << "Finished Sequential" << std::endl;

    // print the CPU results to a file and the screen
    std::cout << ID_ << ", CPU Execution time (sec),                   " << hostElapsedTime << ", Num Vertices, " << numVertices << ", Num Ingress, " << ingr_node_counter  << std::endl; 
    timingFile << ID_ << ", CPU Execution time (sec),                  " << hostElapsedTime << ", Num Vertices, " << numVertices << ", Num Ingress, " << ingr_node_counter  << std::endl; 






    std::cout << std::endl << "Running Single GPU Algorithm..." << std::endl;
    totalSingleGPU += singleDeviceElapsedTime = processGraphSingleGPU(gr, source, ingr_node_counter, gpuCost);     
    std::cout << "Finished Single GPU" << std::endl;

    // print the Single GPU results to a file and the screen
    std::cout << ID_ << ", CUDA Single Device Execution time (sec),    " << singleDeviceElapsedTime << ", Num Vertices, " << numVertices << ", Num Ingress, " << ingr_node_counter  << std::endl;
    timingFile << ID_ << ", CUDA Single Device Execution time (sec),   " << singleDeviceElapsedTime << ", Num Vertices, " << numVertices << ", Num Ingress, " << ingr_node_counter  << std::endl; 






    // CALL MULTI-GPU FUNCTION HERE!!!!
    std::cout << std::endl << "Running Multiple GPU Algorithm..." << std::endl;
    int numDevices;
    cudaGetDeviceCount(&numDevices);

    for(int i = 2; i <= numDevices; i++)
    {
        multipleDeviceElapsedTime = processGraphMultipleGPU(gr, source, ingr_node_counter, multipleGPUResult, i);

        std::cout << ID_ << ", CUDA Multiple Device Execution time (sec),  " << multipleDeviceElapsedTime << ", Num GPUs, " << i << ", Num Vertices, " << numVertices << ", Num Ingress, " << ingr_node_counter  << std::endl;
        timingFile << ID_ << ", CUDA Multiple Device Execution time (sec), " << multipleDeviceElapsedTime << ", Num GPUs, " << i << ", Num Vertices, " << numVertices << ", Num Ingress, " << ingr_node_counter  << std::endl;
    }
    std::cout << "Finished Multiple GPU" << std::endl << std::endl;




    std::cout << std::endl << "Verifying Results..." << std::endl;

    // verify results
    if(verifyResults(sequentialCost, gpuCost, multipleGPUResult, numVertices, ingr_node_counter))
        std::cout << "Results Match!!" << std::endl;
    else
        std::cout << "NOT EQUAL!!" << std::endl;

    std::cout << "Finished Verifying" << std::endl;

    // clean up memory   
    for(int i = 0; i < ingr_node_counter; i++)
    {
        delete [] gpuCost[i];
        delete [] sequentialCost[i];
        delete [] oldSequentialCost[i];
        delete [] multipleGPUResult[i];
    }


    // deallocate memory
    delete [] gpuCost;
    delete [] sequentialCost;
    delete [] oldSequentialCost;
    delete [] multipleGPUResult;
    delete [] source;
    delete b_topology;
    delete gr;
        
    std::cout << std::endl << "------------ FINISHED PROCESSING --------------------" << std::endl << std::endl;

}