Skip to content
Merged
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
5 changes: 2 additions & 3 deletions .github/workflows/cmake-linux-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Add to PATH
shell: bash
run: |
echo "/usr/lib/llvm-19/bin" >> $GITHUB_PATH
echo "/usr/lib/llvm-21/bin" >> $GITHUB_PATH

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
Expand All @@ -40,8 +40,7 @@ jobs:

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: >
core_count=$(nproc)
run: >
cmake --build ${{ steps.strings.outputs.build-output-dir }}
--config Release

Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/cmake-linux-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ on:
pull_request:
branches: [ "main"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: [self-hosted,linux,arm64,agx]

runs-on: [self-hosted,linux,arm64]
timeout-minutes: 10 # Increase this timeout value as needed
strategy:
matrix:
build_type: [Release]
cpp_compiler: [g++,clang++]
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

matrix:
cpp_compiler: [g++,clang++]

fail-fast: true

steps:
- uses: actions/checkout@v4
- name: Add to PATH
shell: bash
run: |
echo "/usr/lib/llvm-19/bin" >> $GITHUB_PATH
echo "/usr/lib/llvm-21/bin" >> $GITHUB_PATH

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
Expand All @@ -36,19 +39,18 @@ jobs:
cmake -G "Ninja" -B ${{steps.strings.outputs.build-output-dir}}
-DCMAKE_CXX_COMPILER=${{matrix.cpp_compiler}}
-DCUDA_ARCH="87;"
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-S ${{github.workspace}};

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: >
core_count=$(nproc)
run: >
cmake --build ${{ steps.strings.outputs.build-output-dir }}
--config Release

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config Release --output-junit test_results.xml
run: ctest --build-config ${{ matrix.build_type }} --output-junit test_results.xml

2 changes: 1 addition & 1 deletion .github/workflows/cmake-windows-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
matrix:
toolset: ["cl,14.16,11.8","cl,14.44,12.9","llvm,19.1.7,12.9"]
toolset: ["cl,14.16,11.8","cl,14.44,12.9","llvm,21.1.0,12.9"]


steps:
Expand Down
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ set (PROJECT_VERSION_REV 11)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_REV})
include (cmake/cmake_init.cmake)
include (cmake/doxygen.cmake)
include (cmake/targets/virtualfolders.cmake)
include (cmake/deploy/deploy_dependencies.cmake)

include (cmake/archflags.cmake)
include (cmake/generators/version_header.cmake)
include (cmake/generators/export_header.cmake)
project(FusedKernelLibrary VERSION ${PROJECT_VERSION} LANGUAGES CXX
DESCRIPTION "Implementation of a methodology that allows all sorts of user defined GPU kernel fusion, for non CUDA programmers."
HOMEPAGE_URL "https://github.com/morousg/FusedKernelLibrary" )
Expand All @@ -36,20 +36,22 @@ else()
message(STATUS "CUDA compiler not found, CUDA support will be disabled.")
endif()

add_subdirectory(include)
add_subdirectory(lib)


option (BUILD_TEST "build standard tests" ON)
option (BUILD_UTEST "build standard unit tests" ON)
option (ENABLE_BENCHMARK "build benchmarking unit tests" OFF)



add_subdirectory(include)
add_subdirectory(lib)
if (${BUILD_TEST})
include (cmake/tests/discover_tests.cmake)
enable_testing()
add_subdirectory(tests)
endif()

if (${BUILD_UTEST})
include (cmake/tests/discover_tests.cmake)
enable_testing()
add_subdirectory(tests)
enable_testing()
add_subdirectory(utests)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/cmake_init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RelWithDebInfo;Release;")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")

set (TEMPLATE_DEPTH "1000" CACHE STRING "template depth")

set (FUNDAMENTAL_TYPES uchar char ushort short uint int ulong long ulonglong longlong float double)

cmake_policy(SET CMP0111 NEW) # ensure all targets provide shared libs location

