From bf413103d3258340adab0f98c1e98b8734f5696d Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 18 Aug 2022 22:34:07 +0200 Subject: [PATCH 1/5] Add basic test to see if platforms can be loaded --- platform_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 platform_test.go diff --git a/platform_test.go b/platform_test.go new file mode 100644 index 0000000..619ec9d --- /dev/null +++ b/platform_test.go @@ -0,0 +1,34 @@ +package cl30_test + +import ( + "errors" + "testing" + + cl "github.com/opencl-go/cl30" +) + +func allPlatforms(tb testing.TB) []cl.PlatformID { + tb.Helper() + ids, err := cl.PlatformIDs() + if err != nil { + if errors.Is(err, cl.StatusError(-1001)) { + tb.Errorf("failed to query platform IDs: %v", err) + } + return nil + } + return ids +} + +func TestPlatforms(t *testing.T) { + platformIDs := allPlatforms(t) + if len(platformIDs) == 0 { + t.Skipf("no platforms available") + } + for _, platformID := range platformIDs { + name, err := cl.PlatformInfoString(platformID, cl.PlatformNameInfo) + if err != nil { + t.Logf("failed to query name of platform: %v", err) + } + t.Logf("Platform <%s>\n", name) + } +} From 7864c75392724db5d15bdcb9a3c61d776b8d528a Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 18 Aug 2022 22:35:04 +0200 Subject: [PATCH 2/5] Install Intel OpenCL Runtime for CPU --- .github/workflows/test.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32e2fae..86ef1ac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,5 +21,18 @@ jobs: run: | sudo apt-get update sudo apt-get install -y opencl-headers ocl-icd-opencl-dev + wget --quiet https://github.com/intel/llvm/releases/download/2022-WW33/oclcpuexp-2022.14.8.0.04_rel.tar.gz --output-document=/tmp/oclcpuexp-2022.14.8.0.04_rel.tar.gz + wget --quiet https://github.com/oneapi-src/oneTBB/releases/download/v2021.5.0/oneapi-tbb-2021.5.0-lin.tgz --output-document=/tmp/oneapi-tbb-2021.5.0-lin.tgz + sudo mkdir --parents /opt/intel/oclcpuexp_2022.14.8.0.04 + sudo tar -zxvf /tmp/intel-llvm/oclcpuexp-2022.14.8.0.04_rel.tar.gz -C /opt/intel/oclcpuexp_2022.14.8.0.04 + sudo tar -zxvf /tmp/oneapi-tbb-2021.5.0-lin.tgz -C /opt/intel + echo /opt/intel/oclcpuexp_2022.14.8.0.04/x64/libintelocl.so | sudo tee -a /etc/OpenCL/vendors/intel_expcpu.icd + sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ + sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbbmalloc.so /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ + sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbb.so.12 /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ + sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbbmalloc.so.2 /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ + echo /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ | sudo tee -a /etc/ld.so.conf.d/libintelopenclexp.conf + sudo ldconfig -f /etc/ld.so.conf.d/libintelopenclexp.conf + ldd /opt/intel/oclcpuexp_2022.14.8.0.04/x64/libintelocl.so - name: Run tests - run: go test -race ./... + run: go test -race -test.v=true ./... From d484434dc2bd6443465f53e9020bc31cc86fb990 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 18 Aug 2022 22:37:14 +0200 Subject: [PATCH 3/5] Fix path in install script --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86ef1ac..13d2d45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: wget --quiet https://github.com/intel/llvm/releases/download/2022-WW33/oclcpuexp-2022.14.8.0.04_rel.tar.gz --output-document=/tmp/oclcpuexp-2022.14.8.0.04_rel.tar.gz wget --quiet https://github.com/oneapi-src/oneTBB/releases/download/v2021.5.0/oneapi-tbb-2021.5.0-lin.tgz --output-document=/tmp/oneapi-tbb-2021.5.0-lin.tgz sudo mkdir --parents /opt/intel/oclcpuexp_2022.14.8.0.04 - sudo tar -zxvf /tmp/intel-llvm/oclcpuexp-2022.14.8.0.04_rel.tar.gz -C /opt/intel/oclcpuexp_2022.14.8.0.04 + sudo tar -zxvf /tmp/oclcpuexp-2022.14.8.0.04_rel.tar.gz -C /opt/intel/oclcpuexp_2022.14.8.0.04 sudo tar -zxvf /tmp/oneapi-tbb-2021.5.0-lin.tgz -C /opt/intel echo /opt/intel/oclcpuexp_2022.14.8.0.04/x64/libintelocl.so | sudo tee -a /etc/OpenCL/vendors/intel_expcpu.icd sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ From e6d64d7ca4d0c53f50215f5d2f5c18d4990d2cee Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 18 Aug 2022 22:39:24 +0200 Subject: [PATCH 4/5] Ensure OpenCL vendors directory is existing --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13d2d45..2206585 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,7 @@ jobs: sudo mkdir --parents /opt/intel/oclcpuexp_2022.14.8.0.04 sudo tar -zxvf /tmp/oclcpuexp-2022.14.8.0.04_rel.tar.gz -C /opt/intel/oclcpuexp_2022.14.8.0.04 sudo tar -zxvf /tmp/oneapi-tbb-2021.5.0-lin.tgz -C /opt/intel + sudo mkdir --parents /etc/OpenCL/vendors echo /opt/intel/oclcpuexp_2022.14.8.0.04/x64/libintelocl.so | sudo tee -a /etc/OpenCL/vendors/intel_expcpu.icd sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbbmalloc.so /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ From c1090160556f11691358007d641be4fd8a9e4e42 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 18 Aug 2022 22:59:40 +0200 Subject: [PATCH 5/5] Extract variables to remove duplication of version numbers --- .github/workflows/test.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2206585..2daa29f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,22 +18,27 @@ jobs: go-version: 1.18 - uses: actions/checkout@v3 - name: Install libraries + env: + OPENCL_RUNTIME_VER: 2022.14.8.0.04 + INTEL_TBB_VER: 2021.5.0 run: | sudo apt-get update sudo apt-get install -y opencl-headers ocl-icd-opencl-dev - wget --quiet https://github.com/intel/llvm/releases/download/2022-WW33/oclcpuexp-2022.14.8.0.04_rel.tar.gz --output-document=/tmp/oclcpuexp-2022.14.8.0.04_rel.tar.gz - wget --quiet https://github.com/oneapi-src/oneTBB/releases/download/v2021.5.0/oneapi-tbb-2021.5.0-lin.tgz --output-document=/tmp/oneapi-tbb-2021.5.0-lin.tgz - sudo mkdir --parents /opt/intel/oclcpuexp_2022.14.8.0.04 - sudo tar -zxvf /tmp/oclcpuexp-2022.14.8.0.04_rel.tar.gz -C /opt/intel/oclcpuexp_2022.14.8.0.04 - sudo tar -zxvf /tmp/oneapi-tbb-2021.5.0-lin.tgz -C /opt/intel + # The following is the installation procedure of the Intel OpenCL CPU runtime as per + # https://github.com/intel/llvm/blob/sycl/sycl/doc/GetStartedGuide.md#install-low-level-runtime + wget --quiet https://github.com/intel/llvm/releases/download/2022-WW33/oclcpuexp-${OPENCL_RUNTIME_VER}_rel.tar.gz --output-document=/tmp/oclcpuexp-${OPENCL_RUNTIME_VER}_rel.tar.gz + wget --quiet https://github.com/oneapi-src/oneTBB/releases/download/v${INTEL_TBB_VER}/oneapi-tbb-${INTEL_TBB_VER}-lin.tgz --output-document=/tmp/oneapi-tbb-${INTEL_TBB_VER}-lin.tgz + sudo mkdir --parents /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER} + sudo tar -zxvf /tmp/oclcpuexp-${OPENCL_RUNTIME_VER}_rel.tar.gz -C /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER} + sudo tar -zxvf /tmp/oneapi-tbb-${INTEL_TBB_VER}-lin.tgz -C /opt/intel sudo mkdir --parents /etc/OpenCL/vendors - echo /opt/intel/oclcpuexp_2022.14.8.0.04/x64/libintelocl.so | sudo tee -a /etc/OpenCL/vendors/intel_expcpu.icd - sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ - sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbbmalloc.so /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ - sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbb.so.12 /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ - sudo ln -s /opt/intel/oneapi-tbb-2021.5.0/lib/intel64/gcc4.8/libtbbmalloc.so.2 /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ - echo /opt/intel/oclcpuexp_2022.14.8.0.04/x64/ | sudo tee -a /etc/ld.so.conf.d/libintelopenclexp.conf + echo /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER}/x64/libintelocl.so | sudo tee -a /etc/OpenCL/vendors/intel_expcpu.icd + sudo ln -s /opt/intel/oneapi-tbb-${INTEL_TBB_VER}/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER}/x64/ + sudo ln -s /opt/intel/oneapi-tbb-${INTEL_TBB_VER}/lib/intel64/gcc4.8/libtbbmalloc.so /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER}/x64/ + sudo ln -s /opt/intel/oneapi-tbb-${INTEL_TBB_VER}/lib/intel64/gcc4.8/libtbb.so.12 /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER}/x64/ + sudo ln -s /opt/intel/oneapi-tbb-${INTEL_TBB_VER}/lib/intel64/gcc4.8/libtbbmalloc.so.2 /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER}/x64/ + echo /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER}/x64/ | sudo tee -a /etc/ld.so.conf.d/libintelopenclexp.conf sudo ldconfig -f /etc/ld.so.conf.d/libintelopenclexp.conf - ldd /opt/intel/oclcpuexp_2022.14.8.0.04/x64/libintelocl.so + ldd /opt/intel/oclcpuexp_${OPENCL_RUNTIME_VER}/x64/libintelocl.so - name: Run tests run: go test -race -test.v=true ./...