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.
122 lines
3.2 KiB
C++
122 lines
3.2 KiB
C++
//==---- lib_common_utils.hpp ---------------------*- C++ -*----------------==//
|
|
//
|
|
// Copyright (C) Intel Corporation
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef __DPCT_LIB_COMMON_UTILS_HPP__
|
|
#define __DPCT_LIB_COMMON_UTILS_HPP__
|
|
|
|
#include "compat_service.hpp"
|
|
|
|
#if defined(__has_include) && __has_include(<oneapi/math.hpp>)
|
|
#include <oneapi/math.hpp>
|
|
#include <oneapi/mkl/namespace_alias.hpp>
|
|
#elif defined(__has_include) && __has_include(<oneapi/mkl.hpp>)
|
|
#include <oneapi/mkl.hpp>
|
|
#elif defined(__has_include)
|
|
#error "SYCLomatic runtime requires oneMath/oneMKL support"
|
|
#else
|
|
#error "SYCLomatic runtime requires __has_include support"
|
|
#endif
|
|
|
|
namespace dpct {
|
|
|
|
enum class version_field : int { major, minor, update, patch };
|
|
|
|
/// Returns the requested field of Intel(R) oneAPI Math Kernel Library version.
|
|
/// \param field The version information field (major, minor, update or patch).
|
|
/// \param result The result value.
|
|
inline void mkl_get_version(version_field field, int *result) {
|
|
#ifndef __INTEL_MKL__
|
|
throw std::runtime_error("The oneAPI Math Kernel Library (oneMKL) Interfaces "
|
|
"Project does not support this API.");
|
|
#else
|
|
MKLVersion version;
|
|
mkl_get_version(&version);
|
|
if (version_field::major == field) {
|
|
*result = version.MajorVersion;
|
|
} else if (version_field::minor == field) {
|
|
*result = version.MinorVersion;
|
|
} else if (version_field::update == field) {
|
|
*result = version.UpdateVersion;
|
|
} else if (version_field::patch == field) {
|
|
*result = 0;
|
|
} else {
|
|
throw std::runtime_error("unknown field");
|
|
}
|
|
#endif
|
|
}
|
|
|
|
enum class library_data_t : unsigned char {
|
|
real_float = 0,
|
|
complex_float,
|
|
real_double,
|
|
complex_double,
|
|
real_half,
|
|
complex_half,
|
|
real_bfloat16,
|
|
complex_bfloat16,
|
|
real_int4,
|
|
complex_int4,
|
|
real_uint4,
|
|
complex_uint4,
|
|
real_int8,
|
|
complex_int8,
|
|
real_uint8,
|
|
complex_uint8,
|
|
real_int16,
|
|
complex_int16,
|
|
real_uint16,
|
|
complex_uint16,
|
|
real_int32,
|
|
complex_int32,
|
|
real_uint32,
|
|
complex_uint32,
|
|
real_int64,
|
|
complex_int64,
|
|
real_uint64,
|
|
complex_uint64,
|
|
real_int8_4,
|
|
real_int8_32,
|
|
real_uint8_4,
|
|
real_f8_e4m3,
|
|
real_f8_e5m2,
|
|
library_data_t_size
|
|
};
|
|
|
|
enum class compute_type : int {
|
|
f16,
|
|
f16_standard,
|
|
f32,
|
|
f32_standard,
|
|
f32_fast_bf16,
|
|
f32_fast_tf32,
|
|
f64,
|
|
f64_standard,
|
|
i32,
|
|
i32_standard,
|
|
};
|
|
|
|
#ifdef DPCT_USM_LEVEL_NONE
|
|
/// Cast a "rvalue reference to a temporary object" to an "lvalue reference to
|
|
/// that temporary object".
|
|
/// CAUTION:
|
|
/// The returned lvalue reference is available only before the last step in
|
|
/// evaluating the full-expression that contains this function call.
|
|
/// \param [in] temporary_object The rvalue reference to a temporary object.
|
|
/// \returns The lvalue reference to that temporary object.
|
|
template <typename T>
|
|
inline typename std::enable_if_t<std::is_rvalue_reference_v<T &&>, T &>
|
|
rvalue_ref_to_lvalue_ref(T &&temporary_object) {
|
|
return temporary_object;
|
|
}
|
|
#endif
|
|
} // namespace dpct
|
|
|
|
#include "detail/lib_common_utils_detail.hpp"
|
|
|
|
#endif // __DPCT_LIB_COMMON_UTILS_HPP__
|