// 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"); handler.run_test(new Jacobi(8, MVType::SimpleMV)); //handler.run_test(new Jacobi(64, MVType::ReduceMV)); //handler.run_test(new Jacobi(64, MVType::LargeMV)); //for (int n = 256; n <= 1024; n = n * 2) { // handler.run_test(new Jacobi(n, MVType::SimpleMV)); // handler.run_test(new Jacobi(n, MVType::LargeMV)); //} 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 g1(GAn, GAm, GA); Gauss g2(GBn, GBm, GB); //handler.run_test(&g1); //handler.run_test(&g2); return 0; }