SWDEV-483130: Replace calls to deprecated functions hipHostMalloc/hipHostFree (#1070)

* SWDEV-483130: Replace calls to deprecated functions hipHostMalloc/hipHostFree

* SWDEV-483130: Replace calls to deprecated functions hipHostMalloc/hipHostFree. Moved definitions from lib/commons/defines.hpp to samples/common/defines.hpp and tests/common/defines.hpp

* Updated comment for clarity

* Update tests/rocprofv3/aborted-app/validate.py

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Formatting

* Formatting

* Updated CHANGELOG

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
itrowbri
2024-09-12 18:31:00 -05:00
committed by GitHub
parent efbe4ea0a2
commit 8d7be2e4b4
16 changed files with 63 additions and 26 deletions
+2 -1
View File
@@ -39,4 +39,5 @@ target_compile_options(scratch-memory PRIVATE -W -Wall -Wextra -Wpedantic -Wshad
-Werror)
find_package(Threads REQUIRED)
target_link_libraries(scratch-memory PRIVATE Threads::Threads hsa-runtime64)
target_link_libraries(scratch-memory PRIVATE Threads::Threads hsa-runtime64
rocprofiler-sdk::tests-common-library)
+3 -1
View File
@@ -27,6 +27,8 @@
#include <iostream>
#include <vector>
#include "common/defines.hpp"
#define hipCheckErr(errval) \
do \
{ \
@@ -166,7 +168,7 @@ int
test_scratch()
{
uint64_t* data_ptr;
hipCheckErr(hipHostMalloc(&data_ptr, sizeof(uint64_t), 0));
hipCheckErr(HIP_HOST_ALLOC_FUNC(&data_ptr, sizeof(uint64_t), 0));
std::vector<float> host_floats(1024);
float* dev;
+2 -1
View File
@@ -38,4 +38,5 @@ target_sources(vector-ops PRIVATE vector-ops.cpp)
target_compile_options(vector-ops PRIVATE -W -Wall -Wextra -Wpedantic -Wshadow -Werror)
find_package(Threads REQUIRED)
target_link_libraries(vector-ops PRIVATE Threads::Threads)
target_link_libraries(vector-ops PRIVATE Threads::Threads
rocprofiler-sdk::tests-common-library)
+8 -6
View File
@@ -31,6 +31,8 @@
#include <mutex>
#include <vector>
#include "common/defines.hpp"
#define HIP_API_CALL(CALL) \
{ \
hipError_t error_ = (CALL); \
@@ -167,9 +169,9 @@ run(int NUM_QUEUE, int DEVICE_ID)
{
HIP_API_CALL(hipStreamCreateWithFlags(&streams[q], hipStreamNonBlocking));
HIP_API_CALL(hipHostMalloc(&hostA[q], NUM * sizeof(float), 0));
HIP_API_CALL(hipHostMalloc(&hostB[q], NUM * sizeof(float), 0));
HIP_API_CALL(hipHostMalloc(&hostC[q], NUM * sizeof(float), 0));
HIP_API_CALL(HIP_HOST_ALLOC_FUNC(&hostA[q], NUM * sizeof(float), 0));
HIP_API_CALL(HIP_HOST_ALLOC_FUNC(&hostB[q], NUM * sizeof(float), 0));
HIP_API_CALL(HIP_HOST_ALLOC_FUNC(&hostC[q], NUM * sizeof(float), 0));
// initialize the input data
for(int i = 0; i < NUM; i++)
@@ -264,9 +266,9 @@ run(int NUM_QUEUE, int DEVICE_ID)
HIP_API_CALL(hipFree(deviceB[q]));
HIP_API_CALL(hipFree(deviceC[q]));
HIP_API_CALL(hipHostFree(hostA[q]));
HIP_API_CALL(hipHostFree(hostB[q]));
HIP_API_CALL(hipHostFree(hostC[q]));
HIP_API_CALL(HIP_HOST_FREE_FUNC(hostA[q]));
HIP_API_CALL(HIP_HOST_FREE_FUNC(hostB[q]));
HIP_API_CALL(HIP_HOST_FREE_FUNC(hostC[q]));
HIP_API_CALL(hipStreamDestroy(streams[q]));
}
+8
View File
@@ -38,3 +38,11 @@
throw std::runtime_error(errmsg.str()); \
} \
}
#if HIP_VERSION >= 60300000
# define HIP_HOST_ALLOC_FUNC hipExtHostAlloc
# define HIP_HOST_FREE_FUNC hipFreeHost
#else
# define HIP_HOST_ALLOC_FUNC hipHostMalloc
# define HIP_HOST_FREE_FUNC hipHostFree
#endif
+2 -1
View File
@@ -41,4 +41,5 @@ target_include_directories(vector-ops-shared-library PUBLIC ${CMAKE_CURRENT_SOUR
set_target_properties(vector-ops-shared-library PROPERTIES OUTPUT_NAME vector-ops)
find_package(Threads REQUIRED)
target_link_libraries(vector-ops-shared-library PRIVATE Threads::Threads)
target_link_libraries(vector-ops-shared-library
PRIVATE Threads::Threads rocprofiler-sdk::tests-common-library)
+8 -6
View File
@@ -30,6 +30,8 @@
#include <mutex>
#include <vector>
#include "common/defines.hpp"
#define HIP_API_CALL(CALL) \
{ \
hipError_t error_ = (CALL); \
@@ -170,9 +172,9 @@ run_vector_ops_impl(int num_queue, int device_id)
{
HIP_API_CALL(hipStreamCreateWithFlags(&streams[q], hipStreamNonBlocking));
HIP_API_CALL(hipHostMalloc(&hostA[q], NUM * sizeof(float), 0));
HIP_API_CALL(hipHostMalloc(&hostB[q], NUM * sizeof(float), 0));
HIP_API_CALL(hipHostMalloc(&hostC[q], NUM * sizeof(float), 0));
HIP_API_CALL(HIP_HOST_ALLOC_FUNC(&hostA[q], NUM * sizeof(float), 0));
HIP_API_CALL(HIP_HOST_ALLOC_FUNC(&hostB[q], NUM * sizeof(float), 0));
HIP_API_CALL(HIP_HOST_ALLOC_FUNC(&hostC[q], NUM * sizeof(float), 0));
// initialize the input data
for(int i = 0; i < NUM; i++)
@@ -253,9 +255,9 @@ run_vector_ops_impl(int num_queue, int device_id)
HIP_API_CALL(hipFree(deviceB[q]));
HIP_API_CALL(hipFree(deviceC[q]));
HIP_API_CALL(hipHostFree(hostA[q]));
HIP_API_CALL(hipHostFree(hostB[q]));
HIP_API_CALL(hipHostFree(hostC[q]));
HIP_API_CALL(HIP_HOST_FREE_FUNC(hostA[q]));
HIP_API_CALL(HIP_HOST_FREE_FUNC(hostB[q]));
HIP_API_CALL(HIP_HOST_FREE_FUNC(hostC[q]));
HIP_API_CALL(hipStreamDestroy(streams[q]));
}
+7 -2
View File
@@ -99,8 +99,13 @@ def test_hip_api_trace_json(json_data):
"hipGetLastError",
]
)
assert functions == expected_functions
# TODO: When tracing support is added for hipExtHostAlloc, replace
# hipHostMalloc with hipExtHostAlloc instead of removing hipHostMalloc
# as is happening currently
updated_expected_functions = [
func for func in expected_functions if func != "hipHostMalloc"
]
assert functions == expected_functions or functions == updated_expected_functions
if __name__ == "__main__":