Skip to content
Hüseyin Tuğrul BÜYÜKIŞIK edited this page May 20, 2023 · 2 revisions

Welcome to the libGPGPU wiki!

Selecting OpenCL Version to Filter Platforms & Devices

Only a define macro before including gpgpu.hpp is enough to select all devices with a minimum OpenCL version.

OpenCL 1.2+:

#include "gpgpu.hpp"
int main()
{
        GPGPU::Computer computer(GPGPU::Computer::DEVICE_ALL);
        
        auto deviceNames = computer.deviceNames();
        for (auto d : deviceNames)
        {
            std::cout << d << std::endl;
        }
        return 0;
}

result:

GeForce GT 1030 (OpenCL 1.2 CUDA )
gfx1036 (OpenCL 2.0 AMD-APP (3444.0) )[direct access to RAM]
AMD Ryzen 9 7900 12-Core Processor              (OpenCL 3.0 (Build 0) )[direct access to RAM]

OpenCL 2.0+:

#define CL_HPP_MINIMUM_OPENCL_VERSION 200
#include "gpgpu.hpp"
int main()
{
        GPGPU::Computer computer(GPGPU::Computer::DEVICE_ALL);
        
        auto deviceNames = computer.deviceNames();
        for (auto d : deviceNames)
        {
            std::cout << d << std::endl;
        }
        return 0;
}

result:

gfx1036 (OpenCL 2.0 AMD-APP (3444.0) )[direct access to RAM]
AMD Ryzen 9 7900 12-Core Processor              (OpenCL 3.0 (Build 0) )[direct access to RAM]

OpenCL 3.0+:

#define CL_HPP_MINIMUM_OPENCL_VERSION 300
#include "gpgpu.hpp"
int main()
{
        GPGPU::Computer computer(GPGPU::Computer::DEVICE_ALL);
        
        auto deviceNames = computer.deviceNames();
        for (auto d : deviceNames)
        {
            std::cout << d << std::endl;
        }
        return 0;
}

result:

AMD Ryzen 9 7900 12-Core Processor              (OpenCL 3.0 (Build 0) )[direct access to RAM]