Skip to content

Commit

Permalink
Fix roctx target export and test (#187)
Browse files Browse the repository at this point in the history
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 d21f26a.
  • Loading branch information
cgmb authored Aug 29, 2024
1 parent b0df83e commit 0be3ff6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
6 changes: 3 additions & 3 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 21 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 $<$<COMPILE_LANGUAGE:Fortran>:-std=gnu>)

add_test(
NAME hipfort_test_${dir}_${lib}_${func}
Expand Down Expand Up @@ -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()
4 changes: 2 additions & 2 deletions test/f2003/roctx/main.f03
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0be3ff6

Please sign in to comment.