-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cmake macro to check if f8 is supported
- Loading branch information
Showing
2 changed files
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Define a macro to check for the struct | ||
macro(check_f8 RESULT_VAR) | ||
# Create a temporary source file | ||
file(WRITE ${CMAKE_BINARY_DIR}/CheckF8.cxx | ||
" | ||
#include <hip/hip_fp8.h> | ||
struct __hip_fp8_e5m2 e5m2; | ||
struct __hip_fp8_e4m3 e4m3; | ||
int main() { return 0; } | ||
" | ||
) | ||
|
||
# Try to compile the test program | ||
try_compile(HAS_F8 | ||
${CMAKE_BINARY_DIR} | ||
SOURCES ${CMAKE_BINARY_DIR}/CheckF8.cxx | ||
COMPILE_DEFINITIONS -xhip | ||
) | ||
|
||
# Set the result variable | ||
if(HAS_F8) | ||
set(${RESULT_VAR} TRUE) | ||
else() | ||
set(${RESULT_VAR} FALSE) | ||
endif() | ||
|
||
# Clean up the temporary file (optional but recommended) | ||
file(REMOVE ${CMAKE_BINARY_DIR}/CheckF8.cxx) | ||
endmacro() |