oneMKL icon indicating copy to clipboard operation
oneMKL copied to clipboard

Example code for SYCL generic BLAS and portFFT backends

Open frenchwr opened this issue 4 weeks ago • 0 comments

Hello! I am in the process of creating debian (.deb) packages for oneMath to be included in Ubuntu. I have the DPC++ (open source version) compiler already packaged and also have the SYCL-only backends for oneMath (v0.9) packaged (built with the DPC++ compiler from my own packages).

I looked around for some code samples for testing these two backend libraries but without much luck. Would you be able to suggest some basic examples that I could use for validating the packaging work?

I asked ChatGPT to help and eventually I got the following to compile:

#include <sycl/sycl.hpp>
#include <oneapi/math.hpp>
#include <oneapi/math/blas.hpp>

int main() {
    sycl::queue q{sycl::default_selector_v};

    const int M = 2, N = 2, K = 2;
    std::vector<float> A = {1,2,3,4};
    std::vector<float> B = {5,6,7,8};
    std::vector<float> C(4, 0.0f);

    float alpha = 1.0f;
    float beta  = 0.0f;

    {
        sycl::buffer<float> bufA(A.data(), A.size());
        sycl::buffer<float> bufB(B.data(), B.size());
        sycl::buffer<float> bufC(C.data(), C.size());

        oneapi::math::blas::column_major::gemm(
            q,
            oneapi::math::transpose::nontrans,
            oneapi::math::transpose::nontrans,
            M, N, K,
            alpha,
            bufA, K,
            bufB, N,
            beta,
            bufC, N
        );
    }

    std::cout << "C = \n";
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < N; j++) {
        std::cout << C[i*N + j] << " ";
      }
      std::cout << "\n";
    }
}

This compiled with:

$ clang++-dpcpp -fsycl test_onemath.cpp -lonemath -lonemath_blas_generic

However, when I attempt to run this program on an Intel(R) Arc(TM) B580 Graphics card the program hangs and eventually I kill it with Control+C and get the following output:

$ ./a.out 
^CThe program was built for 1 devices
Build program log for 'Intel(R) Arc(TM) B580 Graphics':
IGC: Internal Compiler Error: Interrupt request sent to the program

C = 
0 0 
0 0 

Any ideas? Is this a limitation of the SYCL-only libraries? Or the hardware I'm on. I'll paste other relevant details below in case they're helpful. Thanks for any light you can shed!

$ sycl-ls 
[level_zero:gpu][level_zero:0] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) Arc(TM) B580 Graphics 20.1.0 [1.6.34666]
[opencl:gpu][opencl:0] Intel(R) OpenCL Graphics, Intel(R) Arc(TM) B580 Graphics OpenCL 3.0 NEO  [25.31.034666]


$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu Resolute Raccoon (development branch)
Release:	26.04
Codename:	resolute



$ apt list --installed | grep -E 'intel|opencl|ocl|igc|libze'

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

intel-microcode/resolute,now 3.20250812.1ubuntu1 amd64 [installed,automatic]
intel-ocloc-dev/resolute,now 25.31.34666.3-1ubuntu1 amd64 [installed]
intel-ocloc-legacy/resolute,now 24.35.30872.40-1 amd64 [installed,automatic]
intel-ocloc/resolute,now 25.31.34666.3-1ubuntu1 amd64 [installed]
intel-opencl-icd-legacy/resolute,now 24.35.30872.40-1 amd64 [installed,automatic]
intel-opencl-icd/resolute,now 25.31.34666.3-1ubuntu1 amd64 [installed,automatic]
libdrm-intel1/resolute,now 2.4.127-1ubuntu1 amd64 [installed,automatic]
libigc1/resolute,now 1.0.17791.18-1 amd64 [installed,automatic]
libigc2/resolute,now 2.16.0-2ubuntu1 amd64 [installed,automatic]
libopencl-clang14/resolute,now 14.0.2-3 amd64 [installed,automatic]
libur-adapter-opencl-dev/resolute,now 6.2.0-0ubuntu1~26.04~ppa5 amd64 [installed]
libur-adapter-opencl0/resolute,now 6.2.0-0ubuntu1~26.04~ppa5 amd64 [installed]
libze-intel-gpu-legacy1-1/resolute,now 24.35.30872.40-1 amd64 [installed,automatic]
libze-intel-gpu1/resolute,now 25.31.34666.3-1ubuntu1 amd64 [installed,automatic]
libze1/resolute,now 1.24.1-2 amd64 [installed,automatic]
ocl-icd-libopencl1/resolute,now 2.3.4-1 amd64 [installed,automatic]
ocl-icd-opencl-dev/resolute,now 2.3.4-1 amd64 [installed]
opencl-c-headers/resolute,now 3.0~2025.07.22-2 all [installed,automatic]
opencl-clhpp-headers/resolute,now 3.0~2025.07.22-1ubuntu1 all [installed,automatic]


$ lscpu | head
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           42 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  32
On-line CPU(s) list:                     0-31
Vendor ID:                               GenuineIntel
Model name:                              13th Gen Intel(R) Core(TM) i9-13900K
CPU family:                              6
Model:                                   183

Note that it seems recent versions of OpenCL dropped support for Gen 13 (raptor lake), hence why I don't see any CPUs show up with sycl-ls.

frenchwr avatar Dec 03 '25 18:12 frenchwr