From 0be3ff69b29efa7c402acfc0be5dc9d70b175302 Mon Sep 17 00:00:00 2001 From: Cory Bloor Date: Thu, 29 Aug 2024 15:57:57 -0600 Subject: [PATCH] Fix roctx target export and test (#187) The roctx package is named rocprofiler-sdk-roctx so the target export was not working. This commit adds CTest automated testing for the roctx interface and fixes a compilation error introduced when roctxRangePushA was renamed in d21f26aef90a1261389a76a9456d79048b423c52. --- CMakeLists.txt | 2 +- lib/CMakeLists.txt | 6 +++--- test/CMakeLists.txt | 23 +++++++++++++++++++++-- test/f2003/roctx/main.f03 | 4 ++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32a21cd1..ca90496e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) #Setting Default value for libdir set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index bcde37df..f94328d8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -124,9 +124,9 @@ if(HIP_PLATFORM STREQUAL "amd") message(STATUS "Skipping hipfort::hip target export") endif() - find_package(roctx PATHS ${ROCM_PATH} /opt/rocm) - if(roctx_FOUND) - hipfort_add_component(roctx roc::roctx) + find_package(rocprofiler-sdk-roctx PATHS ${ROCM_PATH} /opt/rocm) + if(rocprofiler-sdk-roctx_FOUND) + hipfort_add_component(roctx rocprofiler-sdk-roctx::rocprofiler-sdk-roctx) else() message(STATUS "Skipping hipfort::roctx target export") endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eb133aef..9b16917f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,7 +5,7 @@ # Each test is contained in its own subdirectory of this test directory # The Makefile must create a binary with the same name as the directory name. -cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) +cmake_minimum_required(VERSION 3.5) if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") project(test-hipfort) endif() @@ -47,7 +47,7 @@ if(BUILD_TESTING) target_link_libraries(hipfort_test_${dir}_${lib}_${func} PRIVATE hipfort::${lib} hipfort::hip) # the tests call EXIT, which is a GNU extension - target_compile_options(hipfort_test_${dir}_${lib}_${func} PRIVATE -std=gnu) + target_compile_options(hipfort_test_${dir}_${lib}_${func} PRIVATE $<$:-std=gnu>) add_test( NAME hipfort_test_${dir}_${lib}_${func} @@ -105,4 +105,23 @@ if(BUILD_TESTING) hipfort_add_test(rocsparse ddoti f2003) hipfort_add_test(rocsparse ddoti f2008) endif() + + if(TARGET hipfort::roctx) + include(CheckLanguage) + check_language(HIP) + if(CMAKE_HIP_COMPILER) + enable_language(HIP) + hipfort_add_test(roctx main f2003) + target_sources(hipfort_test_f2003_roctx_main PRIVATE f2003/roctx/hip_implementation.cpp) + set_source_files_properties(f2003/roctx/hip_implementation.cpp + PROPERTIES + LANGUAGE HIP + ) + set_target_properties(hipfort_test_f2003_roctx_main + PROPERTIES + LINKER_LANGUAGE Fortran + POSITION_INDEPENDENT_CODE ON + ) + endif() + endif() endif() diff --git a/test/f2003/roctx/main.f03 b/test/f2003/roctx/main.f03 index cb15158c..6a91841b 100644 --- a/test/f2003/roctx/main.f03 +++ b/test/f2003/roctx/main.f03 @@ -27,9 +27,9 @@ subroutine launch() bind(c) end do write(*,"(a)",advance="no") " - " - ret = roctxRangePushA(c_char_"hello_world"//c_null_char) + ret = roctxRangePush(c_char_"hello_world"//c_null_char) if (ret /= 0) then - write (*, *) "ROCTX ERROR: roctxRangePushA: Invalid nested range level ", ret + write (*, *) "ROCTX ERROR: roctxRangePush: Invalid nested range level ", ret end if call launch()