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
11 changes: 8 additions & 3 deletions cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ function(ginkgo_create_common_device_test test_name)
"${gko_test_multi_args}"
)
ginkgo_build_test_name(${test_name} test_target_name ${ARGN})
# the line number 5 here needs to match the line number that
# /*@GKO_PREPROCESSOR_FILENAME_HELPER@*/ is placed in the source file
set(GKO_PREPROCESSOR_FILENAME_HELPER
"*/\n#line 5 \"${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.cpp\"\n/*"
)
if(
GINKGO_BUILD_SYCL
AND NOT ("dpcpp" IN_LIST common_device_test_DISABLE_EXECUTORS)
Expand All @@ -429,7 +434,7 @@ function(ginkgo_create_common_device_test test_name)
PRIVATE ${GINKGO_DPCPP_FLAGS}
)
# We need to use a new file to avoid sycl setting in other backends because add_sycl_to_target will change the source property.
configure_file(${test_name}.cpp ${test_name}.dp.cpp COPYONLY)
configure_file(${test_name}.cpp ${test_name}.dp.cpp @ONLY)
gko_add_sycl_to_target(TARGET ${test_target_name}_dpcpp SOURCES ${test_name}.dp.cpp)
target_link_options(
${test_target_name}_dpcpp
Expand All @@ -448,7 +453,7 @@ function(ginkgo_create_common_device_test test_name)
AND NOT ("cuda" IN_LIST common_device_test_DISABLE_EXECUTORS)
)
# need to make a separate file for this, since we can't set conflicting properties on the same file
configure_file(${test_name}.cpp ${test_name}.cu COPYONLY)
configure_file(${test_name}.cpp ${test_name}.cu @ONLY)
ginkgo_create_cuda_test_internal(${test_name}_cuda ${CMAKE_CURRENT_BINARY_DIR}/${test_name}.cu ${test_target_name}_cuda ${ARGN})
target_compile_definitions(
${test_target_name}_cuda
Expand All @@ -460,7 +465,7 @@ function(ginkgo_create_common_device_test test_name)
AND NOT ("hip" IN_LIST common_device_test_DISABLE_EXECUTORS)
)
# need to make a separate file for this, since we can't set conflicting properties on the same file
configure_file(${test_name}.cpp ${test_name}.hip.cpp COPYONLY)
configure_file(${test_name}.cpp ${test_name}.hip.cpp @ONLY)
ginkgo_create_hip_test_internal(${test_name}_hip ${CMAKE_CURRENT_BINARY_DIR}/${test_name}.hip.cpp ${test_target_name}_hip ${ARGN})
target_compile_definitions(
${test_target_name}_hip
Expand Down
4 changes: 3 additions & 1 deletion test/base/index_range.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/
Copy link
Member Author

Choose a reason for hiding this comment

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

I am using this weird comment structure to make sure both the original file and the generated file are valid C++ code. The ´#line` directive can start after a comment, but afaik it can't end with a comment, so that needs to be in the next line.


#include "core/base/index_range.hpp"

#include <memory>
Expand Down
2 changes: 2 additions & 0 deletions test/base/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I am missing something, wouldn't this be now after preprocessing be /*/*#line 5 .... */*/ ?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, the above comment clarifies it. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The actual string will be

/**/
#line 5 "file.cpp"
/**/


#include "core/base/intrinsics.hpp"

#include <memory>
Expand Down
4 changes: 3 additions & 1 deletion test/base/iterator_factory.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/

#include "core/base/iterator_factory.hpp"

#include <memory>
Expand Down
4 changes: 3 additions & 1 deletion test/base/kernel_launch_generic.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/

#include <algorithm>
#include <memory>
#include <type_traits>
Expand Down
4 changes: 3 additions & 1 deletion test/base/segmented_range.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/

#include "core/base/segmented_range.hpp"

#include <memory>
Expand Down
2 changes: 2 additions & 0 deletions test/components/range_minimum_query_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/

#include "core/components/range_minimum_query_kernels.hpp"

#include <limits>
Expand Down
2 changes: 2 additions & 0 deletions test/matrix/csr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/

#include "core/matrix/csr_kernels.hpp"

#include <algorithm>
Expand Down