-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (100 loc) · 3.99 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# =============================================================================
# CMake build system files
#
# Copyright (c) 2021-24 chipStar developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# =============================================================================
cmake_minimum_required(VERSION 3.20)
# Check if INTEL_COMPILER_PATH was passed to CMake invocation, if not, look for icpx in PATH
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
find_program(INTEL_COMPILER_PATH icpx)
if(INTEL_COMPILER_PATH)
set(CMAKE_CXX_COMPILER ${INTEL_COMPILER_PATH})
set(CMAKE_CXX_COMPILER_ID "IntelLLVM")
message(STATUS "Found Intel C++ Compiler: ${INTEL_COMPILER_PATH}")
else()
message(WARNING "Intel C++ Compiler (icpx) not found. Using default compiler.")
endif()
endif()
# Must be after setting CMAKE_CXX_COMPILER to intel otherwise it will go into an infinite loop
project(hipFFT
VERSION 1.0.0
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(STANDALONE_BUILD ON)
else()
set(STANDALONE_BUILD OFF)
endif()
# set the default CMAKE_INSTALL_PREFIX to the current directory/install
if(STANDALONE_BUILD AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/install" CACHE PATH "..." FORCE)
endif()
# print where the library will be installed
message(STATUS "hipFFT will be installed to: ${CMAKE_INSTALL_PREFIX}")
# Select SPIR-V platform
add_compile_definitions(__HIP_PLATFORM_SPIRV__)
# Find HIP
if(STANDALONE_BUILD)
# Build H4I-MKLShim from submodule first
add_subdirectory(H4I-MKLShim REQUIRED)
# Find hip package, but exclude its H4I-MKLShim
set(CMAKE_IGNORE_PATH ${CMAKE_IGNORE_PATH} ${hip_DIR}/../H4I-MKLShim)
find_package(hip CONFIG REQUIRED)
# Explicitly set the path to our built H4I-MKLShim
set(H4I_MKLShim_DIR ${CMAKE_CURRENT_BINARY_DIR}/H4I-MKLShim)
endif()
# Create the hipFFT library
add_library(hipfft SHARED
src/hipfft.cpp
)
# Link against MKL and other required libraries
target_link_libraries(hipfft
PUBLIC
CHIP
MKLShim
PRIVATE
MKL::MKL
)
# Set properties for the hipfft target
set_target_properties(hipfft PROPERTIES
OUTPUT_NAME "hipfft"
POSITION_INDEPENDENT_CODE ON
)
# Modify the hipfft target to use Intel's SYCL flag
target_compile_options(hipfft PRIVATE -fsycl)
target_link_options(hipfft PRIVATE -fsycl)
# Add the directory containing hipfftHandle.h to the include directories
target_include_directories(hipfft PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Installation rules
install(TARGETS hipfft
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
include(CTest)
add_subdirectory(tests)