Expand Down
84 changes: 84 additions & 0 deletions cmake/discover_tests.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
set (LAUNCH_SOURCES "${CMAKE_SOURCE_DIR}/tests/main.cpp;${CMAKE_SOURCE_DIR}/tests/main.h")
if (WIN32)
list(APPEND LAUNCH_SOURCES "${CMAKE_SOURCE_DIR}/manifest.xml") #for utf8 codepage
endif()

function(add_cuda_to_test TARGET_NAME)
add_cuda_to_target(${TARGET_NAME} "")
set_target_cuda_arch_flags(${TARGET_NAME})

if(${ENABLE_DEBUG})
add_cuda_debug_support_to_target(${TARGET_NAME})
endif()
if(${ENABLE_NVTX})
add_nvtx_support_to_target(${TARGET_NAME})
endif()
endfunction()

function (add_generated_test TARGET_NAME TEST_SOURCE EXTENSION DIR)

set(TEST_GENERATED_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}_${EXTENSION}/launcher.${EXTENSION}") #use the same name as the target )

configure_file(${CMAKE_SOURCE_DIR}/tests/launcher.in ${TEST_GENERATED_SOURCE} @ONLY) #replace variables in the test source file
set (TARGET_NAME_EXT "${TARGET_NAME}_${EXTENSION}")
#message(STATUS "Adding test: ${TARGET_NAME_EXT} from ${TEST_GENERATED_SOURCE} and ${TEST_SOURCE}")
add_executable(${TARGET_NAME_EXT} "${TEST_GENERATED_SOURCE};${TEST_SOURCE}" )
target_sources(${TARGET_NAME_EXT} PRIVATE ${LAUNCH_SOURCES})

if(${ENABLE_BENCHMARK})
target_compile_definitions(${TARGET_NAME_EXT} PRIVATE ENABLE_BENCHMARK)
endif()

