| 72 | */ |
| 73 | |
| 74 | int main (int argc, char* argv[]) |
| 75 | { |
| 76 | //parse command line |
| 77 | std::string matrix_path; |
| 78 | |
| 79 | if (argc < 2) |
| 80 | { |
| 81 | std::cout << "Not enough parameters. " |
| 82 | << "Please specify path to matrix in mtx format as parameter" |
| 83 | << std::endl; |
| 84 | return -1; |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | matrix_path = std::string(argv[1]); |
| 89 | } |
| 90 | |
| 91 | std::cout << "Executing sample clSPARSE SpMV (y = A*x) C++" << std::endl; |
| 92 | |
| 93 | std::cout << "Matrix will be read from: " << matrix_path << std::endl; |
| 94 | |
| 95 | /** Step 1. Setup OpenCL environment; **/ |
| 96 | |
| 97 | // Init OpenCL environment; |
| 98 | cl_int cl_status; |
| 99 | |
| 100 | // Get OpenCL platforms |
| 101 | std::vector<cl::Platform> platforms; |
| 102 | |
| 103 | cl_status = cl::Platform::get(&platforms); |
| 104 | |
| 105 | if (cl_status != CL_SUCCESS) |
| 106 | { |
| 107 | std::cout << "Problem with getting OpenCL platforms" |
| 108 | << " [" << cl_status << "]" << std::endl; |
| 109 | return -2; |
| 110 | } |
| 111 | |
| 112 | int platform_id = 0; |
| 113 | for (const auto& p : platforms) |
| 114 | { |
| 115 | std::cout << "Platform ID " << platform_id++ << " : " |
| 116 | << p.getInfo<CL_PLATFORM_NAME>() << std::endl; |
| 117 | |
| 118 | } |
| 119 | |
| 120 | // Using first platform |
| 121 | platform_id = 0; |
| 122 | cl::Platform platform = platforms[platform_id]; |
| 123 | |
| 124 | // Get device from platform |
| 125 | std::vector<cl::Device> devices; |
| 126 | cl_status = platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); |
| 127 | |
| 128 | if (cl_status != CL_SUCCESS) |
| 129 | { |
| 130 | std::cout << "Problem with getting devices from platform" |
| 131 | << " [" << platform_id << "] " << platform.getInfo<CL_PLATFORM_NAME>() |
nothing calls this directly
no test coverage detected