Example #1
0
bool OclHost::testAllocate(unsigned long size) {
    //cl_ulong const maxBlockSize = (getDeviceInfoLong(CL_DEVICE_GLOBAL_MEM_SIZE) / 1024 * 1000) / (unsigned long)(Config.GetInt("cpu_threads") * 8);
    //std::cout << "MaxBlockSize: " << maxBlockSize << std::endl;
    //if(size < maxBlockSize) {
    cl_ulong gMem = (getDeviceInfoLong(CL_DEVICE_GLOBAL_MEM_SIZE)) * 0.45;
    if (platform == AMD) {
        return size < (getDeviceInfoLong(CL_DEVICE_MAX_MEM_ALLOC_SIZE))
               && (size * (unsigned long) Config.GetInt("cpu_threads")) < gMem;
    }

    if ((size * (unsigned long) Config.GetInt("cpu_threads")) < gMem) {
        cl_int errCode = 0;

        //return true;
        cl_mem mem = clCreateBuffer(oclGpuContext, 0, size, 0, &errCode);
        if (mem != 0 && errCode == CL_SUCCESS) {
            clReleaseMemObject(mem);
            //		delete[] test;
            //		test = 0;
            return true;
        } else {
            return false;
        }
    }
    //}
    return false;
}
Example #2
0
int OclHost::getThreadPerMulti() {
    if (isGPU()) {
#ifdef __APPLE__
        int id = 20;
#else
        cl_uint revision = getDeviceInfoInt(
                               CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV);

        int id = 10 * revision
                 + getDeviceInfoLong(CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV);
#endif
        switch (id) {
        case 10:
            return 768;
        case 11:
            return 768;
        case 12:
            return 1024;
        case 13:
            return 1024;
        case 20:
            return 1536;
        case 21:
            return 1536;
        default:
            return 1536;
        }
    } else {
        return 256;
    }

}
Example #3
0
bool OclHost::checkGlobalMemory(size_t const size) {
    return true;
    return (size
            < ((maxGlobalMem != 0) ? maxGlobalMem : (maxGlobalMem =
                        getDeviceInfoLong(
                            CL_DEVICE_MAX_MEM_ALLOC_SIZE))));
}
Example #4
0
    void DeviceInfo::populate( cl_platform_id platformId, cl_device_id deviceId ) {
//        this->platformId = platformId;
        platformVendor = getPlatformInfoString( platformId, CL_PLATFORM_VENDOR );
        platformName = getPlatformInfoString( platformId, CL_PLATFORM_NAME );
//        this->deviceId = deviceId;
        deviceType = getDeviceInfoInt( deviceId, CL_DEVICE_TYPE );
        globalMemSize = getDeviceInfoLong( deviceId, CL_DEVICE_GLOBAL_MEM_SIZE );
        localMemSize = getDeviceInfoInt( deviceId, CL_DEVICE_LOCAL_MEM_SIZE );
        globalMemCachelineSize = getDeviceInfoInt( deviceId, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE );
        maxMemAllocSize = getDeviceInfoLong( deviceId, CL_DEVICE_MAX_MEM_ALLOC_SIZE );
        maxComputeUnits = getDeviceInfoInt( deviceId, CL_DEVICE_MAX_COMPUTE_UNITS );
        maxWorkGroupSize = getDeviceInfoInt( deviceId, CL_DEVICE_MAX_WORK_GROUP_SIZE );
        maxWorkItemDimensions = getDeviceInfoInt( deviceId, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS );
    //    maxWorkItemSizes = getDeviceInfoInt( deviceId, CL_MAX_WORK_ITEM_SIZES );
        deviceName = getDeviceInfoString( deviceId, CL_DEVICE_NAME );
        openClCVersion = getDeviceInfoString( deviceId, CL_DEVICE_OPENCL_C_VERSION );
        deviceVersion = getDeviceInfoString( deviceId, CL_DEVICE_VERSION );
        maxClockFrequency = getDeviceInfoInt( deviceId, CL_DEVICE_MAX_CLOCK_FREQUENCY );
    }
Example #5
0
bool OclHost::checkLocalMemory(size_t const size) {
    return (size
            < ((maxLocalMem != 0) ?
               maxLocalMem :
               (maxLocalMem = getDeviceInfoLong(CL_DEVICE_LOCAL_MEM_SIZE))));
}