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.
123 lines
4.0 KiB
C++
123 lines
4.0 KiB
C++
//==---- compat_service.hpp -----------------------*- C++ -*----------------==//
|
|
//
|
|
// Copyright (C) Intel Corporation
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// This file contains some compatibility service APIs which are used by all
|
|
// library utility helper functions. The compatibility service APIs are based on
|
|
// either dpct implementation or syclcompat implementation, which is controlled
|
|
// by the macro USE_DPCT_HELPER.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef __DPCT_COMPAT_SERVICE_HPP__
|
|
#define __DPCT_COMPAT_SERVICE_HPP__
|
|
|
|
namespace dpct {
|
|
namespace cs {
|
|
#if USE_DPCT_HELPER
|
|
namespace ns = ::dpct;
|
|
using memcpy_direction = ::dpct::memcpy_direction;
|
|
template <class... Args> using kernel_name = dpct_kernel_name<Args...>;
|
|
using byte_t = ::dpct::byte_t;
|
|
#else
|
|
namespace ns = ::syclcompat;
|
|
using memcpy_direction = ::syclcompat::detail::memcpy_direction;
|
|
template <class... Args> using kernel_name = syclcompat_kernel_name<Args...>;
|
|
#ifndef __dpct_inline__
|
|
#define __dpct_inline__ __syclcompat_inline__
|
|
#endif
|
|
using byte_t = ::syclcompat::byte_t;
|
|
#endif
|
|
|
|
using ns::get_current_device;
|
|
using ns::get_default_context;
|
|
using ns::queue_ptr;
|
|
|
|
namespace detail {
|
|
using ns::detail::get_pointer_attribute;
|
|
using ns::detail::pointer_access_attribute;
|
|
} // namespace detail
|
|
|
|
inline sycl::queue &get_default_queue() {
|
|
#if USE_DPCT_HELPER
|
|
return ::dpct::get_default_queue();
|
|
#else
|
|
return *::syclcompat::detail::dev_mgr::instance()
|
|
.current_device()
|
|
.default_queue();
|
|
#endif
|
|
}
|
|
|
|
inline sycl::event
|
|
memcpy(sycl::queue &q, void *to_ptr, const void *from_ptr, size_t size,
|
|
memcpy_direction direction = memcpy_direction::automatic,
|
|
const std::vector<sycl::event> &dep_events = {}) {
|
|
#if USE_DPCT_HELPER
|
|
return ::dpct::detail::dpct_memcpy(q, to_ptr, from_ptr, size, direction,
|
|
dep_events);
|
|
#else
|
|
return ::syclcompat::detail::memcpy(q, to_ptr, from_ptr, size, dep_events);
|
|
#endif
|
|
}
|
|
|
|
inline std::vector<sycl::event>
|
|
memcpy(sycl::queue &q, void *to_ptr, const void *from_ptr, size_t to_pitch,
|
|
size_t from_pitch, size_t x, size_t y,
|
|
memcpy_direction direction = memcpy_direction::automatic,
|
|
const std::vector<sycl::event> &dep_events = {}) {
|
|
#if USE_DPCT_HELPER
|
|
return ::dpct::detail::dpct_memcpy(
|
|
q, to_ptr, from_ptr, sycl::range<3>(to_pitch, y, 1),
|
|
sycl::range<3>(from_pitch, y, 1), sycl::id<3>(0, 0, 0),
|
|
sycl::id<3>(0, 0, 0), sycl::range<3>(x, y, 1), direction, dep_events);
|
|
#else
|
|
return ::syclcompat::detail::memcpy(
|
|
q, to_ptr, from_ptr, sycl::range<3>(to_pitch, y, 1),
|
|
sycl::range<3>(from_pitch, y, 1), sycl::id<3>(0, 0, 0),
|
|
sycl::id<3>(0, 0, 0), sycl::range<3>(x, y, 1), dep_events);
|
|
#endif
|
|
}
|
|
|
|
inline void *malloc(size_t size, sycl::queue q = get_default_queue()) {
|
|
#if USE_DPCT_HELPER
|
|
return ::dpct::dpct_malloc(size, q);
|
|
#else
|
|
return ::syclcompat::malloc(size, q);
|
|
#endif
|
|
}
|
|
|
|
template <typename valueT>
|
|
inline sycl::event fill(sycl::queue &q, void *dev_ptr, valueT value,
|
|
size_t size) {
|
|
#if USE_DPCT_HELPER
|
|
return ::dpct::detail::dpct_memset<valueT>(q, dev_ptr, value, size);
|
|
#else
|
|
return ::syclcompat::detail::fill<valueT>(q, dev_ptr, value, size);
|
|
#endif
|
|
}
|
|
|
|
inline void free(void *to_ptr, sycl::queue q) {
|
|
#if USE_DPCT_HELPER
|
|
return ::dpct::detail::dpct_free(to_ptr, q);
|
|
#else
|
|
return ::syclcompat::free(to_ptr, q);
|
|
#endif
|
|
}
|
|
|
|
inline sycl::event enqueue_free(const std::vector<void *> &pointers,
|
|
const std::vector<sycl::event> &events,
|
|
sycl::queue q = get_default_queue()) {
|
|
#if USE_DPCT_HELPER
|
|
return ::dpct::detail::async_dpct_free(pointers, events, q);
|
|
#else
|
|
return ::syclcompat::enqueue_free(pointers, events, q);
|
|
#endif
|
|
}
|
|
|
|
} // namespace cs
|
|
} // namespace dpct
|
|
|
|
#endif // __DPCT_COMPAT_SERVICE_HPP__
|