Skip to content

Commit

Permalink
incorporate review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
apwojcik committed May 27, 2024
1 parent e1f6e2c commit 9d8bcf8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 25 deletions.
22 changes: 0 additions & 22 deletions src/register_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,6 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {

#ifdef _WIN32
namespace {
struct auto_load_targets
{
auto_load_targets()
{
make_target("ref");
#ifdef HAVE_CPU
make_target("cpu");
#endif
#ifdef HAVE_GPU
make_target("gpu");
#endif
#ifdef HAVE_FPGA
make_target("fpga");
#endif
}
};
[[maybe_unused]] static auto load_targets = auto_load_targets{};
} // namespace
#endif

void store_target_lib(const dynamic_loader& lib)
{
static std::vector<dynamic_loader> target_loader;
Expand Down
10 changes: 7 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ if(MIGRAPHX_DISABLE_LARGE_BUFFER_TESTS)
add_compile_definitions(MIGRAPHX_DISABLE_LARGE_BUFFER_TESTS)
endif()

add_library(register_targets STATIC register_target.cpp)
target_link_libraries(register_targets PRIVATE migraphx)

file(GLOB TESTS CONFIGURE_DEPENDS *.cpp)
list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/register_target.cpp)

foreach(TEST ${TESTS})
get_filename_component(BASE_NAME ${TEST} NAME_WE)
Expand All @@ -56,7 +60,7 @@ if(MIGRAPHX_ENABLE_GPU)
if(MIGRAPHX_USE_HIPRTC)
target_compile_definitions(test_gpu_${BASE_NAME} PUBLIC -DMIGRAPHX_USE_HIPRTC)
endif()
target_link_libraries(test_gpu_${BASE_NAME} migraphx_gpu migraphx_kernels)
target_link_libraries(test_gpu_${BASE_NAME} migraphx_gpu migraphx_kernels register_targets)
endforeach()
endif()

Expand Down Expand Up @@ -102,7 +106,7 @@ if(MIGRAPHX_ENABLE_GPU AND MIGRAPHX_ENABLE_CPU AND MIGRAPHX_ENABLE_FPGA)
set(TEST_NAME test_${BASE_NAME})
add_executable(${TEST_NAME} ${MULTI_TARGET_TEST})
rocm_clang_tidy_check(${TEST_NAME})
target_link_libraries(${TEST_NAME} migraphx migraphx_onnx migraphx_tf migraphx_all_targets)
target_link_libraries(${TEST_NAME} migraphx migraphx_onnx migraphx_tf migraphx_all_targets register_targets)
target_include_directories(${TEST_NAME} PUBLIC include)
add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}> WORKING_DIRECTORY ${TEST_MULTI_TARGET_DIR})
rocm_mark_as_test(${TEST_NAME})
Expand Down Expand Up @@ -140,7 +144,7 @@ function(test_headers PREFIX)
string(MAKE_C_IDENTIFIER ${HEADER_REL} TEST_NAME)
get_filename_component(BASE_NAME ${HEADER} NAME_WE)
test_header(header_${TEST_NAME} ${PREFIX}/${BASE_NAME}.hpp)
target_link_libraries(header_${TEST_NAME} migraphx migraphx_onnx migraphx_tf migraphx_all_targets)
target_link_libraries(header_${TEST_NAME} migraphx migraphx_onnx migraphx_tf migraphx_all_targets register_targets)
endforeach()
endfunction()

Expand Down
45 changes: 45 additions & 0 deletions test/register_target.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include <migraphx/register_target.hpp>

namespace {
struct auto_load_targets
{
auto_load_targets()
{
migraphx::make_target("ref");
#ifdef HAVE_CPU
migraphx::make_target("cpu");
#endif
#ifdef HAVE_GPU
migraphx::make_target("gpu");
#endif
#ifdef HAVE_FPGA
migraphx::make_target("fpga");
#endif
}
};
[[maybe_unused]] static auto load_targets = auto_load_targets{};
} // namespace

0 comments on commit 9d8bcf8

Please sign in to comment.