Exemple #1
0
void CL::loadProgram(const char* relative_path)
{
 // Program Setup
    int pl;
    size_t program_length;
    printf("load the program\n");
    
    //CL_SOURCE_DIR is set in the CMakeLists.txt
    std::string path(CL_SOURCE_DIR);
    path += "/" + std::string(relative_path);
    printf("path: %s\n", path.c_str());

    //file_contents is defined in util.cpp
    //it loads the contents of the file at the given path
    char* cSourceCL = file_contents(path.c_str(), &pl);
    //printf("file: %s\n", cSourceCL);
    program_length = (size_t)pl;

    // create the program
    program = clCreateProgramWithSource(context, 1,
                      (const char **) &cSourceCL, &program_length, &err);
    printf("clCreateProgramWithSource: %s\n", oclErrorString(err));

    buildExecutable();
   
}
void CL::loadProgram(const char* kernel, char* name)
{
 // Program Setup
    kernel_name = name;
    int pl;
    size_t program_length;
    printf("load the program\n");


    program_length = (size_t)(strlen(kernel));
    program = clCreateProgramWithSource(context, 1,
                      (const char **) &kernel, &program_length, &err);
    printf("clCreateProgramWithSource: %s\n", oclErrorString(err));

    buildExecutable();

    //Free buffer returned by file_contents
    //free(cSourceCL);
}