set_target_properties(${TARGET_NAME_EXT} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)
target_include_directories(${TARGET_NAME_EXT} PRIVATE "${CMAKE_SOURCE_DIR}")
target_include_directories(${TARGET_NAME_EXT} PRIVATE "${DIR}")
target_link_libraries(${TARGET_NAME_EXT} PRIVATE FKL::FKL)
target_link_libraries(${TARGET_NAME_EXT} PRIVATE CUDA::cuda_driver)
if (NVRTC_ENABLE)
target_link_libraries(${TARGET_NAME_EXT} PRIVATE ${NVRTC_LIBRARIES})
target_compile_definitions(${TARGET_NAME_EXT} PRIVATE NVRTC_ENABLE)
if (MSVC)
if (NVRTC_STATIC_LINK)
set_target_properties(${TARGET_NAME_EXT} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
endif()
if (MSVC)
target_compile_options(${TARGET_NAME_EXT} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/diagnostics:caret>)
endif()

add_optimization_flags(${TARGET_NAME_EXT})

add_test(NAME ${TARGET_NAME_EXT} COMMAND ${TARGET_NAME_EXT})
cmake_path(SET path2 "${DIR}")
cmake_path(GET path2 FILENAME DIR_NAME)
set_property(TARGET "${TARGET_NAME_EXT}" PROPERTY FOLDER "tests/${EXTENSION}/${DIR_NAME}")

endfunction()

function (discover_tests DIR)
file(
GLOB_RECURSE
TEST_SOURCES
CONFIGURE_DEPENDS
"${DIR}/*.h"
)

foreach(test_source ${TEST_SOURCES})

get_filename_component(TARGET_NAME ${test_source} NAME_WE)
cmake_path(GET test_source PARENT_PATH DIR_NAME) #get the directory name of the test source file
string(FIND ${DIR_NAME} "cudabug" POS)
if (${POS} EQUAL -1) #if the directory name does not contain "cudabug"
if (${ENABLE_CPU})
add_generated_test("${TARGET_NAME}" "${test_source}" "cpp" "${DIR_NAME}")
endif()
endif()
if (CMAKE_CUDA_COMPILER AND ENABLE_CUDA)
add_generated_test("${TARGET_NAME}" "${test_source}" "cu" "${DIR_NAME}")
add_cuda_to_test("${TARGET_NAME}_cu")
endif()

endforeach()
endfunction()

9 changes: 9 additions & 0 deletions cmake/generators/export_header.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


macro(add_generated_export_header_to_target TARGET_NAME)
include(GenerateExportHeader)
generate_export_header(${TARGET_NAME} EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/exports/${TARGET_NAME}_export.h")
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_BINARY_DIR}/exports/")
set_target_properties(${TARGET_NAME} PROPERTIES CXX_VISIBILITY_PRESET default)
target_sources(${TARGET_NAME} PRIVATE "${CMAKE_BINARY_DIR}/exports/${TARGET_NAME}_export.h")
endmacro()
23 changes: 0 additions & 23 deletions cmake/targets/virtualfolders.cmake

This file was deleted.

74 changes: 46 additions & 28 deletions cmake/tests/add_generated_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set (LAUNCH_SOURCES "${CMAKE_SOURCE_DIR}/tests/main.cpp;${CMAKE_SOURCE_DIR}/test
if (WIN32)
list(APPEND LAUNCH_SOURCES "${CMAKE_SOURCE_DIR}/utf8cp.manifest") #for utf8 codepage
endif()

include (cmake/generators/export_header.cmake)
function(add_cuda_to_test TARGET_NAME)
add_cuda_to_target(${TARGET_NAME} "")
set_target_cuda_arch_flags(${TARGET_NAME})
Expand All @@ -15,46 +15,64 @@ function(add_cuda_to_test TARGET_NAME)
endif()
endfunction()

function (add_generated_test TARGET_NAME TEST_SOURCE EXTENSION DIR)
set(TEST_GENERATED_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}_${EXTENSION}/launcher.${EXTENSION}") #use the same name as the target )

configure_file(${CMAKE_SOURCE_DIR}/tests/launcher.in ${TEST_GENERATED_SOURCE} @ONLY) #replace variables in the test source file
set (TARGET_NAME_EXT "${TARGET_NAME}_${EXTENSION}")
#message(STATUS "Adding test: ${TARGET_NAME_EXT} from ${TEST_GENERATED_SOURCE} and ${TEST_SOURCE}")
add_executable(${TARGET_NAME_EXT} "${TEST_GENERATED_SOURCE};${TEST_SOURCE}" )
target_sources(${TARGET_NAME_EXT} PRIVATE ${LAUNCH_SOURCES})
function(configure_test_target_flags TARGET_NAME TEST_SOURCE DIR)

set(TEST_GENERATED_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}_${EXTENSION}/launcher.${EXTENSION}") #use the same name as the target )
configure_file(${CMAKE_SOURCE_DIR}/tests/launcher.in ${TEST_GENERATED_SOURCE} @ONLY) #replace variables in the test source file
#message(STATUS "Adding test: ${TARGET_NAME} from ${TEST_GENERATED_SOURCE} and ${TEST_SOURCE}")

if(${ENABLE_BENCHMARK})
target_compile_definitions(${TARGET_NAME_EXT} PRIVATE ENABLE_BENCHMARK)
target_compile_definitions(${TARGET_NAME} PRIVATE ENABLE_BENCHMARK)
endif()
set_target_properties(${TARGET_NAME_EXT} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)
target_include_directories(${TARGET_NAME_EXT} PUBLIC "${CMAKE_SOURCE_DIR}")
target_include_directories(${TARGET_NAME_EXT} PUBLIC "${DIR}")
target_link_libraries(${TARGET_NAME_EXT} PUBLIC FKL::FKL)
set_target_properties(${TARGET_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_SOURCE_DIR}")
target_include_directories(${TARGET_NAME} PUBLIC "${DIR}")
target_link_libraries(${TARGET_NAME} PUBLIC FKL::FKL)
if (MSVC)
target_compile_options(${TARGET_NAME_EXT} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/diagnostics:caret>)
target_compile_options(${TARGET_NAME_EXT} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
target_compile_options(${TARGET_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/diagnostics:caret>)
target_compile_options(${TARGET_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
# add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
#target_link_libraries(${TARGET_NAME_EXT} -manifest:embed -manifestinput:"${PROJECT_SOURCE_DIR}/myapp.manifest"
#target_link_libraries(${TARGET_NAME} -manifest:embed -manifestinput:"${PROJECT_SOURCE_DIR}/myapp.manifest"
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${TARGET_NAME_EXT} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++11-narrowing>)
target_compile_options(${TARGET_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++11-narrowing>)
target_compile_options(${TARGET_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wconversion>)

endif()


add_optimization_flags(${TARGET_NAME_EXT})

add_test(NAME ${TARGET_NAME_EXT} COMMAND ${TARGET_NAME_EXT})
cmake_path(SET path2 "${DIR}")
cmake_path(GET path2 FILENAME DIR_NAME)
cmake_path(GET path2 PARENT_PATH DIR_PARENT_PATH)
if (${EXTENSION} STREQUAL "cu")
add_optimization_flags(${TARGET_NAME})
endfunction()

function (set_ide_target_folder TARGET_NAME DIR_PARENT_PATH EXTENSION)
if (${EXTENSION} STREQUAL "cu")
set(FKL_BACKEND "cuda")
elseif(${EXTENSION} STREQUAL "cpp")
set(FKL_BACKEND "cpu")
else()
message(FATAL_ERROR "Unknown extension: ${EXTENSION}")
endif()
set_property(TARGET "${TARGET_NAME_EXT}" PROPERTY FOLDER "${DIR_PARENT_PATH}/${FKL_BACKEND}/")

set_property(TARGET "${TARGET_NAME}" PROPERTY FOLDER "${DIR_PARENT_PATH}/${FKL_BACKEND}/")
endfunction()


function (add_generated_test_stub TARGET_NAME_EXT TEST_SOURCE DIR)
set(TEST_GENERATED_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}_${EXTENSION}/launcher.${EXTENSION}") #use the same name as the target )
configure_file(${CMAKE_SOURCE_DIR}/tests/launcher.in ${TEST_GENERATED_SOURCE} @ONLY) #replace variables in the test source file
add_executable(${TARGET_NAME_EXT} "${TEST_GENERATED_SOURCE};${TEST_SOURCE}" )
configure_test_target_flags("${TARGET_NAME_EXT}" "${TEST_SOURCE}" "${DIR}")
target_sources(${TARGET_NAME_EXT} PRIVATE ${LAUNCH_SOURCES})
add_test(NAME ${TARGET_NAME_EXT} COMMAND ${TARGET_NAME_EXT})
cmake_path(SET path2 "${DIR}")
cmake_path(GET path2 FILENAME DIR_NAME)
cmake_path(GET path2 PARENT_PATH DIR_PARENT_PATH)
string(REPLACE " " "" DIR_PARENT_PATH "${DIR_PARENT_PATH}") #for windows

set_ide_target_folder("${TARGET_NAME_EXT}" "${DIR_PARENT_PATH}" "${EXTENSION}")

endfunction()

function (add_generated_test TARGET_NAME TEST_SOURCE EXTENSION DIR)
set(TEST_GENERATED_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}_${EXTENSION}/launcher.${EXTENSION}") #use the same name as the target )
set (TARGET_NAME_EXT "${TARGET_NAME}_${EXTENSION}")
add_generated_test_stub("${TARGET_NAME_EXT}" "${TEST_SOURCE}" "${DIR}")
endfunction()
36 changes: 36 additions & 0 deletions cmake/tests/add_shared_test_libs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function (add_generated_lib TARGET_NAME TEST_SOURCES DIR)
add_library(${TARGET_NAME} SHARED "${TEST_SOURCES}" )
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
add_generated_export_header_to_target(${TARGET_NAME})
configure_test_target_flags("${TARGET_NAME}" "${TEST_SOURCES}" "${DIR}")
set_property(TARGET "${TARGET_NAME}" PROPERTY FOLDER "${DIR}")
endfunction()

function (add_shared_target TARGET_BASE_NAME EXTENSION FUNDAMENTAL_TYPE DIR)
string(TOUPPER ${FUNDAMENTAL_TYPE} FUNDAMENTAL_TYPE_UPPER)
string(TOUPPER ${EXTENSION} EXTENSION_UPPER)
set (GEN_DIR ${TARGET_BASE_NAME}_${FUNDAMENTAL_TYPE}_${EXTENSION})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_BASE_NAME}_ftype.h.in
${CMAKE_BINARY_DIR}/generated/${GEN_DIR}/${GEN_DIR}.h)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_BASE_NAME}_ftype.${EXTENSION}.in
${CMAKE_BINARY_DIR}/generated/${GEN_DIR}/${GEN_DIR}.${EXTENSION})

set(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_BASE_NAME}_common.h"
${CMAKE_BINARY_DIR}/generated/${GEN_DIR}/${GEN_DIR}.h
${CMAKE_BINARY_DIR}/generated/${GEN_DIR}/${GEN_DIR}.${EXTENSION})

add_generated_lib("${TARGET_NAME}_${EXTENSION}" "${SOURCES}" "${DIR}")
Comment thread
albertandaluz marked this conversation as resolved.

Copilot AI Sep 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable TARGET_NAME is used but not defined in this function scope. It should be TARGET_BASE_NAME or the function parameter should be corrected.

Copilot uses AI. Check for mistakes.
target_include_directories("${TARGET_NAME}_${EXTENSION}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/") #testcommon
target_include_directories("${TARGET_NAME}_${EXTENSION}" PUBLIC "${CMAKE_BINARY_DIR}/generated/${GEN_DIR}/") #testcommon
Comment on lines +23 to +25

Copilot AI Sep 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable TARGET_NAME is not defined in this function scope. It should use the TARGET_BASE_NAME parameter or the locally defined TARGET_NAME from line 30.

Suggested change
add_generated_lib("${TARGET_NAME}_${EXTENSION}" "${SOURCES}" "${DIR}")
target_include_directories("${TARGET_NAME}_${EXTENSION}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/") #testcommon
target_include_directories("${TARGET_NAME}_${EXTENSION}" PUBLIC "${CMAKE_BINARY_DIR}/generated/${GEN_DIR}/") #testcommon
add_generated_lib("${TARGET_BASE_NAME}_${FUNDAMENTAL_TYPE}_${EXTENSION}" "${SOURCES}" "${DIR}")
target_include_directories("${TARGET_BASE_NAME}_${FUNDAMENTAL_TYPE}_${EXTENSION}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/") #testcommon
target_include_directories("${TARGET_BASE_NAME}_${FUNDAMENTAL_TYPE}_${EXTENSION}" PUBLIC "${CMAKE_BINARY_DIR}/generated/${GEN_DIR}/") #testcommon

Copilot uses AI. Check for mistakes.

endfunction()

function (add_shared_test_lib TARGET_BASE_NAME DIR EXTENSION FUNDAMENTAL_TYPE)
set(TARGET_NAME "${TARGET_BASE_NAME}_${FUNDAMENTAL_TYPE}")
add_shared_target("${TARGET_BASE_NAME}" "${EXTENSION}" "${FUNDAMENTAL_TYPE}" "${DIR}")
if ("${EXTENSION}" STREQUAL "cu")
add_cuda_to_test("${TARGET_NAME}_${EXTENSION}")
endif()

endfunction()
Loading