// Primitives.cpp : Defines the entry point for the console application. #include #include #include "Common.h" // OpenCL C API #include // OpenCL C++ API #include "cl.hpp" #include #include #include "LinearTests.h" void capi() { // Get a platform ID cl_platform_id platformID; clGetPlatformIDs(1, &platformID, NULL); // Get a device ID cl_device_id deviceID; clGetDeviceIDs(platformID, CL_DEVICE_TYPE_GPU, 1, &deviceID, NULL); // Create a context cl_context context; cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platformID, 0 }; context = clCreateContext(contextProperties, 1, &deviceID, NULL, NULL, NULL); // Create a command queue cl_command_queue queue; queue = clCreateCommandQueue(context, deviceID, CL_QUEUE_PROFILING_ENABLE, NULL); // Create an OpenCL program std::string source = FileToString("../kernels/linear.cl"); const char* csource = source.c_str(); cl_program program = clCreateProgramWithSource(context, 1, &csource, NULL, NULL); cl_int err = clBuildProgram(program, 1, &deviceID, NULL, NULL, NULL); if (err != CL_SUCCESS) { cl_uint logLength; clGetProgramBuildInfo(program, deviceID, CL_PROGRAM_BUILD_LOG, 0, NULL, &logLength); char* log = new char[logLength]; clGetProgramBuildInfo(program, deviceID, CL_PROGRAM_BUILD_LOG, logLength, log, 0); std::cout << log << std::endl; delete[] log; exit(-1); } } int main() { capi(); //cppapi(); OpenCLHandler handler("../kernels/linear.cl"); //Jacobi j(MVType::ReduceMV); //Jacobi j(MVType::SimpleMV); //Jacobi j(MVType::LargeMV); //handler.run_test(&j); int GAn = 4; int GAm = 3; float GA[] = { 2, 1, -1, 8, -3, -1, 2, -11, -2, 1, 2, -3 }; int GBn = 6; int GBm = 3; float GB[] = { 2, -1, 0, 1, 0, 0, -1, 2, -1, 0, 1, 0, 0, -1, 2, 0, 0, 1 }; Gauss g(GBn, GBm, GB); handler.run_test(&g); return 0; }