Skip to content

Commit

Permalink
Various chores (#166)
Browse files Browse the repository at this point in the history
Suppress some spurious warnings using CUTE_INVALID_CONTROL_PATH
Catch some potentially dangerous codepaths with same
Improved ifdefs for CUDA arch specific stuff
Remove an empty example file
  • Loading branch information
joeatodd authored Jan 9, 2025
1 parent 01d4c32 commit 25b7875
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 36 deletions.
12 changes: 10 additions & 2 deletions include/cute/arch/xe_copy_1B.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@
#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_BUILTIN(x) SYCL_EXTERNAL extern "C" x
#else
#define SYCL_DEVICE_BUILTIN(x) inline x { assert(false); }
#define SYCL_DEVICE_BUILTIN(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_OCL(x) SYCL_EXTERNAL x
#else
#define SYCL_DEVICE_OCL(x) inline x { assert(false); }
#define SYCL_DEVICE_OCL(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

using namespace cute;
Expand Down
12 changes: 10 additions & 2 deletions include/cute/arch/xe_copy_2B.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@
#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_BUILTIN(x) SYCL_EXTERNAL extern "C" x
#else
#define SYCL_DEVICE_BUILTIN(x) inline x { assert(false); }
#define SYCL_DEVICE_BUILTIN(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_OCL(x) SYCL_EXTERNAL x
#else
#define SYCL_DEVICE_OCL(x) inline x { assert(false); }
#define SYCL_DEVICE_OCL(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

using namespace cute;
Expand Down
12 changes: 10 additions & 2 deletions include/cute/arch/xe_copy_4B.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@
#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_BUILTIN(x) SYCL_EXTERNAL extern "C" x
#else
#define SYCL_DEVICE_BUILTIN(x) inline x { assert(false); }
#define SYCL_DEVICE_BUILTIN(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_OCL(x) SYCL_EXTERNAL x
#else
#define SYCL_DEVICE_OCL(x) inline x { assert(false); }
#define SYCL_DEVICE_OCL(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

enum class CacheControl {
Expand Down
12 changes: 10 additions & 2 deletions include/cute/arch/xe_copy_8B.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@
#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_BUILTIN(x) SYCL_EXTERNAL extern "C" x
#else
#define SYCL_DEVICE_BUILTIN(x) inline x { assert(false); }
#define SYCL_DEVICE_BUILTIN(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

#ifdef __SYCL_DEVICE_ONLY__
#define SYCL_DEVICE_OCL(x) SYCL_EXTERNAL x
#else
#define SYCL_DEVICE_OCL(x) inline x { assert(false); }
#define SYCL_DEVICE_OCL(x) \
inline x { \
CUTE_INVALID_CONTROL_PATH( \
"Attempting to use a device built-in in host code."); \
}
#endif

using namespace cute;
Expand Down
13 changes: 9 additions & 4 deletions include/cutlass/arch/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#pragma once

#include "cutlass/cutlass.h"
#include "cutlass/platform/platform.h"

////////////////////////////////////////////////////////////////////////////////////////////////////

Expand All @@ -47,20 +48,24 @@ namespace arch {
CUTLASS_DEVICE
int LaneId() {
int ret;
#if !defined(CUTLASS_ENABLE_SYCL) || defined(__SYCL_CUDA_ARCH__)
#if defined(__CUDA_ARCH__) || defined(__SYCL_CUDA_ARCH__)
asm ("mov.u32 %0, %%laneid;" : "=r"(ret) : );
#endif
return ret;
#else
CUTLASS_INVALID_CONTROL_PATH("Attempting to use Nvidia-specific code path on non-Nvidia hardware.");
#endif
}

/// Computes SM number the thread is running on
CUTLASS_DEVICE
int SmId() {
int ret;
#if !defined(CUTLASS_ENABLE_SYCL) || defined(__SYCL_CUDA_ARCH__)
#if defined(__CUDA_ARCH__) || defined(__SYCL_CUDA_ARCH__)
asm ("mov.u32 %0, %%smid;" : "=r"(ret) : );
#endif
return ret;
#else
CUTLASS_INVALID_CONTROL_PATH("Attempting to use Nvidia-specific code path on non-Nvidia hardware.");
#endif
}

#endif
Expand Down
Loading

0 comments on commit 25b7875

Please sign in to comment.