Files
strata/sycl/include/dpct/dpct.hpp
T
maxfridbe a1c47bc90b sycl: the CUDA engine migrated to SYCL - builds with oneAPI, 19 of 22 kernel parity tests pass on the Arc Pro B70
The port lives in sycl/ and changes no upstream file: sycl/src and sycl/include hold only the files the
migration touched, sycl/CMakeLists.txt takes everything else from the original tree.

How it was made, reproducibly (sycl/tools/): a dev image (the llama.cpp SYCL image + SYCLomatic 2025.3 +
CUDA 12.8 headers from the pip wheels), migrate.sh (compilation database + dpct over 86 translation
units), fixups.py (every hand fix with its reason, idempotent), build.sh (icpx, ninja).

What dpct got wrong and the script repairs: CUDA's null stream became a null sycl::queue* (strata::q_of
maps it to the default queue); __ldg((const float*) p) lost its cast and read one byte; __fadd_rn lost
parentheses; ggml's lookup tables were threaded through kernel parameters with the wrong table per
template; helper headers renamed since 2025.3; cudaGraphUpload, graph introspection and %globaltimer
have no equivalents. Two compiler flags are load-bearing: -fp-model=precise, and the device compiler's
-cl-fp32-correctly-rounded-divide-sqrt - the Arc's fp32 divide is not correctly rounded by default, and
quantize_act_parity went from 303k mismatches to byte-exact with it.

Not ported: the three kernels with inline PTX (mma.sync, ldmatrix, cp.async) take their existing
pre-sm_80 fallback; the launchers refuse the device. The XMX joint_matrix versions are next.

The engine itself starts on the card, loads the pack, the projections, the PLE table and the 23.4 GiB
expert arena, and is then stopped by the test rig's memory guard: Strata keeps the experts as a resident
host copy, and the rig has 23 GiB of RAM (upstream asks for 32). A streaming fill of the VRAM cache
from the GGUF is the next piece; the whole model fits in the 32 GB card.
2026-09-29 14:06:20 -05:00

107 lines
4.5 KiB
C++

//==---- dpct.hpp ---------------------------------*- C++ -*----------------==//
//
// Copyright (C) Intel Corporation
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//
// clang-format off
/*
There are 3 macros that can be used to control the behavior of the helper
function files.
+========================+=========================+===========================+
| | Helper function files | Helper function files |
| Macro Name | Used in dpct migrated | Used in direct |
| | code | programming |
+========================+=========================+===========================+
| DPCT_USM_LEVEL_NONE | USM by default. | USM by default. |
| (Use USM or SYCL | Use SYCL Buffer by | Define it explicitly to |
| buffer) | running dpct with | use the SYCL buffer. |
| | "--use-level=none". | |
+------------------------+-------------------------+---------------------------+
| DPCT_PROFILING_ENABLED | Enabled heuristically | Disable by default. |
| (Enable SYCL queue | depends on the input | Define it explicitly to |
| profiling) | code. | enable. |
| | Enable explicitly by | |
| | running dpct with | |
| | "--enable-profiling". | |
| | Disable by removing the | |
| | macro definition | |
| | manually. | |
+------------------------+-------------------------+---------------------------+
| DPCT_HELPER_VERBOSE | Disable by default. | Disable by default. |
| (Verbose option) | Define it explicitly to | Define it explicitly to |
| | enable. | enable. |
+========================+=========================+===========================+
*/
// clang-format on
#ifndef __DPCT_HPP__
#define __DPCT_HPP__
#include <sycl/sycl.hpp>
#include <iostream>
#include <limits.h>
#include <math.h>
template <class... Args> class dpct_kernel_name;
template <int Arg> class dpct_kernel_scalar;
#include "atomic.hpp"
#include "device.hpp"
#include "image.hpp"
#include "kernel.hpp"
#include "math.hpp"
#include "memory.hpp"
#include "util.hpp"
#include "bindless_images.hpp"
#include "graph.hpp"
#include "ze_utils.hpp"
#define USE_DPCT_HELPER 1
#if defined(_MSC_VER)
#define __dpct_align__(n) __declspec(align(n))
#define __dpct_inline__ __forceinline
#else
#define __dpct_align__(n) __attribute__((aligned(n)))
#define __dpct_inline__ __inline__ __attribute__((always_inline))
#endif
#if defined(_MSC_VER)
#define __dpct_noinline__ __declspec(noinline)
#else
#define __dpct_noinline__ __attribute__((noinline))
#endif
#define DPCT_COMPATIBILITY_TEMP (900)
namespace dpct {
enum error_code { success = 0, default_error = 999 };
/// A dummy function introduced to assist auto migration.
/// The migration tool user should replace it with a real error-handling function.
/// SYCL reports errors using exceptions and does not use error codes.
inline const char *get_error_string_dummy(int ec) {
(void)ec;
return "<FIXME: Placeholder>"; // Return the error string for the error code
// ec.
}
} // namespace dpct
#define DPCT_CHECK_ERROR(expr) \
[&]() { \
try { \
expr; \
return dpct::success; \
} catch (std::exception const &e) { \
std::cerr << e.what() << std::endl; \
return dpct::default_error; \
} \
}()
#define DPCT_PI_F (3.14159274101257f)
#define DPCT_PI (3.141592653589793115998)
#endif // __DPCT_HPP__