1
- cmake_minimum_required ( VERSION 3.10 )
1
+ # Modifications Copyright (C) 2023 Intel Corporation
2
2
3
- if (NOT DEFINED HIP_PATH )
4
- if (NOT DEFINED ENV{HIP_PATH} )
5
- set (HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed" )
6
- else ()
7
- set (HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed" )
8
- endif ()
9
- endif ()
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"),
5
+ # to deal in the Software without restriction, including without limitation
6
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ # and/or sell copies of the Software, and to permit persons to whom
8
+ # the Software is furnished to do so, subject to the following conditions:
9
+
10
+ # The above copyright notice and this permission notice shall be included
11
+ # in all copies or substantial portions of the Software.
10
12
11
- set (CMAKE_MODULE_PATH "${HIP_PATH} /cmake" ${CMAKE_MODULE_PATH} )
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
17
+ # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19
+ # OR OTHER DEALINGS IN THE SOFTWARE.
12
20
13
- project ( cudasift )
21
+ # SPDX-License-Identifier: MIT
14
22
15
- set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -O3 -Wextra -D__HIP_PLATFORM_AMD__=1" )
16
- set (CMAKE_CXX_STANDARD 11 )
23
+ cmake_minimum_required (VERSION 3.10 )
24
+ project (cudasift LANGUAGES CXX )
25
+ set (CMAKE_CXX_STANDARD 17 )
17
26
set (CMAKE_CXX_STANDARD_REQUIRED ON )
18
27
set (CMAKE_CXX_EXTENSIONS OFF )
19
28
29
+ set (DEF_WL_CXX_FLAGS " -D__HIP_PLATFORM_AMD__ " )
30
+ set (DEF_GENERAL_CXX_FLAGS " -Wall -O3 -Wextra " )
31
+ set (DEF_COMBINED_CXX_FLAGS "${DEF_GENERAL_CXX_FLAGS} ${DEF_WL_CXX_FLAGS} " )
32
+
33
+ if (NOT DEFINED ROCM_PATH )
34
+ if (NOT DEFINED ENV{ROCM_PATH} )
35
+ set (ROCM_PATH "/opt/rocm" CACHE PATH "Path to which HIP has been installed" )
36
+ else ()
37
+ set (ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which HIP has been installed" )
38
+ endif ()
39
+ endif ()
40
+
41
+ set (CMAKE_MODULE_PATH "${ROCM_PATH} /hip/cmake" ${CMAKE_MODULE_PATH} )
42
+ set (HIP_INCLUDE_DIRS "${ROCM_PATH} /include" ${HIP_INCLUDE_DIRS} )
43
+ set (HIP_LIBRARIES "${ROCM_PATH} /lib" ${HIP_LIBRARIES} )
44
+
20
45
option (DEVICE_TIMER "Build using Device Timer" OFF )
21
46
22
- find_package (HIP QUIET )
47
+ find_package (HIP REQUIRED )
23
48
24
49
if (HIP_FOUND )
25
50
message (STATUS "Found HIP: " ${HIP_VERSION} )
26
51
else ()
27
52
message (FATAL_ERROR "Could not find HIP!" )
28
53
endif ()
29
54
30
- set (HIP_SEPARABLE_COMPILATION ON )
31
-
32
55
find_package (OpenCV REQUIRED )
33
56
include_directories (${OpenCV_INCLUDE_DIRS} )
34
57
@@ -51,41 +74,35 @@ include_directories(
51
74
${CMAKE_CURRENT_SOURCE_DIR}
52
75
)
53
76
77
+ # -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
78
+ # -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
79
+ # passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
80
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
81
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
82
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
83
+ message (STATUS "Using DEFAULT compilation flags" )
84
+ set (CMAKE_CXX_FLAGS "${DEF_COMBINED_CXX_FLAGS} " )
85
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
86
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
87
+ set (CMAKE_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} " )
88
+ string (APPEND CMAKE_CXX_FLAGS ${DEF_WL_CXX_FLAGS} )
89
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
90
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
91
+ endif ()
92
+
93
+ message (STATUS "CXX Compilation flags to: ${CMAKE_CXX_FLAGS} " )
94
+
54
95
if (DEVICE_TIMER )
55
96
message (STATUS "Enabling Device Timer" )
56
97
add_compile_options (-DDEVICE_TIMER )
57
98
endif ()
58
99
100
+ set (HIP_SEPARABLE_COMPILATION ON )
59
101
set (MY_TARGET_NAME ${PROJECT_NAME} )
60
102
set (MY_HIPCC_OPTIONS )
61
103
set (MY_NVCC_OPTIONS )
62
104
set (CMAKE_HIP_ARCHITECTURES OFF )
63
- set (CMAKE_NVCC_FLAGS ${CMAKE_NVCC_FLAGS} -std=c++11 )
64
105
65
106
set_source_files_properties (${cuda_sources} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1 )
66
107
hip_add_executable (${MY_TARGET_NAME} ${SOURCES} ${MY_HIPCC_OPTIONS} NVCC_OPTIONS ${MY_NVCC_OPTIONS} )
67
108
target_link_libraries (cudasift stdc++ stdc++fs ${OpenCV_LIBS} )
68
-
69
- # SET(CUDA_SEPARABLE_COMPILATION ON)
70
- # hip_add_executable(cudasift ${cuda_sources} ${sources} OPTIONS -arch=sm_61)
71
-
72
- # cuda_add_executable(l2net l2netD.cu OPTIONS -arch=sm_35)
73
- # set_target_properties(cudasift PROPERTIES
74
- # COMPILE_FLAGS "${EXTRA_CXX_FLAGS}"
75
- # )
76
-
77
- # target_link_libraries(cudasift ${CUDA_cudadevrt_LIBRARY} ${OpenCV_LIBS})
78
-
79
- # /usr/local/cuda/lib64/libcudadevrt.a ${OpenCV_LIBS}
80
- # )
81
- # install(FILES
82
- # ${cuda_sources}
83
- # ${sources}
84
- # cudaSiftD.cu
85
- # CMakeLists.txt
86
- # Copyright.txt
87
- # DESTINATION .
88
- # )
89
- # install(FILES data/left.pgm data/righ.pgm
90
- # DESTINATION data
91
- # )
0 commit comments