Skip to content

Commit

Permalink
CMake jit_preprocess_files function only runs when needed (rapidsai#7872
Browse files Browse the repository at this point in the history
)

This correct a couple of issues with the `jit_preprocess_files` function.

1. It now always makes sure that the output directory that the jit headers are going into will exist before executing. So if a user deletes `<build_dir>/include` everything will work as expected
2. The output of the jitify tool are files that end in `.jit.hpp` not `.jit`. This is required to allow generators to build the minimal incremental compilation graph
3. Mark the input source files as a dependency so when that file is modified, the build-system knows to recompile the jit file.

Authors:
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Christopher Harris (https://github.com/cwharris)
  - Nghia Truong (https://github.com/ttnghia)
  - Jason Lowe (https://github.com/jlowe)
  - Keith Kraus (https://github.com/kkraus14)

URL: rapidsai#7872
  • Loading branch information
robertmaynard authored and shwina committed Apr 7, 2021
1 parent 2c7723c commit d07c405
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cpp/cmake/Modules/JitifyPreprocessKernels.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
# limitations under the License.
#=============================================================================

cmake_minimum_required(VERSION 3.18)

file(MAKE_DIRECTORY "${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files")

# Create `jitify_preprocess` executable
project(jitify_preprocess VERSION 2.0 LANGUAGES CXX CUDA)
add_executable(jitify_preprocess "${JITIFY_INCLUDE_DIR}/jitify2_preprocess.cpp")

target_link_libraries(jitify_preprocess CUDA::cudart ${CMAKE_DL_LIBS})
Expand All @@ -33,12 +28,14 @@ function(jit_preprocess_files)
)

foreach(ARG_FILE ${ARG_FILES})
set(ARG_OUTPUT ${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files/${ARG_FILE}.jit)
set(ARG_OUTPUT ${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files/${ARG_FILE}.jit.hpp)
get_filename_component(jit_output_directory "${ARG_OUTPUT}" DIRECTORY )
list(APPEND JIT_PREPROCESSED_FILES "${ARG_OUTPUT}")
add_custom_command(WORKING_DIRECTORY ${ARG_SOURCE_DIRECTORY}
DEPENDS jitify_preprocess
DEPENDS jitify_preprocess "${ARG_SOURCE_DIRECTORY}/${ARG_FILE}"
OUTPUT ${ARG_OUTPUT}
VERBATIM
COMMAND ${CMAKE_COMMAND} -E make_directory "${jit_output_directory}"
COMMAND jitify_preprocess ${ARG_FILE}
-o ${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files
-v
Expand Down

0 comments on commit d07c405

Please sign in to comment.