load_policies.hh
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <type_traits>
5#include <sycl/sycl.hpp>
6
7namespace batchlas::sycl_gemm {
8
9template <typename T>
10inline constexpr bool supports_packet4_v = std::is_same_v<T, float>;
11
12template <typename T, int Width>
13inline constexpr bool supports_packet_v = false;
14
15template <typename T>
17
18template <typename T, int Width>
19inline bool supports_aligned_packet_loads(const T* ptr, int ld, int stride) {
20 if constexpr (!supports_packet_v<T, Width>) {
21 static_cast<void>(ptr);
22 static_cast<void>(ld);
23 static_cast<void>(stride);
24 return false;
25 } else {
26 const auto address = reinterpret_cast<std::uintptr_t>(ptr);
27 return (address % alignof(sycl::vec<T, Width>) == 0) && (ld % Width == 0) && (stride % Width == 0);
28 }
29}
30
31template <typename T, int Width>
32inline sycl::vec<T, Width> packet_load_aligned(const T* ptr, int offset) {
33 return *reinterpret_cast<const sycl::vec<T, Width>*>(ptr + offset);
34}
35
36} // namespace batchlas::sycl_gemm
sycl::vec< T, Width > packet_load_aligned(const T *ptr, int offset)
bool supports_aligned_packet_loads(const T *ptr, int ld, int stride)
constexpr bool supports_packet4_v
constexpr bool supports_packet_v