SEXP getDeviceIDs(SEXP sPlatformID){
    resetError("ROpenCL::getDeviceIDs");
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);

    cl_uint num_GPUs = 0;
    logError( clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_GPU, 0, 0, &num_GPUs) );
    std::vector<cl_device_id> gpus(num_GPUs);
    logError( clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_GPU, num_GPUs, gpus.empty() ? NULL : &gpus.front(), &num_GPUs) );

    cl_uint num_nonGPUs = 0;
    logError( clGetDeviceIDs(*platformID, ~CL_DEVICE_TYPE_GPU, 0, 0, &num_nonGPUs) );
    std::vector<cl_device_id> devices(num_nonGPUs);
    logError( clGetDeviceIDs(*platformID, ~CL_DEVICE_TYPE_GPU, num_nonGPUs, devices.empty() ? NULL : &devices.front(), &num_nonGPUs) );

    //for each device in devices add its pointer to the return list
    Rcpp::List result(gpus.size() + devices.size());
    //To be more compatible with the previous version of this function, put GPUs first in the result list.
    for (int i=0; i<gpus.size(); i++){
        cl_device_id *tempDeviceID = new cl_device_id;
        *tempDeviceID = gpus[i];
        Rcpp::XPtr<cl_device_id> tempXPtr(tempDeviceID);
        result[i] = tempXPtr;
    }
    for (int i=0; i<devices.size(); i++){
        cl_device_id *tempDeviceID = new cl_device_id;
        *tempDeviceID = devices[i];
        Rcpp::XPtr<cl_device_id> tempXPtr(tempDeviceID);
        result[i+gpus.size()] = tempXPtr;
    }
    PRINTONERROR();
    return result;
}
Example #2
0
SEXP getPlatformName(SEXP sPlatformID){
    char cBuffer[1024];
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);
    clGetPlatformInfo (*platformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL);
    std::string retVal = cBuffer;
    return Rcpp::wrap(retVal);
}
Example #3
0
    void Platform::getInfo(cl_platform_info paramName, size_t paramValueSize, void *paramValue) const
    {
        cl_int err = 0;

        err = clGetPlatformInfo(platformID(), paramName, paramValueSize, paramValue, nullptr);

        if(err != CL_SUCCESS) {
            throw OpenCLException(err);
        }
    }
SEXP getPlatformName(SEXP sPlatformID){
    resetError("ROpenCL::getPlatformName");
    char cBuffer[1024];
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL) );
    std::string retVal = cBuffer;
    PRINTONERROR();
    return Rcpp::wrap(retVal);
}
Example #5
0
    Epic::Core::Array<Device> Platform::devices(cl_device_type deviceType) const
    {
        Epic::Core::Array<Device> ret;
        cl_uint numDevices = 0;

        clGetDeviceIDs(platformID(), deviceType, 0, nullptr, &numDevices);

        if(numDevices > 0) {
            cl_device_id *devices = new cl_device_id[numDevices];
            int err = clGetDeviceIDs(platformID(), deviceType, numDevices, devices, nullptr);

            if(err != CL_SUCCESS) {
                throw OpenCLException(err);
            }

            ret = deviceIDToDeviceHelper(devices, numDevices);

            delete [] devices;
        }

        return ret;
    }
Example #6
0
    size_t Platform::getInfoSize(cl_platform_info paramName) const
    {
        size_t ret;
        cl_int err = 0;

        err = clGetPlatformInfo(platformID(), paramName, 0, nullptr, &ret);

        if(err != CL_SUCCESS) {
            throw OpenCLException(err);
        }

        return ret;
    }
Example #7
0
SEXP getDeviceIDs(SEXP sPlatformID){
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);
    cl_uint num_devices = 0;
    clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_GPU, 0, 0, &num_devices);
    std::vector<cl_device_id> devices(num_devices);
    clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_GPU, num_devices, devices.empty() ? NULL : &devices.front(), &num_devices);
    //for each platform in platforms add its pointer to the return list
    Rcpp::List result(devices.size());
    for (int i=0; i<devices.size(); i++){
        cl_device_id *tempDeviceID = new cl_device_id;
        *tempDeviceID = devices[i];
        Rcpp::XPtr<cl_device_id> tempXPtr(tempDeviceID);
        result[i] = tempXPtr;
    }
    return result;
}
SEXP getPlatformInfo(SEXP sPlatformID){
    resetError("ROpenCL::getPlatformInfo");
    static char cBuffer[1024];
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);
    std::string str;
    Rcpp::List result;
    
#ifdef CL_PLATFORM_PROFILE /* TODO CHECK THIS IS STRING RETURN VALUE */
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_PROFILE, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_PROFILE"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_VERSION
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_VERSION, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_VERSION"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_NAME
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo (*platformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_NAME"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_VENDOR
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_VENDOR, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_VENDOR"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_EXTENSIONS
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_EXTENSIONS, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    std::string word;
    std::stringstream ss(str); // Insert the string into a stream
    Rcpp::List extensions;
    while (ss >> word) { // Fetch next word from stream
        extensions.push_back(Rcpp::wrap(word));
    }
    result["CL_PLATFORM_EXTENSIONS"] = Rcpp::wrap(extensions);
#endif

    PRINTONERROR();
    return result;
}