Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Run OpenCL on CI #17

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +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
# 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_${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_${OPENCL_RUNTIME_VER}/x64/libintelocl.so
- name: Run tests
run: go test -race ./...
run: go test -race -test.v=true ./...
34 changes: 34 additions & 0 deletions platform_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}