Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions swm_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
# Add optimization flag
#add_compile_options(-O2)
# Maybe move this to be set if CMAKE_BUILD_TYPE is Release
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3") # use -O3 for performance evaluation
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")

# Flags that get used when building debug flags
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -g")
Expand All @@ -15,4 +15,8 @@ endif()

if (SWM_OPENACC)
add_subdirectory(c_OpenACC)
endif()
endif()

if (SWM_CUDA)
add_subdirectory(c_CUDA)
endif()
53 changes: 53 additions & 0 deletions swm_c/c_CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

enable_language(CUDA)

set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

# Original CUDA implementation
add_executable(swm_c_cuda
shallow_swap.cuda.cu
../common/wtime.c
)

target_include_directories(swm_c_cuda PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../common)

set_target_properties(swm_c_cuda PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
)

target_compile_options(swm_c_cuda PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-lineinfo>)

target_link_libraries(swm_c_cuda PRIVATE m)

# Fused CUDA implementation (all kernels fused into one)
add_executable(swm_c_cuda_fused
shallow_swap.cuda.fused.cu
../common/wtime.c
)

target_include_directories(swm_c_cuda_fused PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../common)

set_target_properties(swm_c_cuda_fused PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
)

target_compile_options(swm_c_cuda_fused PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-lineinfo>)

target_link_libraries(swm_c_cuda_fused PRIVATE m)
Loading