Skip to content

Commit 2db51da

Browse files
authored
changes for integration into proxySEM (#39)
* make camp more optional * some cmake fixes * fixes for absolute paths in aggregateOrSplit.py * updated pmpl for data transfer * change looping strategy for jacobian to static * cuda/std/tuple workaround and uncrustify * add cuda version through cmake
1 parent d9167ec commit 2db51da

File tree

22 files changed

+305
-175
lines changed

22 files changed

+305
-175
lines changed

CMakeLists.txt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ set( SHIVA_VERSION_PATCHLEVEL 0 )
1515
# check if Shiva is build as a submodule or a separate project
1616
get_directory_property( parent_dir PARENT_DIRECTORY )
1717
if(parent_dir)
18-
set( is_submodule ON )
18+
set( SHIVA_IS_SUBMODULE ON )
1919
else()
20-
set( is_submodule OFF )
20+
set( SHIVA_IS_SUBMODULE OFF )
2121
endif()
2222

23-
if( NOT is_submodule )
23+
if( NOT SHIVA_IS_SUBMODULE )
2424
message( "not a submodule")
2525
project( Shiva LANGUAGES CXX C )
2626

@@ -66,12 +66,22 @@ include( cmake/Macros.cmake )
6666
include( cmake/Config.cmake )
6767

6868

69+
set(SHIVA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
70+
set(SHIVA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
71+
72+
message( STATUS "SHIVA_BINARY_DIR: ${SHIVA_BINARY_DIR}" )
73+
message( STATUS "SHIVA_SOURCE_DIR: ${SHIVA_SOURCE_DIR}" )
74+
75+
6976
add_subdirectory( src )
70-
add_subdirectory( tpl/camp )
71-
target_compile_options( camp PRIVATE "-Wno-shadow")
7277

73-
configure_file(tpl/camp/include/camp/config.in.hpp
74-
${PROJECT_BINARY_DIR}/include/camp/config.hpp)
78+
if( SHIVA_ENABLE_CAMP )
79+
add_subdirectory( tpl/camp )
80+
target_compile_options( camp PRIVATE "-Wno-shadow")
81+
82+
configure_file(tpl/camp/include/camp/config.in.hpp
83+
${PROJECT_BINARY_DIR}/include/camp/config.hpp)
84+
endif()
7585

7686

7787
if( SHIVA_ENABLE_DOCS )

cmake/CMakeBasics.cmake

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,20 @@ blt_append_custom_compiler_flag( FLAGS_VAR CMAKE_CXX_FLAGS_DEBUG
2727
CLANG "-fstandalone-debug"
2828
)
2929

30-
31-
set( CAMP_ENABLE_TESTS OFF CACHE BOOL "")
30+
option( SHIVA_ENABLE_CAMP OFF )
31+
option( CAMP_ENABLE_TESTS OFF )
32+
33+
34+
if( ENABLE_CUDA )
35+
if( CUDA_VERSION AND CUDA_VERSION_MAJOR AND CUDA_VERSION_MINOR )
36+
set( SHIVA_CUDA_VERSION ${CUDA_VERSION} )
37+
set( SHIVA_CUDA_MAJOR ${CUDA_VERSION_MAJOR} )
38+
set( SHIVA_CUDA_MINOR ${CUDA_VERSION_MINOR} )
39+
else()
40+
message(FATAL_ERROR "CUDA_VERSION_MAJOR and CUDA_VERSION_MINOR not defined")
41+
endif()
42+
else()
43+
set( SHIVA_CUDA_VERSION 0 )
44+
set( SHIVA_CUDA_MAJOR 0 )
45+
set( SHIVA_CUDA_MINOR 0 )
46+
endif()

cmake/Config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#
22
set( PREPROCESSOR_DEFINES CUDA
33
HIP
4+
CAMP
45
BOUNDS_CHECK
56
)
67

cmake/blt

Submodule blt updated 354 files

docs/doxygen/ShivaConfig.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@
1414

1515
/* #undef SHIVA_USE_CALIPER */
1616

17+
#define SHIVA_USE_CAMP
18+
1719
#define SHIVA_USE_BOUNDS_CHECK
20+
21+
#define SHIVA_CUDA_MAJOR 0
22+
#define SHIVA_CUDA_MINOR 0

hostconfigs/TTE/maple_rocky9.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
set(CONFIG_NAME "maple_rocky9" CACHE PATH "")
2+
3+
set(COMPILER_DIR /opt/rh/gcc-toolset-13/root/ )
4+
set(CMAKE_C_COMPILER ${COMPILER_DIR}/bin/gcc CACHE PATH "")
5+
set(CMAKE_CXX_COMPILER ${COMPILER_DIR}/bin/g++ CACHE PATH "")
6+
7+
# C++ options
8+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -mtune=native -march=native" CACHE STRING "")
9+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g ${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "")
10+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "")
11+
12+
# Cuda options
13+
set(ENABLE_CUDA ON CACHE BOOL "")
14+
set(CUDA_TOOLKIT_ROOT_DIR /hrtc/apps/cuda/12.6.20/aarch64/rocky9 CACHE STRING "")
15+
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "")
16+
set(CMAKE_CUDA_COMPILER ${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc CACHE STRING "")
17+
set(CMAKE_CUDA_ARCHITECTURES 90 CACHE STRING "")
18+
set(CMAKE_CUDA_STANDARD 17 CACHE STRING "")
19+
set(CMAKE_CUDA_FLAGS "-restrict --expt-extended-lambda --expt-relaxed-constexpr -Werror cross-execution-space-call,reorder,deprecated-declarations" CACHE STRING "")
20+
#set(CMAKE_CUDA_FLAGS_RELEASE "-O3 -DNDEBUG -Xcompiler -DNDEBUG -Xcompiler -O3 -Xcompiler -mcpu=powerpc64le -Xcompiler -mtune=powerpc64le" CACHE STRING "")
21+
#set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-g -lineinfo ${CMAKE_CUDA_FLAGS_RELEASE}" CACHE STRING "")
22+
#set(CMAKE_CUDA_FLAGS_DEBUG "-g -G -O0 -Xcompiler -O0" CACHE STRING "")
23+
24+
set( SHIVA_ENABLE_CAMP OFF CACHE BOOL "Disable CAMP support" FORCE )

scripts/aggregateOrSplit.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ def create_dependency_graph(self, header, include_paths=None):
2020
if include_paths is None:
2121
include_paths = []
2222

23+
header = os.path.abspath(header) # Normalize here
24+
2325
if header in self.dependencies:
2426
return # Already processed
2527

2628
self.dependencies[header] = set()
27-
base_path = os.path.dirname(os.path.abspath(header)) # Base directory of the current header
29+
base_path = os.path.dirname(header) # Base directory of the current header
2830

2931
try:
3032
with open(header, 'r') as file:
@@ -34,10 +36,10 @@ def create_dependency_graph(self, header, include_paths=None):
3436
included_file = include_match.group(1)
3537

3638
if included_file != self.config_file:
37-
resolved_path = self.resolve_path(
38-
included_file, base_path, include_paths)
39+
resolved_path = self.resolve_path( included_file, base_path, include_paths)
3940

4041
if resolved_path:
42+
resolved_path = os.path.abspath(resolved_path)
4143
self.dependencies[header].add(resolved_path)
4244

4345
if os.path.exists(resolved_path):
@@ -82,16 +84,21 @@ def resolve_path(self, included_file, base_path, include_paths):
8284

8385
return None # Return None if no resolution was possible
8486

87+
8588
def generate_header_list(self):
8689
remaining_dependencies = self.dependencies.copy()
8790
size_of_remaining_dependencies = len(remaining_dependencies)
91+
unique_files = set() # Track unique files by absolute path
8892

8993
while size_of_remaining_dependencies > 0:
9094
local_included = []
9195

9296
for key in remaining_dependencies:
9397
if len(remaining_dependencies[key]) == 0:
94-
self.included_list.append(key)
98+
abs_key = os.path.abspath(key)
99+
if abs_key not in unique_files:
100+
self.included_list.append(abs_key)
101+
unique_files.add(abs_key)
95102
local_included.append(key)
96103

97104
for included_key in local_included:
@@ -111,6 +118,7 @@ def process_header(header_path, output):
111118
"""
112119
Processes a single header file, commenting out includes and pragmas.
113120
"""
121+
header_path = os.path.abspath(header_path)
114122
if header_path in self.included:
115123
return # Avoid duplicate processing
116124
self.included.add(header_path)
@@ -133,6 +141,7 @@ def process_header(header_path, output):
133141

134142
with open(output_file, 'w') as output:
135143
for header in headers:
144+
header = os.path.abspath(header)
136145
self.create_dependency_graph(header, include_paths)
137146

138147
for header in self.dependencies:

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ blt_add_library( NAME shiva
2323

2424
target_include_directories( shiva
2525
INTERFACE
26-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
26+
$<BUILD_INTERFACE:${SHIVA_BINARY_DIR}/include>
27+
$<BUILD_INTERFACE:${SHIVA_SOURCE_DIR}/src>
2728
$<INSTALL_INTERFACE:include> )
2829

2930
install( FILES ${shiva_headers}

src/ShivaConfig.hpp.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@
1414

1515
#cmakedefine SHIVA_USE_CALIPER
1616

17-
#cmakedefine SHIVA_USE_BOUNDS_CHECK
17+
#cmakedefine SHIVA_USE_CAMP
18+
19+
#cmakedefine SHIVA_USE_BOUNDS_CHECK
20+
21+
#define SHIVA_CUDA_MAJOR @SHIVA_CUDA_MAJOR@
22+
#define SHIVA_CUDA_MINOR @SHIVA_CUDA_MINOR@

src/common/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ blt_add_library( NAME common
3535

3636
target_include_directories( common
3737
INTERFACE
38-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
39-
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
38+
$<BUILD_INTERFACE:${SHIVA_BINARY_DIR}/include>
39+
$<BUILD_INTERFACE:${SHIVA_SOURCE_DIR}/src>
4040
$<INSTALL_INTERFACE:include> )
4141

4242
target_include_directories( common
4343
SYSTEM INTERFACE
44-
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/tpl/camp/include>
45-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/tpl/camp/include> )
44+
$<BUILD_INTERFACE:${SHIVA_SOURCE_DIR}/tpl/camp/include>
45+
$<BUILD_INTERFACE:${SHIVA_BINARY_DIR}/tpl/camp/include> )
4646

4747
install( FILES ${common_headers}
4848
DESTINATION include/common )

0 commit comments

Comments
 (0)