Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix targets registration on Windows #2866

Merged
merged 35 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
34bf488
fix target registering on Windows
apwojcik Feb 27, 2024
fc29bd6
upgrade the year in licenses
apwojcik Mar 7, 2024
cd46541
fix compilation of the fpga target
Mar 7, 2024
60860e9
update the year in CMakeLists.txt files
Mar 7, 2024
7de05db
fix cppcheck reports
Mar 7, 2024
bbe1d3d
undo *requirements.txt
Mar 7, 2024
6b14d6d
Merge branch 'develop' into register_target
apwojcik Mar 7, 2024
1e1f4fb
minimize the number of changes required
apwojcik Mar 7, 2024
07cc374
add missing migraphx_all_targets to tests
apwojcik Mar 7, 2024
4624e43
update the year in the license
apwojcik Mar 7, 2024
151dac7
Merge branch 'develop' into register_target
apwojcik Apr 23, 2024
894d40f
Merge branch 'develop' into register_target
apwojcik May 8, 2024
45ede6f
incorporate review feedback
apwojcik May 8, 2024
caac2b0
fix typo
apwojcik May 8, 2024
0e73fdb
fix clang-format
apwojcik May 8, 2024
68c049c
Merge branch 'develop' into register_target
apwojcik May 8, 2024
f0d79d3
limit auto target registration to Windows only
apwojcik May 8, 2024
7090c2b
Merge branch 'develop' into register_target
apwojcik May 8, 2024
e1f6e2c
Merge branch 'develop' into register_target
apwojcik May 27, 2024
9d8bcf8
incorporate review feedback
apwojcik May 27, 2024
5e3411f
Merge branch 'develop' into register_target
apwojcik May 27, 2024
db78e91
incorporate review feedback
apwojcik May 27, 2024
5a235c1
fix license check
apwojcik May 27, 2024
6ec5a5e
fix clang-format
apwojcik May 27, 2024
31459c7
incorporate review feedback
apwojcik May 27, 2024
75a5b61
Merge branch 'develop' into register_target
apwojcik May 28, 2024
bbf93b0
Merge branch 'develop' into register_target
apwojcik May 29, 2024
52fc7d1
Merge branch 'develop' into register_target
apwojcik May 30, 2024
2ad56ac
Merge branch 'develop' into register_target
apwojcik Jun 3, 2024
f00dc28
Merge branch 'develop' into register_target
apwojcik Jun 5, 2024
a3ccae5
fix target library registration on Windows
apwojcik Mar 7, 2024
2004b73
add missing linking to migraphx_all_tragets
apwojcik Jun 6, 2024
14bf216
Merge branch 'develop' into register_target
apwojcik Jun 6, 2024
bcd8ad1
revert some more changes
apwojcik Jun 6, 2024
165d0ec
revert some more changes
apwojcik Jun 6, 2024
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: 3 additions & 2 deletions src/include/migraphx/register_target.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 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
Expand All @@ -28,6 +28,7 @@
#include <migraphx/target.hpp>
#include <migraphx/auto_register.hpp>
#include <cstring>
#include <utility>
#include <vector>

namespace migraphx {
Expand All @@ -44,7 +45,7 @@ struct target_handler
{
target t;
std::string target_name;
target_handler(const target& t_r) : t(t_r), target_name(t.name()) {}
explicit target_handler(target t_r) : t(std::move(t_r)), target_name(t.name()) {}
~target_handler() { unregister_target(target_name); }
};
} // namespace detail
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 migraphx_all_targets)

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-2024 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
Loading