clblasFunc(StatisticalTimer& _timer, cl_device_type devType) : timer(_timer) { cl_int err; /* Setup OpenCL environment. */ OPENCL_V_THROW(clGetPlatformIDs(1, &platform_, NULL), "getting platform IDs"); OPENCL_V_THROW(clGetDeviceIDs(platform_, devType, 1, &device_, NULL), "getting device IDs"); props_[0] = CL_CONTEXT_PLATFORM; props_[1] = (cl_context_properties)platform_; props_[2] = 0; ctx_ = clCreateContext(props_, 1, &device_, NULL, NULL, &err); OPENCL_V_THROW(err, "creating context"); queue_ = clCreateCommandQueue(ctx_, device_, 0, &err); timer_id = timer.getUniqueID( "clfunc", 0 ); maxMemAllocSize = queryMemAllocSize( device_ ); /* Setup clblas. */ err = clblasSetup(); if (err != CL_SUCCESS) { std::cerr << "clblasSetup() failed with %d\n"; clReleaseCommandQueue(queue_); clReleaseContext(ctx_); } }
clsparseFunc( cl_device_type devType, cl_command_queue_properties cqProp ): cqProperties( cqProp ) { cl_int err; // Setup OpenCL environment CLSPARSE_V( ::clGetPlatformIDs( 1, &platform, NULL ), "getting platform IDs" ); CLSPARSE_V( ::clGetDeviceIDs( platform, devType, 1, &device, NULL ), "getting device IDs" ); { char buffer [1024]; clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(buffer), buffer, NULL); std::cout << "DEVICE NAME " << buffer << std::endl; } props[ 0 ] = CL_CONTEXT_PLATFORM; props[ 1 ] = (cl_context_properties)platform; props[ 2 ] = 0; ctx = ::clCreateContext( props, 1, &device, NULL, NULL, &err ); CLSPARSE_V( err, "creating context" ); queue = ::clCreateCommandQueue( ctx, device, cqProp, &err ); CLSPARSE_V( err, "clCreateCommandQueue" ); maxMemAllocSize = queryMemAllocSize( device ); // Setup clsparse if( clsparseSetup( ) != clsparseSuccess ) { std::cerr << "clsparseSetup() failed with %d\n"; CLSPARSE_V( ::clReleaseCommandQueue( queue ), "releasing command queue" ); CLSPARSE_V( ::clReleaseContext( ctx ), "releasing context" ); } clsparseCreateResult createResult = clsparseCreateControl( queue ); control = ( createResult.status == clsparseSuccess ) ? createResult.control : nullptr; }