Skip to content

Commit

Permalink
Make DR_NVTX optional, use HAVE_DR_NVTX instead of __PGI in Fortran/C
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarguinaud committed Jun 7, 2024
1 parent dfad60a commit 453b148
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/tools/install-nvhpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See <https://creativecommons.org/publicdomain/zero/1.0/> for
# details.

version=21.9
version=24.3

TEMPORARY_FILES="${TMPDIR:-/tmp}"
export NVHPC_INSTALL_DIR=$(pwd)/nvhpc-install
Expand Down Expand Up @@ -55,8 +55,8 @@ if [ -d "${NVHPC_INSTALL_DIR}" ]; then
fi
fi

# Example download URL for version 21.9
# https://developer.download.nvidia.com/hpc-sdk/21.9/nvhpc_2020_219_Linux_x86_64_cuda_11.0.tar.gz
# Example download URL for version 24.3
# https://developer.download.nvidia.com/hpc-sdk/24.3/nvhpc_2020_219_Linux_x86_64_cuda_11.0.tar.gz

ver="$(echo $version | tr -d . )"
URL=$(curl -s "https://developer.nvidia.com/nvidia-hpc-sdk-$ver-downloads" | grep -oP "https://developer.download.nvidia.com/hpc-sdk/([0-9]{2}\.[0-9]+)/nvhpc_([0-9]{4})_([0-9]+)_Linux_$(uname -m)_cuda_([0-9\.]+).tar.gz" | sort | tail -1)
Expand Down
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,21 @@ ecbuild_add_option( FEATURE WARNINGS
DEFAULT ON
DESCRIPTION "Add warnings to compiler" )

if(CMAKE_C_COMPILER_ID STREQUAL "PGI" OR CMAKE_C_COMPILER_ID STREQUAL "NVHPC" )
set (DEFAULT_DR_NVTX ON)
else ()
set (DEFAULT_DR_NVTX OFF)
endif ()

ecbuild_add_option( FEATURE DR_NVTX
DEFAULT ${DEFAULT_DR_NVTX}
DESCRIPTION "Add nvtx intrumentation" )

ecbuild_find_package( NAME Realtime QUIET )

####

if(CMAKE_C_COMPILER_ID STREQUAL "PGI" OR CMAKE_C_COMPILER_ID STREQUAL "NVHPC" )
if(HAVE_DR_NVTX)

find_package(CUDAToolkit REQUIRED COMPONENTS nvtx3)
find_package(NVHPC REQUIRED COMPONENTS HOSTUTILS)
Expand Down
11 changes: 6 additions & 5 deletions src/fiat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ endif()
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/library/version.c.in ${CMAKE_CURRENT_BINARY_DIR}/version.c @ONLY )

ecbuild_list_add_pattern( LIST fiat_src GLOB *.c *.F* *.cc )
if(NOT (CMAKE_C_COMPILER_ID STREQUAL "PGI" OR CMAKE_C_COMPILER_ID STREQUAL "NVHPC" ))
# The files in the dr_nvtx directory are only intended to work with NVHPC
# So don't try to compile them when using another compiler
ecbuild_list_exclude_pattern( LIST fiat_src REGEX dr_nvtx/* )

if( NOT HAVE_DR_NVTX)
# The files in the drnvtx directory are only intended to work with NVHPC
# So don't try to compile them when using another compiler
ecbuild_list_exclude_pattern( LIST fiat_src REGEX drnvtx/* )
endif()

set( fiat_src ${fiat_src} PARENT_SCOPE )
Expand All @@ -74,7 +75,7 @@ ecbuild_add_library( TARGET fiat

## if compiler is pgi add two libs

if(CMAKE_C_COMPILER_ID STREQUAL "PGI" OR CMAKE_C_COMPILER_ID STREQUAL "NVHPC" )
if (HAVE_DR_NVTX)
target_link_libraries(fiat PUBLIC ${NVTOOLSEXT_LIB})
target_link_libraries(fiat PUBLIC ${NVHPCWRAPNVTX_LIB})
target_include_directories(fiat PRIVATE "${CUDAToolkit_LIBRARY_DIR}/../include")
Expand Down
6 changes: 3 additions & 3 deletions src/fiat/drhook/internal/dr_hook_util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SUBROUTINE DR_HOOK_UTIL(LDHOOK,CDNAME,KCASE,PKEY,CDFILENAME,KSIZEINFO)
USE OML_MOD , ONLY : OML_MY_THREAD
USE YOMHOOK , ONLY : LHOOK
USE DR_HACK_MOD, ONLY : LL_DRHACK, DR_HACK_INIT, DR_HACK
#ifdef __PGI
#ifdef HAVE_DR_NVTX
USE NVTX
USE DR_NVTX
#endif
Expand All @@ -37,13 +37,13 @@ SUBROUTINE DR_HOOK_UTIL(LDHOOK,CDNAME,KCASE,PKEY,CDFILENAME,KSIZEINFO)

#include "dr_hook_init.intfb.h"

#ifdef __PGI
#ifdef HAVE_DR_NVTX
INTEGER, SAVE :: II_DRNVTX = 0 ! 0=no initialized, -1=nvtx off, +1=nvtx on
CHARACTER*32 :: CL_NVTX
#endif


#ifdef __PGI
#ifdef HAVE_DR_NVTX
IF (II_DRNVTX == 0) THEN
CALL GETENV ('DR_NVTX', CL_NVTX)
IF (CL_NVTX == '1') THEN
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 453b148

Please sign in to comment.