Skip to content

Commit

Permalink
SWDEV-308763 - Update hiprtc tests to link with hiprtc lib (ROCm#2575)
Browse files Browse the repository at this point in the history
hiprtc is made into a separate lib and hence tests should link with it explicitly during compilation
Also, updates the hiprtc programming guide

Change-Id: Ie1f9d7250d4a8622b77ef92938fc0decbaeb72f9
  • Loading branch information
rocm-ci authored Apr 1, 2022
1 parent 44e0440 commit ef9505d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
11 changes: 10 additions & 1 deletion docs/markdown/hip_rtc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
HIP allows you to compile kernels at runtime with its ```hiprtc*``` APIs.
Kernels can be store as a text string and can be passed on to hiprtc APIs alongside options to guide the compilation.

NOTE:

- This library can be used on systems without HIP install nor AMD GPU driver installed at all (offline compilation). Therefore it does not depend on any HIP runtime library.
- But it does depend on COMGr. We may try to statically link COMGr into hipRTC to avoid any ambiguity.
- Developers can decide to bundle this library with their application.

## Example
To use hiprtc functionality, hiprtc header needs to be included first.
```#include <hip/hiprtc.h>```
Expand Down Expand Up @@ -84,6 +90,9 @@ Please have a look at saxpy.cpp and hiprtcGetLoweredName.cpp files for a detaile
## HIPRTC specific options
HIPRTC provides a few hiprtc specific flags
- ```--gpu-architecture``` : This flag can guide the code object generation for a specific gpu arch. Example: ```--gpu-architecture=gfx906:sramecc+:xnack-```, its equivalent to ```--offload-arch```.
- This option is compulsory if compilation is done on a system without AMD GPUs supported by HIP runtime.
- Otherwise, hipRTC will load the hip runtime and gather the current device and its architecture info and use it as option.

## Deprecation notice
Users will be required to link to libhiprtc.so/libhiprtc.dll in future releases. Currently all symbols are present in libhipamd64.so/libhipamd64.dll and there is a plan in action to separate HIPRTC APIs from HIP APIs.
Currently HIPRTC APIs are separated from HIP APIs and HIPRTC is available as a separate library libhiprtc.so/libhiprtc.dll. But hiprtc symbols are present in libhipamd64.so/libhipamd64.dll in order to support the existing applications. Gradually, these symbols will be removed from HIP library and applications using HIPRTC will be required to explictly link to HIPRTC library.

11 changes: 9 additions & 2 deletions tests/catch/unit/rtc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# AMD Tests
# Common Tests - Test independent of all platforms
set(TEST_SRC
saxpy.cc
warpsize.cc
)

# AMD only tests
set(AMD_TEST_SRC
customOptions.cc
)

if(HIP_PLATFORM MATCHES "nvidia")
hip_add_exe_to_target(NAME RTC
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests
LINKER_LIBS nvrtc)
elseif(HIP_PLATFORM MATCHES "amd")
set(TEST_SRC ${TEST_SRC} ${AMD_TEST_SRC})
hip_add_exe_to_target(NAME RTC
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests)
TEST_TARGET_NAME build_tests
LINKER_LIBS hiprtc)
endif()
4 changes: 2 additions & 2 deletions tests/src/hiprtc/hiprtcGetLoweredName.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
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
Expand All @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* HIT_START
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS -lnvrtc
* BUILD: %t %s ../test_common.cpp HIPCC_OPTIONS -lhiprtc NVCC_OPTIONS -lnvrtc
* TEST: %t
* HIT_END
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/src/hiprtc/saxpy.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
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
Expand All @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* HIT_START
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS -lnvrtc
* BUILD: %t %s ../test_common.cpp HIPCC_OPTIONS -lhiprtc NVCC_OPTIONS -lnvrtc
* TEST: %t
* HIT_END
*/
Expand Down

0 comments on commit ef9505d

Please sign in to comment.