From afefa691da1d9f2eb6b82fce23cc69193b5a673a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 25 Nov 2025 19:14:41 -0700 Subject: [PATCH 01/48] Remove rocfile from formatter --- util/format-source.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/util/format-source.sh b/util/format-source.sh index 1c4c35aa..b1077738 100755 --- a/util/format-source.sh +++ b/util/format-source.sh @@ -9,7 +9,6 @@ COMMAND="clang-format" DIRS=( "hipfile" - "rocfile" ) if [ $# -eq 1 ]; then From b54b3b35b32c5b69548171f4510c1bca0a860e12 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 25 Nov 2025 21:50:35 -0700 Subject: [PATCH 02/48] Move rocFile code to hipFile source tree This still builds separate rocFile and hipFile libraries, but the rocFile code has been moved to the hipFile source tree. rocfile/include/* --> hipfile/include/ rocfile/src/* --> hipfile/src/amd_detail/ rocfile/test/* --> hipfile/test/amd_detail/ The hipfile directory has been left as-is, though it may be renamed in the future (libhipfile?). If we add command-line tools or other code to this repo, it'll be handy to have the library code separated into its own directory. --- CMakeLists.txt | 3 -- hipfile/CMakeLists.txt | 13 ++++++-- {rocfile => hipfile}/include/rocfile.h | 0 hipfile/src/amd_detail/CMakeLists.txt | 28 +++++++++++++++++ .../src => hipfile/src/amd_detail}/async.cpp | 0 .../src => hipfile/src/amd_detail}/async.h | 0 .../src => hipfile/src/amd_detail}/backend.h | 0 .../amd_detail}/backend/asyncop-fallback.cpp | 0 .../amd_detail}/backend/asyncop-fallback.h | 0 .../src/amd_detail}/backend/fallback.cpp | 0 .../src/amd_detail}/backend/fallback.h | 0 .../src/amd_detail}/backend/fastpath.cpp | 0 .../src/amd_detail}/backend/fastpath.h | 0 .../src/amd_detail}/batch/batch.cpp | 0 .../src/amd_detail}/batch/batch.h | 0 .../src => hipfile/src/amd_detail}/buffer.cpp | 0 .../src => hipfile/src/amd_detail}/buffer.h | 0 .../src/amd_detail}/context.cpp | 0 .../src => hipfile/src/amd_detail}/context.h | 0 .../src => hipfile/src/amd_detail}/file.cpp | 0 .../src => hipfile/src/amd_detail}/file.h | 0 .../src => hipfile/src/amd_detail}/hip.cpp | 0 {rocfile/src => hipfile/src/amd_detail}/hip.h | 0 {rocfile/src => hipfile/src/amd_detail}/io.h | 0 .../src/amd_detail}/mountinfo.cpp | 0 .../src/amd_detail}/mountinfo.h | 0 .../src/amd_detail}/rocfile-private.cpp | 0 .../src/amd_detail}/rocfile-private.h | 0 .../src/amd_detail}/rocfile.cpp | 0 .../src => hipfile/src/amd_detail}/state.cpp | 0 .../src => hipfile/src/amd_detail}/state.h | 0 .../src => hipfile/src/amd_detail}/stream.cpp | 0 .../src => hipfile/src/amd_detail}/stream.h | 0 .../src => hipfile/src/amd_detail}/sys.cpp | 0 {rocfile/src => hipfile/src/amd_detail}/sys.h | 0 .../test/amd_detail}/CMakeLists.txt | 0 .../test/amd_detail}/async.cpp | 0 .../test/amd_detail}/batch/batch.cpp | 0 .../test/amd_detail}/batch/batch_mt.cpp | 0 .../test/amd_detail}/buffer.cpp | 0 .../test/amd_detail}/context.cpp | 0 .../test/amd_detail}/driver.cpp | 0 .../test/amd_detail}/fallback.cpp | 0 .../test/amd_detail}/fastpath.cpp | 0 .../test/amd_detail}/handle.cpp | 0 .../test => hipfile/test/amd_detail}/hip.cpp | 0 .../test/amd_detail}/mbackend.h | 0 .../test => hipfile/test/amd_detail}/mbatch.h | 0 .../test/amd_detail}/mbuffer.h | 0 .../test => hipfile/test/amd_detail}/mfile.h | 0 .../test => hipfile/test/amd_detail}/mhip.h | 0 .../test => hipfile/test/amd_detail}/misc.cpp | 0 .../test/amd_detail}/mmountinfo.h | 0 .../test/amd_detail}/mountinfo.cpp | 0 .../test => hipfile/test/amd_detail}/mstate.h | 0 .../test/amd_detail}/mstream.h | 0 .../test => hipfile/test/amd_detail}/msys.h | 0 .../test/amd_detail}/rocfile-test.h | 0 .../test/amd_detail}/rocfile.cpp | 0 .../test/amd_detail}/state_mt.cpp | 0 .../test/amd_detail}/stream.cpp | 0 rocfile/CMakeLists.txt | 19 ------------ rocfile/src/CMakeLists.txt | 31 ------------------- 63 files changed, 39 insertions(+), 55 deletions(-) rename {rocfile => hipfile}/include/rocfile.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/async.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/async.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/backend.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/backend/asyncop-fallback.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/backend/asyncop-fallback.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/backend/fallback.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/backend/fallback.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/backend/fastpath.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/backend/fastpath.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/batch/batch.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/batch/batch.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/buffer.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/buffer.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/context.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/context.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/file.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/file.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/hip.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/hip.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/io.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/mountinfo.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/mountinfo.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/rocfile-private.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/rocfile-private.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/rocfile.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/state.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/state.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/stream.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/stream.h (100%) rename {rocfile/src => hipfile/src/amd_detail}/sys.cpp (100%) rename {rocfile/src => hipfile/src/amd_detail}/sys.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/CMakeLists.txt (100%) rename {rocfile/test => hipfile/test/amd_detail}/async.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/batch/batch.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/batch/batch_mt.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/buffer.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/context.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/driver.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/fallback.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/fastpath.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/handle.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/hip.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/mbackend.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/mbatch.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/mbuffer.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/mfile.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/mhip.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/misc.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/mmountinfo.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/mountinfo.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/mstate.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/mstream.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/msys.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/rocfile-test.h (100%) rename {rocfile/test => hipfile/test/amd_detail}/rocfile.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/state_mt.cpp (100%) rename {rocfile/test => hipfile/test/amd_detail}/stream.cpp (100%) delete mode 100644 rocfile/CMakeLists.txt delete mode 100644 rocfile/src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index a04b0607..fb441259 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,9 +219,6 @@ endif() #----------------------------------------------------------------------------- # Subdirectories to configure/build #----------------------------------------------------------------------------- -if(BUILD_ROCFILE) - add_subdirectory(rocfile) -endif() add_subdirectory(hipfile) if(BUILD_AIS_DOCS) add_subdirectory(docs) diff --git a/hipfile/CMakeLists.txt b/hipfile/CMakeLists.txt index b6fd4e96..68f0a9b0 100644 --- a/hipfile/CMakeLists.txt +++ b/hipfile/CMakeLists.txt @@ -5,13 +5,19 @@ cmake_minimum_required(VERSION 3.21) project("hipfile" DESCRIPTION "hipFile library" LANGUAGES CXX HIP) +project("rocfile" DESCRIPTION "rocFile library" LANGUAGES CXX) -# Set the path to the include directory for later use +# Set the path to the include directories for later use set(HIPFILE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") set(HIPFILE_AMD_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/amd_detail") set(HIPFILE_NVIDIA_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/nvidia_detail") set(HIPFILE_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test") +# Set the path to the include directories for later use +set(ROCFILE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") +set(ROCFILE_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/amd_detail") +set(ROCFILE_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/amd_detail") + # Add the src directory depending on the HIP platform if(CMAKE_HIP_PLATFORM STREQUAL "nvidia") add_subdirectory(src/nvidia_detail) @@ -19,10 +25,13 @@ else() add_subdirectory(src/amd_detail) endif() -# Add the testing directory +# Add the testing directories if(BUILD_TESTING) add_subdirectory(test) endif() +if(BUILD_TESTING AND NOT CMAKE_HIP_PLATFORM STREQUAL "nvidia") + add_subdirectory(test/amd_detail) +endif() # Add the aiscp example directory if(BUILD_AISCP) diff --git a/rocfile/include/rocfile.h b/hipfile/include/rocfile.h similarity index 100% rename from rocfile/include/rocfile.h rename to hipfile/include/rocfile.h diff --git a/hipfile/src/amd_detail/CMakeLists.txt b/hipfile/src/amd_detail/CMakeLists.txt index 650d5c89..4aab3a2f 100644 --- a/hipfile/src/amd_detail/CMakeLists.txt +++ b/hipfile/src/amd_detail/CMakeLists.txt @@ -18,3 +18,31 @@ ais_add_libraries( DEPS rocfile LIBINCL ${HIPFILE_INCLUDE_PATH} ) + +set(ROCFILE_SOURCES + async.cpp + backend/asyncop-fallback.cpp + backend/fallback.cpp + backend/fastpath.cpp + batch/batch.cpp + buffer.cpp + context.cpp + file.cpp + hip.cpp + mountinfo.cpp + rocfile.cpp + rocfile-private.cpp + state.cpp + stream.cpp + sys.cpp +) + +# Will create rocfile_(static|shared) +ais_add_libraries( + NAME rocfile + DETAIL amd + SRCS ${ROCFILE_SOURCES} + LIBINCL ${ROCFILE_INCLUDE_PATH} + SYSINCLS ${ROCFILE_SOURCE_PATH} + LIBS mount +) diff --git a/rocfile/src/async.cpp b/hipfile/src/amd_detail/async.cpp similarity index 100% rename from rocfile/src/async.cpp rename to hipfile/src/amd_detail/async.cpp diff --git a/rocfile/src/async.h b/hipfile/src/amd_detail/async.h similarity index 100% rename from rocfile/src/async.h rename to hipfile/src/amd_detail/async.h diff --git a/rocfile/src/backend.h b/hipfile/src/amd_detail/backend.h similarity index 100% rename from rocfile/src/backend.h rename to hipfile/src/amd_detail/backend.h diff --git a/rocfile/src/backend/asyncop-fallback.cpp b/hipfile/src/amd_detail/backend/asyncop-fallback.cpp similarity index 100% rename from rocfile/src/backend/asyncop-fallback.cpp rename to hipfile/src/amd_detail/backend/asyncop-fallback.cpp diff --git a/rocfile/src/backend/asyncop-fallback.h b/hipfile/src/amd_detail/backend/asyncop-fallback.h similarity index 100% rename from rocfile/src/backend/asyncop-fallback.h rename to hipfile/src/amd_detail/backend/asyncop-fallback.h diff --git a/rocfile/src/backend/fallback.cpp b/hipfile/src/amd_detail/backend/fallback.cpp similarity index 100% rename from rocfile/src/backend/fallback.cpp rename to hipfile/src/amd_detail/backend/fallback.cpp diff --git a/rocfile/src/backend/fallback.h b/hipfile/src/amd_detail/backend/fallback.h similarity index 100% rename from rocfile/src/backend/fallback.h rename to hipfile/src/amd_detail/backend/fallback.h diff --git a/rocfile/src/backend/fastpath.cpp b/hipfile/src/amd_detail/backend/fastpath.cpp similarity index 100% rename from rocfile/src/backend/fastpath.cpp rename to hipfile/src/amd_detail/backend/fastpath.cpp diff --git a/rocfile/src/backend/fastpath.h b/hipfile/src/amd_detail/backend/fastpath.h similarity index 100% rename from rocfile/src/backend/fastpath.h rename to hipfile/src/amd_detail/backend/fastpath.h diff --git a/rocfile/src/batch/batch.cpp b/hipfile/src/amd_detail/batch/batch.cpp similarity index 100% rename from rocfile/src/batch/batch.cpp rename to hipfile/src/amd_detail/batch/batch.cpp diff --git a/rocfile/src/batch/batch.h b/hipfile/src/amd_detail/batch/batch.h similarity index 100% rename from rocfile/src/batch/batch.h rename to hipfile/src/amd_detail/batch/batch.h diff --git a/rocfile/src/buffer.cpp b/hipfile/src/amd_detail/buffer.cpp similarity index 100% rename from rocfile/src/buffer.cpp rename to hipfile/src/amd_detail/buffer.cpp diff --git a/rocfile/src/buffer.h b/hipfile/src/amd_detail/buffer.h similarity index 100% rename from rocfile/src/buffer.h rename to hipfile/src/amd_detail/buffer.h diff --git a/rocfile/src/context.cpp b/hipfile/src/amd_detail/context.cpp similarity index 100% rename from rocfile/src/context.cpp rename to hipfile/src/amd_detail/context.cpp diff --git a/rocfile/src/context.h b/hipfile/src/amd_detail/context.h similarity index 100% rename from rocfile/src/context.h rename to hipfile/src/amd_detail/context.h diff --git a/rocfile/src/file.cpp b/hipfile/src/amd_detail/file.cpp similarity index 100% rename from rocfile/src/file.cpp rename to hipfile/src/amd_detail/file.cpp diff --git a/rocfile/src/file.h b/hipfile/src/amd_detail/file.h similarity index 100% rename from rocfile/src/file.h rename to hipfile/src/amd_detail/file.h diff --git a/rocfile/src/hip.cpp b/hipfile/src/amd_detail/hip.cpp similarity index 100% rename from rocfile/src/hip.cpp rename to hipfile/src/amd_detail/hip.cpp diff --git a/rocfile/src/hip.h b/hipfile/src/amd_detail/hip.h similarity index 100% rename from rocfile/src/hip.h rename to hipfile/src/amd_detail/hip.h diff --git a/rocfile/src/io.h b/hipfile/src/amd_detail/io.h similarity index 100% rename from rocfile/src/io.h rename to hipfile/src/amd_detail/io.h diff --git a/rocfile/src/mountinfo.cpp b/hipfile/src/amd_detail/mountinfo.cpp similarity index 100% rename from rocfile/src/mountinfo.cpp rename to hipfile/src/amd_detail/mountinfo.cpp diff --git a/rocfile/src/mountinfo.h b/hipfile/src/amd_detail/mountinfo.h similarity index 100% rename from rocfile/src/mountinfo.h rename to hipfile/src/amd_detail/mountinfo.h diff --git a/rocfile/src/rocfile-private.cpp b/hipfile/src/amd_detail/rocfile-private.cpp similarity index 100% rename from rocfile/src/rocfile-private.cpp rename to hipfile/src/amd_detail/rocfile-private.cpp diff --git a/rocfile/src/rocfile-private.h b/hipfile/src/amd_detail/rocfile-private.h similarity index 100% rename from rocfile/src/rocfile-private.h rename to hipfile/src/amd_detail/rocfile-private.h diff --git a/rocfile/src/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp similarity index 100% rename from rocfile/src/rocfile.cpp rename to hipfile/src/amd_detail/rocfile.cpp diff --git a/rocfile/src/state.cpp b/hipfile/src/amd_detail/state.cpp similarity index 100% rename from rocfile/src/state.cpp rename to hipfile/src/amd_detail/state.cpp diff --git a/rocfile/src/state.h b/hipfile/src/amd_detail/state.h similarity index 100% rename from rocfile/src/state.h rename to hipfile/src/amd_detail/state.h diff --git a/rocfile/src/stream.cpp b/hipfile/src/amd_detail/stream.cpp similarity index 100% rename from rocfile/src/stream.cpp rename to hipfile/src/amd_detail/stream.cpp diff --git a/rocfile/src/stream.h b/hipfile/src/amd_detail/stream.h similarity index 100% rename from rocfile/src/stream.h rename to hipfile/src/amd_detail/stream.h diff --git a/rocfile/src/sys.cpp b/hipfile/src/amd_detail/sys.cpp similarity index 100% rename from rocfile/src/sys.cpp rename to hipfile/src/amd_detail/sys.cpp diff --git a/rocfile/src/sys.h b/hipfile/src/amd_detail/sys.h similarity index 100% rename from rocfile/src/sys.h rename to hipfile/src/amd_detail/sys.h diff --git a/rocfile/test/CMakeLists.txt b/hipfile/test/amd_detail/CMakeLists.txt similarity index 100% rename from rocfile/test/CMakeLists.txt rename to hipfile/test/amd_detail/CMakeLists.txt diff --git a/rocfile/test/async.cpp b/hipfile/test/amd_detail/async.cpp similarity index 100% rename from rocfile/test/async.cpp rename to hipfile/test/amd_detail/async.cpp diff --git a/rocfile/test/batch/batch.cpp b/hipfile/test/amd_detail/batch/batch.cpp similarity index 100% rename from rocfile/test/batch/batch.cpp rename to hipfile/test/amd_detail/batch/batch.cpp diff --git a/rocfile/test/batch/batch_mt.cpp b/hipfile/test/amd_detail/batch/batch_mt.cpp similarity index 100% rename from rocfile/test/batch/batch_mt.cpp rename to hipfile/test/amd_detail/batch/batch_mt.cpp diff --git a/rocfile/test/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp similarity index 100% rename from rocfile/test/buffer.cpp rename to hipfile/test/amd_detail/buffer.cpp diff --git a/rocfile/test/context.cpp b/hipfile/test/amd_detail/context.cpp similarity index 100% rename from rocfile/test/context.cpp rename to hipfile/test/amd_detail/context.cpp diff --git a/rocfile/test/driver.cpp b/hipfile/test/amd_detail/driver.cpp similarity index 100% rename from rocfile/test/driver.cpp rename to hipfile/test/amd_detail/driver.cpp diff --git a/rocfile/test/fallback.cpp b/hipfile/test/amd_detail/fallback.cpp similarity index 100% rename from rocfile/test/fallback.cpp rename to hipfile/test/amd_detail/fallback.cpp diff --git a/rocfile/test/fastpath.cpp b/hipfile/test/amd_detail/fastpath.cpp similarity index 100% rename from rocfile/test/fastpath.cpp rename to hipfile/test/amd_detail/fastpath.cpp diff --git a/rocfile/test/handle.cpp b/hipfile/test/amd_detail/handle.cpp similarity index 100% rename from rocfile/test/handle.cpp rename to hipfile/test/amd_detail/handle.cpp diff --git a/rocfile/test/hip.cpp b/hipfile/test/amd_detail/hip.cpp similarity index 100% rename from rocfile/test/hip.cpp rename to hipfile/test/amd_detail/hip.cpp diff --git a/rocfile/test/mbackend.h b/hipfile/test/amd_detail/mbackend.h similarity index 100% rename from rocfile/test/mbackend.h rename to hipfile/test/amd_detail/mbackend.h diff --git a/rocfile/test/mbatch.h b/hipfile/test/amd_detail/mbatch.h similarity index 100% rename from rocfile/test/mbatch.h rename to hipfile/test/amd_detail/mbatch.h diff --git a/rocfile/test/mbuffer.h b/hipfile/test/amd_detail/mbuffer.h similarity index 100% rename from rocfile/test/mbuffer.h rename to hipfile/test/amd_detail/mbuffer.h diff --git a/rocfile/test/mfile.h b/hipfile/test/amd_detail/mfile.h similarity index 100% rename from rocfile/test/mfile.h rename to hipfile/test/amd_detail/mfile.h diff --git a/rocfile/test/mhip.h b/hipfile/test/amd_detail/mhip.h similarity index 100% rename from rocfile/test/mhip.h rename to hipfile/test/amd_detail/mhip.h diff --git a/rocfile/test/misc.cpp b/hipfile/test/amd_detail/misc.cpp similarity index 100% rename from rocfile/test/misc.cpp rename to hipfile/test/amd_detail/misc.cpp diff --git a/rocfile/test/mmountinfo.h b/hipfile/test/amd_detail/mmountinfo.h similarity index 100% rename from rocfile/test/mmountinfo.h rename to hipfile/test/amd_detail/mmountinfo.h diff --git a/rocfile/test/mountinfo.cpp b/hipfile/test/amd_detail/mountinfo.cpp similarity index 100% rename from rocfile/test/mountinfo.cpp rename to hipfile/test/amd_detail/mountinfo.cpp diff --git a/rocfile/test/mstate.h b/hipfile/test/amd_detail/mstate.h similarity index 100% rename from rocfile/test/mstate.h rename to hipfile/test/amd_detail/mstate.h diff --git a/rocfile/test/mstream.h b/hipfile/test/amd_detail/mstream.h similarity index 100% rename from rocfile/test/mstream.h rename to hipfile/test/amd_detail/mstream.h diff --git a/rocfile/test/msys.h b/hipfile/test/amd_detail/msys.h similarity index 100% rename from rocfile/test/msys.h rename to hipfile/test/amd_detail/msys.h diff --git a/rocfile/test/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h similarity index 100% rename from rocfile/test/rocfile-test.h rename to hipfile/test/amd_detail/rocfile-test.h diff --git a/rocfile/test/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp similarity index 100% rename from rocfile/test/rocfile.cpp rename to hipfile/test/amd_detail/rocfile.cpp diff --git a/rocfile/test/state_mt.cpp b/hipfile/test/amd_detail/state_mt.cpp similarity index 100% rename from rocfile/test/state_mt.cpp rename to hipfile/test/amd_detail/state_mt.cpp diff --git a/rocfile/test/stream.cpp b/hipfile/test/amd_detail/stream.cpp similarity index 100% rename from rocfile/test/stream.cpp rename to hipfile/test/amd_detail/stream.cpp diff --git a/rocfile/CMakeLists.txt b/rocfile/CMakeLists.txt deleted file mode 100644 index 63e75826..00000000 --- a/rocfile/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) Advanced Micro Devices, Inc. All rights reserved. -# -# SPDX-License-Identifier: MIT - -cmake_minimum_required(VERSION 3.17) - -project("rocfile" DESCRIPTION "rocFile library" LANGUAGES CXX) - -# Set the path to the include directory for later use -set(ROCFILE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") -set(ROCFILE_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src") -set(ROCFILE_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test") - -add_subdirectory(src) - -# Add the testing directory -if(BUILD_TESTING) - add_subdirectory(test) -endif() diff --git a/rocfile/src/CMakeLists.txt b/rocfile/src/CMakeLists.txt deleted file mode 100644 index 42ff398b..00000000 --- a/rocfile/src/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) Advanced Micro Devices, Inc. All rights reserved. -# -# SPDX-License-Identifier: MIT - -set(ROCFILE_SOURCES - async.cpp - backend/asyncop-fallback.cpp - backend/fallback.cpp - backend/fastpath.cpp - batch/batch.cpp - buffer.cpp - context.cpp - file.cpp - hip.cpp - mountinfo.cpp - rocfile.cpp - rocfile-private.cpp - state.cpp - stream.cpp - sys.cpp -) - -# Will create rocfile_(static|shared) -ais_add_libraries( - NAME rocfile - DETAIL amd - SRCS ${ROCFILE_SOURCES} - LIBINCL ${ROCFILE_INCLUDE_PATH} - SYSINCLS ${ROCFILE_SOURCE_PATH} - LIBS mount -) From 21a949da61273ef037dfc5aa21171273b5b1d6f0 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 25 Nov 2025 22:17:44 -0700 Subject: [PATCH 03/48] Clean up CMake code Replaces a lot of HIP platform string comparisons with a variable that gets set early and cleans up a few other things. --- CMakeLists.txt | 22 +++++++++++----------- cmake/AISCompilerOptions.cmake | 2 +- cmake/AISInstall.cmake | 11 ++--------- docs/CMakeLists.txt | 2 +- hipfile/CMakeLists.txt | 4 ++-- hipfile/test/CMakeLists.txt | 8 ++++---- 6 files changed, 21 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb441259..401c5dc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,15 @@ if(NOT CMAKE_HIP_PLATFORM STREQUAL "amd" AND NOT CMAKE_HIP_PLATFORM STREQUAL "nv message(FATAL_ERROR "Invalid CMAKE_HIP_PLATFORM: '${CMAKE_HIP_PLATFORM}'. Allowed values are 'amd' or 'nvidia'.") endif() +# Set the platform variable +if(CMAKE_HIP_PLATFORM STREQUAL "nvidia") + set(BUILD_AMD_DETAIL OFF) + set(BUILD_NVIDIA_DETAIL ON) +else() + set(BUILD_AMD_DETAIL ON) + set(BUILD_NVIDIA_DETAIL OFF) +endif() + #----------------------------------------------------------------------------- # Include our custom CMake code in the module path #----------------------------------------------------------------------------- @@ -156,15 +165,6 @@ include(AISIWYU) #------------------- include(AISSanitizers) -#------------------- -# Platform defaults -#------------------- -if(CMAKE_HIP_PLATFORM STREQUAL "nvidia") - set(BUILD_ROCFILE OFF) -else() - set(BUILD_ROCFILE ON) -endif() - #----------------------- # aiscp example program #----------------------- @@ -194,10 +194,10 @@ else() endif() # Find the cuFile library and headers on NVIDIA -if(CMAKE_HIP_PLATFORM STREQUAL "nvidia") +if(BUILD_NVIDIA_DETAIL) find_package(CUDAToolkit REQUIRED) - if(CMAKE_HIP_PLATFORM STREQUAL "nvidia" AND CMAKE_VERSION VERSION_LESS "3.28") + if(CMAKE_VERSION VERSION_LESS "3.28") enable_language(CUDA) # Set a default architecture if not provided. if(NOT CMAKE_CUDA_ARCHITECTURES) diff --git a/cmake/AISCompilerOptions.cmake b/cmake/AISCompilerOptions.cmake index fc49b389..354a9887 100644 --- a/cmake/AISCompilerOptions.cmake +++ b/cmake/AISCompilerOptions.cmake @@ -12,7 +12,7 @@ function(ais_set_compiler_flags target) foreach(source IN LISTS sources) get_source_file_property(language ${source} LANGUAGE) # CMake HIP language prior to 3.28 only supports AMD, so change LANGUAGE to CUDA for HIP files - if(CMAKE_HIP_PLATFORM STREQUAL "nvidia" AND CMAKE_VERSION VERSION_LESS "3.28" AND language STREQUAL HIP) + if(BUILD_NVIDIA_DETAIL AND CMAKE_VERSION VERSION_LESS "3.28" AND language STREQUAL HIP) set_source_files_properties(${source} PROPERTIES LANGUAGE "CUDA") set(language CUDA) message(STATUS "Setting ${source} LANGUAGE to CUDA because CMake < 3.28") diff --git a/cmake/AISInstall.cmake b/cmake/AISInstall.cmake index 78466306..d5d7868a 100644 --- a/cmake/AISInstall.cmake +++ b/cmake/AISInstall.cmake @@ -8,9 +8,8 @@ include(ROCMInstallTargets) include(ROCMCreatePackage) - # Install the package -if(BUILD_ROCFILE) +if(BUILD_AMD_DETAIL) rocm_install(TARGETS rocfile_static) rocm_install(TARGETS rocfile_shared) endif() @@ -18,12 +17,6 @@ rocm_install(TARGETS hipfile_static) rocm_install(TARGETS hipfile_shared) # Install the headers -if(BUILD_ROCFILE) - rocm_install( - DIRECTORY ${CMAKE_SOURCE_DIR}/rocfile/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ) -endif() rocm_install( DIRECTORY ${CMAKE_SOURCE_DIR}/hipfile/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} @@ -39,7 +32,7 @@ rocm_install( # when we have dependencies # Export the targets -if(BUILD_ROCFILE) +if(BUILD_AMD_DETAIL) set(target_list ${target_list} roc::rocfile_shared roc::rocfile_static) endif() set(target_list ${target_list} roc::hipfile_shared roc::hipfile_static) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 4f959805..7503ae60 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -52,6 +52,6 @@ function(ais_add_docs_target AIS_DOC_PRETTY_NAME) endfunction() ais_add_docs_target("hipFile") -if(BUILD_ROCFILE) +if(BUILD_AMD_DETAIL) ais_add_docs_target("rocFile") endif() diff --git a/hipfile/CMakeLists.txt b/hipfile/CMakeLists.txt index 68f0a9b0..ec18eb2c 100644 --- a/hipfile/CMakeLists.txt +++ b/hipfile/CMakeLists.txt @@ -19,7 +19,7 @@ set(ROCFILE_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/amd_detail") set(ROCFILE_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/amd_detail") # Add the src directory depending on the HIP platform -if(CMAKE_HIP_PLATFORM STREQUAL "nvidia") +if(BUILD_NVIDIA_DETAIL) add_subdirectory(src/nvidia_detail) else() add_subdirectory(src/amd_detail) @@ -29,7 +29,7 @@ endif() if(BUILD_TESTING) add_subdirectory(test) endif() -if(BUILD_TESTING AND NOT CMAKE_HIP_PLATFORM STREQUAL "nvidia") +if(BUILD_AMD_DETAIL) add_subdirectory(test/amd_detail) endif() diff --git a/hipfile/test/CMakeLists.txt b/hipfile/test/CMakeLists.txt index dc2a7ea5..8cefa051 100644 --- a/hipfile/test/CMakeLists.txt +++ b/hipfile/test/CMakeLists.txt @@ -37,10 +37,10 @@ set(TEST_SYSINCLS ${SHARED_TEST_INCLUDE_PATH} ) -if(CMAKE_HIP_PLATFORM STREQUAL "nvidia") +if(BUILD_NVIDIA_DETAIL) list(APPEND UNIT_TEST_SOURCE_FILES hipfile-cufile.cpp) list(APPEND TEST_SYSINCLS ${HIPFILE_NVIDIA_SOURCE_PATH}) -elseif(CMAKE_HIP_PLATFORM STREQUAL "amd") +else() list(APPEND UNIT_TEST_SOURCE_FILES hipfile-rocfile.cpp) list(APPEND TEST_SYSINCLS ${HIPFILE_AMD_SOURCE_PATH}) endif() @@ -56,7 +56,7 @@ target_compile_options(hipfile_tests ) target_link_libraries(hipfile_tests PRIVATE GTest::gtest) target_link_libraries(hipfile_tests PRIVATE GTest::gtest_main) -if(CMAKE_HIP_PLATFORM STREQUAL "amd") +if(BUILD_AMD_DETAIL) target_link_libraries(hipfile_tests PRIVATE rocfile_shared) endif() @@ -74,7 +74,7 @@ ais_add_executable( ) target_link_libraries(hipfile_system_tests PRIVATE GTest::gtest) target_link_libraries(hipfile_system_tests PRIVATE Boost::program_options) -if(CMAKE_HIP_PLATFORM STREQUAL "amd") +if(BUILD_AMD_DETAIL) target_link_libraries(hipfile_system_tests PRIVATE rocfile_shared) endif() From 19c7b6beddcfe84c21cff9acb1c64683821b8df6 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 25 Nov 2025 22:56:38 -0700 Subject: [PATCH 04/48] Remove the rocFile library target We only build hipFile now. All former rocFile code is now built with hipFile. The rocFile API is still exposed at this time. --- cmake/AISAddExecutable.cmake | 6 +++--- cmake/AISAddLibraries.cmake | 22 +--------------------- cmake/AISInstall.cmake | 7 ------- docs/CMakeLists.txt | 3 --- hipfile/CMakeLists.txt | 9 ++------- hipfile/src/amd_detail/CMakeLists.txt | 26 +++++++------------------- hipfile/test/CMakeLists.txt | 6 ------ hipfile/test/amd_detail/CMakeLists.txt | 17 +++++++++-------- 8 files changed, 22 insertions(+), 74 deletions(-) diff --git a/cmake/AISAddExecutable.cmake b/cmake/AISAddExecutable.cmake index d0e794ba..38b0af79 100644 --- a/cmake/AISAddExecutable.cmake +++ b/cmake/AISAddExecutable.cmake @@ -15,9 +15,9 @@ include(AISCompilerOptions) # NOTE: Assumes AIS target libraries are named _(static|shared) # # NOTE: This isn't the most robust function. It's mainly intended -# to reduce code duplication in rocFile/hipFile. For example, -# DEPS is for passing the rocFile dependency to hipFile and -# won't work for passing general library dependencies. +# to reduce code duplication. For example, DEPS is for passing +# the hipFile shared/static dependency and won't work for passing +# general library dependencies. function(ais_add_executable) # Parse arguments diff --git a/cmake/AISAddLibraries.cmake b/cmake/AISAddLibraries.cmake index 4d7add76..9913bb34 100644 --- a/cmake/AISAddLibraries.cmake +++ b/cmake/AISAddLibraries.cmake @@ -13,21 +13,13 @@ include(CheckLinkerFlag) # LIBINCL Path to installed include files (e.g., hipfile.h) # SYSINCLS [path1 [path2 ...]] Paths to other include dirs # SRCS [src1 [src2 ...]] The source files -# DEPS [dependency1 [dependency2 ...]] List of AIS target library dependencies # LIBS [lib1, [lib2 ...]] List of external library dependencies -# -# NOTE: Assumes internal library dependencies are named _(static|shared) -# -# NOTE: This isn't the most robust function. It's mainly intended to reduce -# code duplication in rocFile/hipFile. For example, DEPS is for passing -# the rocFile internal library dependency to hipFile and won't work for -# passing general library dependencies. function(ais_add_libraries) # Parse arguments set(options) # None at this time set(oneValueArgs NAME DETAIL LIBINCL) - set(multiValueArgs SRCS DEPS SYSINCLS LIBS) + set(multiValueArgs SRCS SYSINCLS LIBS) cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) # Convenience names @@ -48,18 +40,6 @@ function(ais_add_libraries) set_target_properties(${shared_name} PROPERTIES VERSION ${AIS_LIBRARY_VERSION}) set_target_properties(${shared_name} PROPERTIES SOVERSION ${AIS_LIBRARY_SOVERSION}) - # Add dependencies on internal targets - foreach(dep IN LISTS arg_DEPS) - add_dependencies(${static_name} "${dep}_static") - add_dependencies(${shared_name} "${dep}_shared") - - target_link_libraries(${static_name} PRIVATE "${dep}_static") - target_link_libraries(${shared_name} PRIVATE "${dep}_shared") - - # The object library needs to see the headers for any dependencies - target_link_libraries(${object_name} PUBLIC "${dep}_shared") - endforeach() - # Add dependencies on external libraries foreach(lib IN LISTS arg_LIBS) find_library(LIBRARY_PATH NAMES ${lib}) diff --git a/cmake/AISInstall.cmake b/cmake/AISInstall.cmake index d5d7868a..e6792dbe 100644 --- a/cmake/AISInstall.cmake +++ b/cmake/AISInstall.cmake @@ -9,10 +9,6 @@ include(ROCMInstallTargets) include(ROCMCreatePackage) # Install the package -if(BUILD_AMD_DETAIL) - rocm_install(TARGETS rocfile_static) - rocm_install(TARGETS rocfile_shared) -endif() rocm_install(TARGETS hipfile_static) rocm_install(TARGETS hipfile_shared) @@ -32,9 +28,6 @@ rocm_install( # when we have dependencies # Export the targets -if(BUILD_AMD_DETAIL) - set(target_list ${target_list} roc::rocfile_shared roc::rocfile_static) -endif() set(target_list ${target_list} roc::hipfile_shared roc::hipfile_static) rocm_export_targets( diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 7503ae60..d8c2d3ac 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -52,6 +52,3 @@ function(ais_add_docs_target AIS_DOC_PRETTY_NAME) endfunction() ais_add_docs_target("hipFile") -if(BUILD_AMD_DETAIL) - ais_add_docs_target("rocFile") -endif() diff --git a/hipfile/CMakeLists.txt b/hipfile/CMakeLists.txt index ec18eb2c..39d919f1 100644 --- a/hipfile/CMakeLists.txt +++ b/hipfile/CMakeLists.txt @@ -5,18 +5,13 @@ cmake_minimum_required(VERSION 3.21) project("hipfile" DESCRIPTION "hipFile library" LANGUAGES CXX HIP) -project("rocfile" DESCRIPTION "rocFile library" LANGUAGES CXX) # Set the path to the include directories for later use set(HIPFILE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") set(HIPFILE_AMD_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/amd_detail") set(HIPFILE_NVIDIA_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/nvidia_detail") set(HIPFILE_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test") - -# Set the path to the include directories for later use -set(ROCFILE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") -set(ROCFILE_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/amd_detail") -set(ROCFILE_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/amd_detail") +set(HIPFILE_AMD_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/amd_detail") # Add the src directory depending on the HIP platform if(BUILD_NVIDIA_DETAIL) @@ -29,7 +24,7 @@ endif() if(BUILD_TESTING) add_subdirectory(test) endif() -if(BUILD_AMD_DETAIL) +if(BUILD_TESTING AND BUILD_AMD_DETAIL) add_subdirectory(test/amd_detail) endif() diff --git a/hipfile/src/amd_detail/CMakeLists.txt b/hipfile/src/amd_detail/CMakeLists.txt index 4aab3a2f..78b2a622 100644 --- a/hipfile/src/amd_detail/CMakeLists.txt +++ b/hipfile/src/amd_detail/CMakeLists.txt @@ -5,21 +5,7 @@ # ROCm-backed hipFile set(HIPFILE_SOURCES - hipfile.cpp - hipfile-rocfile.cpp ../common/hipfile-common.cpp -) - -# Will create hipfile_(static|shared) -ais_add_libraries( - NAME hipfile - DETAIL amd - SRCS ${HIPFILE_SOURCES} - DEPS rocfile - LIBINCL ${HIPFILE_INCLUDE_PATH} -) - -set(ROCFILE_SOURCES async.cpp backend/asyncop-fallback.cpp backend/fallback.cpp @@ -29,6 +15,8 @@ set(ROCFILE_SOURCES context.cpp file.cpp hip.cpp + hipfile.cpp + hipfile-rocfile.cpp mountinfo.cpp rocfile.cpp rocfile-private.cpp @@ -37,12 +25,12 @@ set(ROCFILE_SOURCES sys.cpp ) -# Will create rocfile_(static|shared) +# Will create hipfile_(static|shared) ais_add_libraries( - NAME rocfile + NAME hipfile DETAIL amd - SRCS ${ROCFILE_SOURCES} - LIBINCL ${ROCFILE_INCLUDE_PATH} - SYSINCLS ${ROCFILE_SOURCE_PATH} LIBS mount + SRCS ${HIPFILE_SOURCES} + LIBINCL ${HIPFILE_INCLUDE_PATH} + SYSINCLS ${HIPFILE_AMD_SOURCE_PATH} ) diff --git a/hipfile/test/CMakeLists.txt b/hipfile/test/CMakeLists.txt index 8cefa051..72644986 100644 --- a/hipfile/test/CMakeLists.txt +++ b/hipfile/test/CMakeLists.txt @@ -56,9 +56,6 @@ target_compile_options(hipfile_tests ) target_link_libraries(hipfile_tests PRIVATE GTest::gtest) target_link_libraries(hipfile_tests PRIVATE GTest::gtest_main) -if(BUILD_AMD_DETAIL) - target_link_libraries(hipfile_tests PRIVATE rocfile_shared) -endif() ais_gtest_discover_tests( hipfile_tests @@ -74,9 +71,6 @@ ais_add_executable( ) target_link_libraries(hipfile_system_tests PRIVATE GTest::gtest) target_link_libraries(hipfile_system_tests PRIVATE Boost::program_options) -if(BUILD_AMD_DETAIL) - target_link_libraries(hipfile_system_tests PRIVATE rocfile_shared) -endif() gtest_discover_tests( hipfile_system_tests diff --git a/hipfile/test/amd_detail/CMakeLists.txt b/hipfile/test/amd_detail/CMakeLists.txt index caeba059..fc12fac1 100644 --- a/hipfile/test/amd_detail/CMakeLists.txt +++ b/hipfile/test/amd_detail/CMakeLists.txt @@ -30,15 +30,16 @@ set(TEST_SOURCE_FILES ) set(TEST_SYSINCLS - ${ROCFILE_SOURCE_PATH} - ${ROCFILE_INCLUDE_PATH} - ${ROCFILE_TEST_PATH} + ${HIPFILE_AMD_SOURCE_PATH} + ${HIPFILE_INCLUDE_PATH} + ${HIPFILE_TEST_PATH} + ${HIPFILE_AMD_TEST_PATH} ${SHARED_TEST_INCLUDE_PATH} ) ais_add_executable( NAME rocfile_tests - DEPS rocfile_shared + DEPS hipfile_shared SRCS ${TEST_SOURCE_FILES} ${SHARED_SOURCE_FILES} SYSINCLS ${TEST_SYSINCLS} ) @@ -63,9 +64,9 @@ ais_gtest_discover_tests( ais_add_executable( NAME state_mt - DEPS rocfile_shared + DEPS hipfile_shared SRCS "state_mt.cpp" - SYSINCLS ${ROCFILE_SOURCE_PATH} ${ROCFILE_INCLUDE_PATH} + SYSINCLS ${HIPFILE_AMD_SOURCE_PATH} ${HIPFILE_INCLUDE_PATH} ) add_test( NAME state_mt_test @@ -75,9 +76,9 @@ set_tests_properties(state_mt_test PROPERTIES LABELS "stress;rocfile") ais_add_executable( NAME batch_mt - DEPS rocfile_shared + DEPS hipfile_shared SRCS "batch/batch_mt.cpp" - SYSINCLS ${ROCFILE_SOURCE_PATH} ${ROCFILE_INCLUDE_PATH} + SYSINCLS ${HIPFILE_AMD_SOURCE_PATH} ${HIPFILE_INCLUDE_PATH} ) add_test( NAME batch_mt_test From da18ec4f0c2069ba0f69d0b1a7eedc80cf0737e6 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 25 Nov 2025 23:15:28 -0700 Subject: [PATCH 05/48] Remove the rocFile namespace Everything moved to the hipFile namespace --- hipfile/src/amd_detail/async.cpp | 8 ++++---- hipfile/src/amd_detail/async.h | 10 +++++----- hipfile/src/amd_detail/backend.h | 2 +- hipfile/src/amd_detail/backend/asyncop-fallback.cpp | 8 ++++---- hipfile/src/amd_detail/backend/asyncop-fallback.h | 10 +++++----- hipfile/src/amd_detail/backend/fallback.cpp | 4 ++-- hipfile/src/amd_detail/backend/fallback.h | 8 ++++---- hipfile/src/amd_detail/backend/fastpath.cpp | 2 +- hipfile/src/amd_detail/backend/fastpath.h | 8 ++++---- hipfile/src/amd_detail/batch/batch.cpp | 2 +- hipfile/src/amd_detail/batch/batch.h | 6 +++--- hipfile/src/amd_detail/buffer.cpp | 2 +- hipfile/src/amd_detail/buffer.h | 2 +- hipfile/src/amd_detail/context.cpp | 2 +- hipfile/src/amd_detail/context.h | 2 +- hipfile/src/amd_detail/file.cpp | 2 +- hipfile/src/amd_detail/file.h | 2 +- hipfile/src/amd_detail/hip.cpp | 2 +- hipfile/src/amd_detail/hip.h | 2 +- hipfile/src/amd_detail/io.h | 2 +- hipfile/src/amd_detail/mountinfo.cpp | 2 +- hipfile/src/amd_detail/mountinfo.h | 2 +- hipfile/src/amd_detail/rocfile-private.cpp | 2 +- hipfile/src/amd_detail/rocfile-private.h | 6 +++--- hipfile/src/amd_detail/rocfile.cpp | 2 +- hipfile/src/amd_detail/state.cpp | 4 ++-- hipfile/src/amd_detail/state.h | 4 ++-- hipfile/src/amd_detail/stream.cpp | 2 +- hipfile/src/amd_detail/stream.h | 2 +- hipfile/src/amd_detail/sys.cpp | 2 +- hipfile/src/amd_detail/sys.h | 2 +- hipfile/test/amd_detail/async.cpp | 2 +- hipfile/test/amd_detail/batch/batch.cpp | 2 +- hipfile/test/amd_detail/batch/batch_mt.cpp | 2 +- hipfile/test/amd_detail/buffer.cpp | 2 +- hipfile/test/amd_detail/context.cpp | 2 +- hipfile/test/amd_detail/driver.cpp | 2 +- hipfile/test/amd_detail/fallback.cpp | 4 ++-- hipfile/test/amd_detail/fastpath.cpp | 4 ++-- hipfile/test/amd_detail/handle.cpp | 2 +- hipfile/test/amd_detail/hip.cpp | 2 +- hipfile/test/amd_detail/mbackend.h | 4 ++-- hipfile/test/amd_detail/mbatch.h | 2 +- hipfile/test/amd_detail/mbuffer.h | 2 +- hipfile/test/amd_detail/mfile.h | 2 +- hipfile/test/amd_detail/mhip.h | 2 +- hipfile/test/amd_detail/misc.cpp | 2 +- hipfile/test/amd_detail/mmountinfo.h | 2 +- hipfile/test/amd_detail/mountinfo.cpp | 2 +- hipfile/test/amd_detail/mstate.h | 2 +- hipfile/test/amd_detail/mstream.h | 2 +- hipfile/test/amd_detail/msys.h | 2 +- hipfile/test/amd_detail/rocfile-test.h | 8 ++++---- hipfile/test/amd_detail/rocfile.cpp | 6 +++--- hipfile/test/amd_detail/state_mt.cpp | 2 +- hipfile/test/amd_detail/stream.cpp | 2 +- 56 files changed, 91 insertions(+), 91 deletions(-) diff --git a/hipfile/src/amd_detail/async.cpp b/hipfile/src/amd_detail/async.cpp index adab7a70..4d30cc07 100644 --- a/hipfile/src/amd_detail/async.cpp +++ b/hipfile/src/amd_detail/async.cpp @@ -13,17 +13,17 @@ #include #include -namespace rocFile { +namespace hipFile { class IBuffer; } -namespace rocFile { +namespace hipFile { class IFile; } -namespace rocFile { +namespace hipFile { enum class IoType; } -namespace rocFile { +namespace hipFile { AsyncMonitor::AsyncMonitor() : is_finished{false} { diff --git a/hipfile/src/amd_detail/async.h b/hipfile/src/amd_detail/async.h index fe5e8ea2..dbb6e3de 100644 --- a/hipfile/src/amd_detail/async.h +++ b/hipfile/src/amd_detail/async.h @@ -15,20 +15,20 @@ #include #include -namespace rocFile { +namespace hipFile { class IBuffer; } -namespace rocFile { +namespace hipFile { class IFile; } -namespace rocFile { +namespace hipFile { class IStream; } -namespace rocFile { +namespace hipFile { enum class IoType; } -namespace rocFile { +namespace hipFile { class AsyncOp { public: diff --git a/hipfile/src/amd_detail/backend.h b/hipfile/src/amd_detail/backend.h index d681800d..c2e040df 100644 --- a/hipfile/src/amd_detail/backend.h +++ b/hipfile/src/amd_detail/backend.h @@ -16,7 +16,7 @@ #include #include -namespace rocFile { +namespace hipFile { // The maximum number of bytes that can be transferred in a single read() or // write() system call. Mirrors kernel's MAX_RW_COUNT diff --git a/hipfile/src/amd_detail/backend/asyncop-fallback.cpp b/hipfile/src/amd_detail/backend/asyncop-fallback.cpp index cd951d3c..7c1976d2 100644 --- a/hipfile/src/amd_detail/backend/asyncop-fallback.cpp +++ b/hipfile/src/amd_detail/backend/asyncop-fallback.cpp @@ -14,17 +14,17 @@ #include #include -namespace rocFile { +namespace hipFile { class IFile; } -namespace rocFile { +namespace hipFile { class IStream; } -namespace rocFile { +namespace hipFile { enum class IoType; } -using namespace rocFile; +using namespace hipFile; static void hipHostDeleter(void *buffer) diff --git a/hipfile/src/amd_detail/backend/asyncop-fallback.h b/hipfile/src/amd_detail/backend/asyncop-fallback.h index cb44766e..98398e25 100644 --- a/hipfile/src/amd_detail/backend/asyncop-fallback.h +++ b/hipfile/src/amd_detail/backend/asyncop-fallback.h @@ -10,20 +10,20 @@ #include #include -namespace rocFile { +namespace hipFile { class IBuffer; } -namespace rocFile { +namespace hipFile { class IFile; } -namespace rocFile { +namespace hipFile { class IStream; } -namespace rocFile { +namespace hipFile { enum class IoType; } -namespace rocFile { +namespace hipFile { struct AsyncOpFallback : AsyncOp { ssize_t bytes_transferred_internal; diff --git a/hipfile/src/amd_detail/backend/fallback.cpp b/hipfile/src/amd_detail/backend/fallback.cpp index 0ca245d1..7b0feae3 100644 --- a/hipfile/src/amd_detail/backend/fallback.cpp +++ b/hipfile/src/amd_detail/backend/fallback.cpp @@ -20,7 +20,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using std::min; using std::shared_ptr; @@ -52,7 +52,7 @@ Fallback::io(IoType io_type, shared_ptr file, shared_ptr buffer, { size_t buflen{buffer->getLength()}; - size = min(size, rocFile::MAX_RW_COUNT); + size = min(size, hipFile::MAX_RW_COUNT); if (file_offset < 0) { throw std::invalid_argument("Negative file offset"); diff --git a/hipfile/src/amd_detail/backend/fallback.h b/hipfile/src/amd_detail/backend/fallback.h index 94bd75b9..9213d67c 100644 --- a/hipfile/src/amd_detail/backend/fallback.h +++ b/hipfile/src/amd_detail/backend/fallback.h @@ -11,17 +11,17 @@ #include #include -namespace rocFile { +namespace hipFile { class IBuffer; } -namespace rocFile { +namespace hipFile { class IFile; } -namespace rocFile { +namespace hipFile { enum class IoType; } -namespace rocFile { +namespace hipFile { struct Fallback : public Backend { virtual ~Fallback() override = default; diff --git a/hipfile/src/amd_detail/backend/fastpath.cpp b/hipfile/src/amd_detail/backend/fastpath.cpp index 63e30b7d..24e2c0a4 100644 --- a/hipfile/src/amd_detail/backend/fastpath.cpp +++ b/hipfile/src/amd_detail/backend/fastpath.cpp @@ -16,7 +16,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace std; /* The fastpath backend is used when: diff --git a/hipfile/src/amd_detail/backend/fastpath.h b/hipfile/src/amd_detail/backend/fastpath.h index 91b9863f..33032b44 100644 --- a/hipfile/src/amd_detail/backend/fastpath.h +++ b/hipfile/src/amd_detail/backend/fastpath.h @@ -11,17 +11,17 @@ #include #include -namespace rocFile { +namespace hipFile { class IBuffer; } -namespace rocFile { +namespace hipFile { class IFile; } -namespace rocFile { +namespace hipFile { enum class IoType; } -namespace rocFile { +namespace hipFile { struct Fastpath : public Backend { virtual ~Fastpath() override = default; diff --git a/hipfile/src/amd_detail/batch/batch.cpp b/hipfile/src/amd_detail/batch/batch.cpp index 024ca359..e6aa3600 100644 --- a/hipfile/src/amd_detail/batch/batch.cpp +++ b/hipfile/src/amd_detail/batch/batch.cpp @@ -20,7 +20,7 @@ #include #include -namespace rocFile { +namespace hipFile { BatchOperation::BatchOperation(std::unique_ptr params, std::shared_ptr _buffer, std::shared_ptr _file) diff --git a/hipfile/src/amd_detail/batch/batch.h b/hipfile/src/amd_detail/batch/batch.h index 54923941..def314a0 100644 --- a/hipfile/src/amd_detail/batch/batch.h +++ b/hipfile/src/amd_detail/batch/batch.h @@ -13,14 +13,14 @@ #include #include -namespace rocFile { +namespace hipFile { class IBuffer; } -namespace rocFile { +namespace hipFile { class IFile; } -namespace rocFile { +namespace hipFile { struct InvalidBatchHandle : public std::invalid_argument { InvalidBatchHandle() : std::invalid_argument{"Invalid batch handle"} diff --git a/hipfile/src/amd_detail/buffer.cpp b/hipfile/src/amd_detail/buffer.cpp index 41738454..697b5651 100644 --- a/hipfile/src/amd_detail/buffer.cpp +++ b/hipfile/src/amd_detail/buffer.cpp @@ -20,7 +20,7 @@ using std::shared_ptr; using std::transform; using std::vector; -namespace rocFile { +namespace hipFile { static bool isValidBufferRegion(void *ptr, size_t length) diff --git a/hipfile/src/amd_detail/buffer.h b/hipfile/src/amd_detail/buffer.h index 3500f5fd..f837dc64 100644 --- a/hipfile/src/amd_detail/buffer.h +++ b/hipfile/src/amd_detail/buffer.h @@ -11,7 +11,7 @@ #include #include -namespace rocFile { +namespace hipFile { /// @brief Buffer is currently registered struct BufferAlreadyRegistered : public std::runtime_error { diff --git a/hipfile/src/amd_detail/context.cpp b/hipfile/src/amd_detail/context.cpp index bd829970..41136cb0 100644 --- a/hipfile/src/amd_detail/context.cpp +++ b/hipfile/src/amd_detail/context.cpp @@ -9,7 +9,7 @@ #include "state.h" #include "sys.h" -namespace rocFile { +namespace hipFile { RocFileInit::RocFileInit() { diff --git a/hipfile/src/amd_detail/context.h b/hipfile/src/amd_detail/context.h index c3e12ee0..6817369f 100644 --- a/hipfile/src/amd_detail/context.h +++ b/hipfile/src/amd_detail/context.h @@ -11,7 +11,7 @@ #include #endif -namespace rocFile { +namespace hipFile { template struct ContextOverride; diff --git a/hipfile/src/amd_detail/file.cpp b/hipfile/src/amd_detail/file.cpp index dbcbb382..61b2861c 100644 --- a/hipfile/src/amd_detail/file.cpp +++ b/hipfile/src/amd_detail/file.cpp @@ -21,7 +21,7 @@ using std::shared_ptr; using std::transform; using std::vector; -namespace rocFile { +namespace hipFile { UnregisteredFile::UnregisteredFile(int fd) : m_fd(fd), m_stx{Context::get()->statx(fd, "", AT_EMPTY_PATH, diff --git a/hipfile/src/amd_detail/file.h b/hipfile/src/amd_detail/file.h index f1ff06b6..8a037d73 100644 --- a/hipfile/src/amd_detail/file.h +++ b/hipfile/src/amd_detail/file.h @@ -14,7 +14,7 @@ #include #include -namespace rocFile { +namespace hipFile { /// @brief File is not registered struct FileNotRegistered : public std::runtime_error { diff --git a/hipfile/src/amd_detail/hip.cpp b/hipfile/src/amd_detail/hip.cpp index b575842a..e891b44a 100644 --- a/hipfile/src/amd_detail/hip.cpp +++ b/hipfile/src/amd_detail/hip.cpp @@ -9,7 +9,7 @@ #include #include -namespace rocFile { +namespace hipFile { static void * hipGetProcAddressHelper(const char *symbol) diff --git a/hipfile/src/amd_detail/hip.h b/hipfile/src/amd_detail/hip.h index 754801f2..c78a951c 100644 --- a/hipfile/src/amd_detail/hip.h +++ b/hipfile/src/amd_detail/hip.h @@ -23,7 +23,7 @@ * - Use return values instead of out arguments when possible */ -namespace rocFile { +namespace hipFile { struct HipMemAddressRange { hipDeviceptr_t base; diff --git a/hipfile/src/amd_detail/io.h b/hipfile/src/amd_detail/io.h index 0babd96f..4ed0cc51 100644 --- a/hipfile/src/amd_detail/io.h +++ b/hipfile/src/amd_detail/io.h @@ -4,7 +4,7 @@ */ #pragma once -namespace rocFile { +namespace hipFile { enum class IoType { Read, diff --git a/hipfile/src/amd_detail/mountinfo.cpp b/hipfile/src/amd_detail/mountinfo.cpp index 1fb3a143..54af714e 100644 --- a/hipfile/src/amd_detail/mountinfo.cpp +++ b/hipfile/src/amd_detail/mountinfo.cpp @@ -14,7 +14,7 @@ struct libmnt_context; struct libmnt_fs; struct libmnt_table; -namespace rocFile { +namespace hipFile { LibMount::~LibMount() { diff --git a/hipfile/src/amd_detail/mountinfo.h b/hipfile/src/amd_detail/mountinfo.h index ccd48c6e..d2d24f5d 100644 --- a/hipfile/src/amd_detail/mountinfo.h +++ b/hipfile/src/amd_detail/mountinfo.h @@ -12,7 +12,7 @@ struct libmnt_context; struct libmnt_fs; struct libmnt_table; -namespace rocFile { +namespace hipFile { /// @brief The filesystem type enum class FilesystemType { diff --git a/hipfile/src/amd_detail/rocfile-private.cpp b/hipfile/src/amd_detail/rocfile-private.cpp index 0ea5be16..d5a65e4c 100644 --- a/hipfile/src/amd_detail/rocfile-private.cpp +++ b/hipfile/src/amd_detail/rocfile-private.cpp @@ -10,5 +10,5 @@ void rocFileEnsureDriverInitPrivate() { - rocFile::Context::get()->ensureInitialized(); + hipFile::Context::get()->ensureInitialized(); } diff --git a/hipfile/src/amd_detail/rocfile-private.h b/hipfile/src/amd_detail/rocfile-private.h index 6e6e90fb..48173fe5 100644 --- a/hipfile/src/amd_detail/rocfile-private.h +++ b/hipfile/src/amd_detail/rocfile-private.h @@ -12,7 +12,7 @@ #include #include -namespace rocFile { +namespace hipFile { enum class IoType; struct Backend; } @@ -26,6 +26,6 @@ struct Backend; ROCFILE_API void rocFileEnsureDriverInitPrivate(); -ssize_t rocFileIo(rocFile::IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, +ssize_t rocFileIo(hipFile::IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset, - const std::vector> &backends); + const std::vector> &backends); diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 6d1f41e8..b5c55602 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -23,7 +23,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace std; const char * diff --git a/hipfile/src/amd_detail/state.cpp b/hipfile/src/amd_detail/state.cpp index 93e99cca..f41d9b6a 100644 --- a/hipfile/src/amd_detail/state.cpp +++ b/hipfile/src/amd_detail/state.cpp @@ -22,11 +22,11 @@ using std::shared_mutex; using std::shared_ptr; using std::unique_lock; -namespace rocFile { +namespace hipFile { struct Backend; } -namespace rocFile { +namespace hipFile { DriverState::DriverState() : ref_count{0} { diff --git a/hipfile/src/amd_detail/state.h b/hipfile/src/amd_detail/state.h index 665df1bd..f1f84315 100644 --- a/hipfile/src/amd_detail/state.h +++ b/hipfile/src/amd_detail/state.h @@ -20,11 +20,11 @@ #include #include -namespace rocFile { +namespace hipFile { template struct Context; } -namespace rocFile { +namespace hipFile { /// @brief The driver is not initialized struct DriverNotInitialized : public std::runtime_error { diff --git a/hipfile/src/amd_detail/stream.cpp b/hipfile/src/amd_detail/stream.cpp index e0e07841..23bf1e7b 100644 --- a/hipfile/src/amd_detail/stream.cpp +++ b/hipfile/src/amd_detail/stream.cpp @@ -13,7 +13,7 @@ #include #include -namespace rocFile { +namespace hipFile { Stream::Stream(const hipStream_t _hip_stream, uint32_t flags) : hip_stream{_hip_stream}, fixed_buf_offset{(flags & ROCFILE_STREAM_FIXED_BUF_OFFSET) != 0}, diff --git a/hipfile/src/amd_detail/stream.h b/hipfile/src/amd_detail/stream.h index 073f940a..9c67a446 100644 --- a/hipfile/src/amd_detail/stream.h +++ b/hipfile/src/amd_detail/stream.h @@ -9,7 +9,7 @@ #include #include -namespace rocFile { +namespace hipFile { class IStream { public: diff --git a/hipfile/src/amd_detail/sys.cpp b/hipfile/src/amd_detail/sys.cpp index d7f9768a..898c3b17 100644 --- a/hipfile/src/amd_detail/sys.cpp +++ b/hipfile/src/amd_detail/sys.cpp @@ -11,7 +11,7 @@ #include #include -namespace rocFile { +namespace hipFile { template static inline R diff --git a/hipfile/src/amd_detail/sys.h b/hipfile/src/amd_detail/sys.h index 40caf886..9ec2532d 100644 --- a/hipfile/src/amd_detail/sys.h +++ b/hipfile/src/amd_detail/sys.h @@ -20,7 +20,7 @@ * - Use return values instead of out arguments when possible */ -namespace rocFile { +namespace hipFile { struct Sys { virtual ~Sys() = default; diff --git a/hipfile/test/amd_detail/async.cpp b/hipfile/test/amd_detail/async.cpp index fc887fdf..14f32c10 100644 --- a/hipfile/test/amd_detail/async.cpp +++ b/hipfile/test/amd_detail/async.cpp @@ -32,7 +32,7 @@ // warnings HIPFILE_WARN_NO_GLOBAL_CTOR_OFF -using namespace rocFile; +using namespace hipFile; using std::shared_ptr; using ::testing::_; using ::testing::AnyNumber; diff --git a/hipfile/test/amd_detail/batch/batch.cpp b/hipfile/test/amd_detail/batch/batch.cpp index c8a219e9..0285102b 100644 --- a/hipfile/test/amd_detail/batch/batch.cpp +++ b/hipfile/test/amd_detail/batch/batch.cpp @@ -28,7 +28,7 @@ using ::testing::Return; using ::testing::StrictMock; using ::testing::Throw; -using namespace rocFile; +using namespace hipFile; HIPFILE_WARN_NO_GLOBAL_CTOR_OFF diff --git a/hipfile/test/amd_detail/batch/batch_mt.cpp b/hipfile/test/amd_detail/batch/batch_mt.cpp index ba53d80e..c932f976 100644 --- a/hipfile/test/amd_detail/batch/batch_mt.cpp +++ b/hipfile/test/amd_detail/batch/batch_mt.cpp @@ -23,7 +23,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace std; diff --git a/hipfile/test/amd_detail/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp index 65f52f61..133cd190 100644 --- a/hipfile/test/amd_detail/buffer.cpp +++ b/hipfile/test/amd_detail/buffer.cpp @@ -21,7 +21,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using ::testing::StrictMock; diff --git a/hipfile/test/amd_detail/context.cpp b/hipfile/test/amd_detail/context.cpp index 01afb73c..90e1200b 100644 --- a/hipfile/test/amd_detail/context.cpp +++ b/hipfile/test/amd_detail/context.cpp @@ -10,7 +10,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; // Put tests inside the macros to suppress the global constructor // warnings diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index e35c5f74..f94f46c6 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -18,7 +18,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace testing; // Put tests inside the macros to suppress the global constructor diff --git a/hipfile/test/amd_detail/fallback.cpp b/hipfile/test/amd_detail/fallback.cpp index a987aa41..7a4b4f7e 100644 --- a/hipfile/test/amd_detail/fallback.cpp +++ b/hipfile/test/amd_detail/fallback.cpp @@ -39,14 +39,14 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace testing; using std::shared_ptr; using ::testing::Return; using ::testing::StrictMock; -namespace rocFile { +namespace hipFile { class IFile; } diff --git a/hipfile/test/amd_detail/fastpath.cpp b/hipfile/test/amd_detail/fastpath.cpp index f7c2c01f..83d6ae21 100644 --- a/hipfile/test/amd_detail/fastpath.cpp +++ b/hipfile/test/amd_detail/fastpath.cpp @@ -25,7 +25,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace testing; using namespace std; @@ -42,7 +42,7 @@ static uint32_t DEFAULT_MEM_ALIGN{4096}; static uint32_t DEFAULT_OFFSET_ALIGN{4096}; #endif -namespace rocFile { +namespace hipFile { inline bool operator==(const hipAmdFileHandle_t &lhs, const hipAmdFileHandle_t &rhs) { diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index f9a31bcd..1bf69b80 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -24,7 +24,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace testing; // Put tests inside the macros to suppress the global constructor diff --git a/hipfile/test/amd_detail/hip.cpp b/hipfile/test/amd_detail/hip.cpp index 597384dc..7b1619a6 100644 --- a/hipfile/test/amd_detail/hip.cpp +++ b/hipfile/test/amd_detail/hip.cpp @@ -11,7 +11,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace testing; HIPFILE_WARN_NO_GLOBAL_CTOR_OFF diff --git a/hipfile/test/amd_detail/mbackend.h b/hipfile/test/amd_detail/mbackend.h index d0594de8..ae3517ff 100644 --- a/hipfile/test/amd_detail/mbackend.h +++ b/hipfile/test/amd_detail/mbackend.h @@ -9,13 +9,13 @@ #include -namespace rocFile { +namespace hipFile { struct MBackend : Backend { MOCK_METHOD(int, score, (std::shared_ptr, std::shared_ptr, size_t, hoff_t, hoff_t), (const override)); MOCK_METHOD(ssize_t, io, - (rocFile::IoType type, std::shared_ptr, std::shared_ptr, size_t, hoff_t, + (hipFile::IoType type, std::shared_ptr, std::shared_ptr, size_t, hoff_t, hoff_t), (override)); }; diff --git a/hipfile/test/amd_detail/mbatch.h b/hipfile/test/amd_detail/mbatch.h index 5b637524..cf34c206 100644 --- a/hipfile/test/amd_detail/mbatch.h +++ b/hipfile/test/amd_detail/mbatch.h @@ -13,7 +13,7 @@ * A place to create mocks for the batch module. */ -namespace rocFile { +namespace hipFile { class MBatchContext : public IBatchContext { public: diff --git a/hipfile/test/amd_detail/mbuffer.h b/hipfile/test/amd_detail/mbuffer.h index b3308881..2ddf4ae0 100644 --- a/hipfile/test/amd_detail/mbuffer.h +++ b/hipfile/test/amd_detail/mbuffer.h @@ -13,7 +13,7 @@ * A place to create mocks for the buffer module. */ -namespace rocFile { +namespace hipFile { class MBuffer : public IBuffer { public: diff --git a/hipfile/test/amd_detail/mfile.h b/hipfile/test/amd_detail/mfile.h index 37828379..967ee748 100644 --- a/hipfile/test/amd_detail/mfile.h +++ b/hipfile/test/amd_detail/mfile.h @@ -14,7 +14,7 @@ * A place to create mocks for the file module. */ -namespace rocFile { +namespace hipFile { class MFile : public IFile { public: diff --git a/hipfile/test/amd_detail/mhip.h b/hipfile/test/amd_detail/mhip.h index 78647a1e..f8132d5e 100644 --- a/hipfile/test/amd_detail/mhip.h +++ b/hipfile/test/amd_detail/mhip.h @@ -14,7 +14,7 @@ * * Mock implementations for Hip. Enables unit tests to mock HIP APIs. */ -namespace rocFile { +namespace hipFile { struct MHip : Hip { ContextOverride co; diff --git a/hipfile/test/amd_detail/misc.cpp b/hipfile/test/amd_detail/misc.cpp index 4571e65e..d0a24eca 100644 --- a/hipfile/test/amd_detail/misc.cpp +++ b/hipfile/test/amd_detail/misc.cpp @@ -12,7 +12,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; // Put tests inside the macros to suppress the global constructor // warnings diff --git a/hipfile/test/amd_detail/mmountinfo.h b/hipfile/test/amd_detail/mmountinfo.h index c1b8718b..45edec89 100644 --- a/hipfile/test/amd_detail/mmountinfo.h +++ b/hipfile/test/amd_detail/mmountinfo.h @@ -10,7 +10,7 @@ #include -namespace rocFile { +namespace hipFile { struct MLibMount : LibMount { ContextOverride co; diff --git a/hipfile/test/amd_detail/mountinfo.cpp b/hipfile/test/amd_detail/mountinfo.cpp index 818ee171..c2b967a0 100644 --- a/hipfile/test/amd_detail/mountinfo.cpp +++ b/hipfile/test/amd_detail/mountinfo.cpp @@ -22,7 +22,7 @@ struct libmnt_context; struct libmnt_fs; struct libmnt_table; -using namespace rocFile; +using namespace hipFile; using namespace testing; HIPFILE_WARN_NO_GLOBAL_CTOR_OFF diff --git a/hipfile/test/amd_detail/mstate.h b/hipfile/test/amd_detail/mstate.h index 86181d8a..7c62e719 100644 --- a/hipfile/test/amd_detail/mstate.h +++ b/hipfile/test/amd_detail/mstate.h @@ -17,7 +17,7 @@ * A place to create mocks for the DriverState singleton. */ -namespace rocFile { +namespace hipFile { class MDriverState : public DriverState { public: diff --git a/hipfile/test/amd_detail/mstream.h b/hipfile/test/amd_detail/mstream.h index 72a12016..34411b8b 100644 --- a/hipfile/test/amd_detail/mstream.h +++ b/hipfile/test/amd_detail/mstream.h @@ -6,7 +6,7 @@ #include "stream.h" -namespace rocFile { +namespace hipFile { class MStream : public IStream { public: diff --git a/hipfile/test/amd_detail/msys.h b/hipfile/test/amd_detail/msys.h index 26d40ae9..3308e650 100644 --- a/hipfile/test/amd_detail/msys.h +++ b/hipfile/test/amd_detail/msys.h @@ -11,7 +11,7 @@ #include // Mock implementations for Sys. Enables unit tests to mock system calls. -namespace rocFile { +namespace hipFile { struct MSys : Sys { ContextOverride co; diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h index 9d8253b6..da537f18 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/rocfile-test.h @@ -114,7 +114,7 @@ struct RocFileUnopened : public ::testing::Test { // *********************************************************************** /// @brief Set up mocks for buffer registration -void expect_buffer_registration(rocFile::MHip &mhip, hipMemoryType memory_type); +void expect_buffer_registration(hipFile::MHip &mhip, hipMemoryType memory_type); // *********************************************************************** // FILE FUNCTIONALITY @@ -123,13 +123,13 @@ void expect_buffer_registration(rocFile::MHip &mhip, hipMemoryType memory_type); /// @brief Setup mocks for file registration /// /// Mock methods will return default values -void expect_file_registration(rocFile::MSys &msys, rocFile::MLibMountHelper &mlibmounthelper); +void expect_file_registration(hipFile::MSys &msys, hipFile::MLibMountHelper &mlibmounthelper); /// @brief Setup mocks for file registration /// /// Mock methods will return the specified values -void expect_file_registration(rocFile::MSys &msys, rocFile::MLibMountHelper &mlibmounthelper, - struct statx stxbuf, int fcntl_flags, rocFile::MountInfo mountinfo); +void expect_file_registration(hipFile::MSys &msys, hipFile::MLibMountHelper &mlibmounthelper, + struct statx stxbuf, int fcntl_flags, hipFile::MountInfo mountinfo); // *********************************************************************** // ENUM VALUE HELPERS diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index bf112657..5b1bcff5 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -4,7 +4,7 @@ */ /* - * These tests are integration-level tests against th rocFile API. + * These tests are integration-level tests against the rocFile API. * They should test that the various rocFile modules are compatible with * one another. Running IO is not intended to be guaranteed to run here. * @@ -41,11 +41,11 @@ #include #include -namespace rocFile { +namespace hipFile { struct Backend; } -using namespace rocFile; +using namespace hipFile; using namespace std; using namespace testing; diff --git a/hipfile/test/amd_detail/state_mt.cpp b/hipfile/test/amd_detail/state_mt.cpp index 95f7d9f7..6d77e715 100644 --- a/hipfile/test/amd_detail/state_mt.cpp +++ b/hipfile/test/amd_detail/state_mt.cpp @@ -27,7 +27,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using namespace std; diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index 27a6c674..a4424f7b 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -18,7 +18,7 @@ #include #include -using namespace rocFile; +using namespace hipFile; using ::testing::StrictMock; From 745f6e95d45ca80ea024b4b70f40c8463c3a5bfb Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 25 Nov 2025 23:40:34 -0700 Subject: [PATCH 06/48] Move test-hipfile* programs Relocated to a `legacy` subdirectory under `test` --- hipfile/test/CMakeLists.txt | 4 ++-- hipfile/test/{ => legacy}/test-hipfile-batch.cpp | 0 hipfile/test/{ => legacy}/test-hipfile.cpp | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename hipfile/test/{ => legacy}/test-hipfile-batch.cpp (100%) rename hipfile/test/{ => legacy}/test-hipfile.cpp (100%) diff --git a/hipfile/test/CMakeLists.txt b/hipfile/test/CMakeLists.txt index 72644986..46193a48 100644 --- a/hipfile/test/CMakeLists.txt +++ b/hipfile/test/CMakeLists.txt @@ -84,12 +84,12 @@ gtest_discover_tests( # ---------------------------------------- ais_add_executable( NAME test_hipfile_basic - SRCS test-hipfile.cpp + SRCS legacy/test-hipfile.cpp DEPS hipfile_shared ) ais_add_executable( NAME test_hipfile_batch - SRCS test-hipfile-batch.cpp + SRCS legacy/test-hipfile-batch.cpp DEPS hipfile_shared ) # ---------------------------------------- diff --git a/hipfile/test/test-hipfile-batch.cpp b/hipfile/test/legacy/test-hipfile-batch.cpp similarity index 100% rename from hipfile/test/test-hipfile-batch.cpp rename to hipfile/test/legacy/test-hipfile-batch.cpp diff --git a/hipfile/test/test-hipfile.cpp b/hipfile/test/legacy/test-hipfile.cpp similarity index 100% rename from hipfile/test/test-hipfile.cpp rename to hipfile/test/legacy/test-hipfile.cpp From b9ddfb53460d2f3fc2fe6dcde91f91d876bad819 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 25 Nov 2025 23:54:59 -0700 Subject: [PATCH 07/48] Remove hipfile-rocfile.cpp These tests ensured that the rocFile API stayed compatible with the hipFile API. With the retirement of the rocFile API, these tests are no longer necessary. --- hipfile/test/CMakeLists.txt | 1 - hipfile/test/hipfile-rocfile.cpp | 264 ------------------------------- 2 files changed, 265 deletions(-) delete mode 100644 hipfile/test/hipfile-rocfile.cpp diff --git a/hipfile/test/CMakeLists.txt b/hipfile/test/CMakeLists.txt index 46193a48..ca0d41f2 100644 --- a/hipfile/test/CMakeLists.txt +++ b/hipfile/test/CMakeLists.txt @@ -41,7 +41,6 @@ if(BUILD_NVIDIA_DETAIL) list(APPEND UNIT_TEST_SOURCE_FILES hipfile-cufile.cpp) list(APPEND TEST_SYSINCLS ${HIPFILE_NVIDIA_SOURCE_PATH}) else() - list(APPEND UNIT_TEST_SOURCE_FILES hipfile-rocfile.cpp) list(APPEND TEST_SYSINCLS ${HIPFILE_AMD_SOURCE_PATH}) endif() diff --git a/hipfile/test/hipfile-rocfile.cpp b/hipfile/test/hipfile-rocfile.cpp deleted file mode 100644 index 78a46f68..00000000 --- a/hipfile/test/hipfile-rocfile.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ - -#include "hipfile.h" -#include "hipfile-rocfile.h" -#include "hipfile-warnings.h" -#include "invalid-enum.h" -#include "rocfile.h" -#include "test-common.h" - -#include -#include -#include -#include - -// Put tests inside the macros to suppress the global constructor -// warnings -HIPFILE_WARN_NO_GLOBAL_CTOR_OFF - -TEST(ToHipFile, hipFileOpError_t) -{ - ASSERT_THROW(toHipFileOpError(invalidEnum(hipFileSuccess - 1)), std::invalid_argument); - ASSERT_THROW(toHipFileOpError(invalidEnum(hipFileSuccess + 1)), std::invalid_argument); - - ASSERT_THROW(toHipFileOpError(invalidEnum(HIPFILE_BASE_ERR)), std::invalid_argument); - - ASSERT_THROW(toHipFileOpError(invalidEnum(HIPFILE_BASE_ERR + 21)), - std::invalid_argument); - ASSERT_THROW(toHipFileOpError(invalidEnum(HIPFILE_BASE_ERR + 32)), - std::invalid_argument); - -#define r2h(R, H) ASSERT_EQ(toHipFileOpError((R)), (H)) - r2h(rocFileSuccess, hipFileSuccess); - r2h(rocFileDriverNotInitialized, hipFileDriverNotInitialized); - r2h(rocFileDriverInvalidProps, hipFileDriverInvalidProps); - r2h(rocFileDriverUnsupportedLimit, hipFileDriverUnsupportedLimit); - r2h(rocFileDriverVersionMismatch, hipFileDriverVersionMismatch); - r2h(rocFileDriverVersionReadError, hipFileDriverVersionReadError); - r2h(rocFileDriverClosing, hipFileDriverClosing); - r2h(rocFilePlatformNotSupported, hipFilePlatformNotSupported); - r2h(rocFileIONotSupported, hipFileIONotSupported); - r2h(rocFileDeviceNotSupported, hipFileDeviceNotSupported); - r2h(rocFileDriverError, hipFileDriverError); - r2h(rocFileHipDriverError, hipFileHipDriverError); - r2h(rocFileHipPointerInvalid, hipFileHipPointerInvalid); - r2h(rocFileHipMemoryTypeInvalid, hipFileHipMemoryTypeInvalid); - r2h(rocFileHipPointerRangeError, hipFileHipPointerRangeError); - r2h(rocFileHipContextMismatch, hipFileHipContextMismatch); - r2h(rocFileInvalidMappingSize, hipFileInvalidMappingSize); - r2h(rocFileInvalidMappingRange, hipFileInvalidMappingRange); - r2h(rocFileInvalidFileType, hipFileInvalidFileType); - r2h(rocFileInvalidFileOpenFlag, hipFileInvalidFileOpenFlag); - r2h(rocFileDIONotSet, hipFileDIONotSet); - r2h(rocFileInvalidValue, hipFileInvalidValue); - r2h(rocFileMemoryAlreadyRegistered, hipFileMemoryAlreadyRegistered); - r2h(rocFileMemoryNotRegistered, hipFileMemoryNotRegistered); - r2h(rocFilePermissionDenied, hipFilePermissionDenied); - r2h(rocFileDriverAlreadyOpen, hipFileDriverAlreadyOpen); - r2h(rocFileHandleNotRegistered, hipFileHandleNotRegistered); - r2h(rocFileHandleAlreadyRegistered, hipFileHandleAlreadyRegistered); - r2h(rocFileDeviceNotFound, hipFileDeviceNotFound); - r2h(rocFileInternalError, hipFileInternalError); - r2h(rocFileGetNewFDFailed, hipFileGetNewFDFailed); - r2h(rocFileDriverSetupError, hipFileDriverSetupError); - r2h(rocFileIODisabled, hipFileIODisabled); - r2h(rocFileBatchSubmitFailed, hipFileBatchSubmitFailed); - r2h(rocFileGPUMemoryPinningFailed, hipFileGPUMemoryPinningFailed); - r2h(rocFileBatchFull, hipFileBatchFull); - r2h(rocFileAsyncNotSupported, hipFileAsyncNotSupported); - r2h(rocFileIOMaxError, hipFileIOMaxError); -#undef r2h - - ASSERT_THROW(toHipFileOpError(invalidEnum(hipFileIOMaxError + 1)), - std::invalid_argument); -} - -TEST(ToHipFile, hipFileError_t) -{ - ASSERT_THROW((void)toHipFileError( - rocFileError_t{invalidEnum(rocFileIOMaxError + 1), hipSuccess}), - std::invalid_argument); - - ASSERT_EQ(toHipFileError(rocFileError_t{rocFileSuccess, hipSuccess}), HIPFILE_SUCCESS); - ASSERT_EQ(toHipFileError(rocFileError_t{rocFileHipDriverError, hipErrorInvalidValue}), - HipFileDriverError(hipErrorInvalidValue)); - ASSERT_EQ(toHipFileError(rocFileError_t{rocFileDriverNotInitialized, hipSuccess}), - HipFileOpError(hipFileDriverNotInitialized)); -} - -TEST(ToHipFile, hipFileStatus_t) -{ - ASSERT_THROW(toHipFileStatus(invalidEnum(rocFileWaiting - 1)), std::invalid_argument); - -#define r2h(R, H) ASSERT_EQ(toHipFileStatus((R)), (H)) - r2h(rocFileWaiting, hipFileWaiting); - r2h(rocFilePending, hipFilePending); - r2h(rocFileInvalid, hipFileInvalid); - r2h(rocFileCanceled, hipFileCanceled); - r2h(rocFileComplete, hipFileComplete); - r2h(rocFileTimeout, hipFileTimeout); - r2h(rocFileFailed, hipFileFailed); -#undef r2h - - ASSERT_THROW(toHipFileStatus(invalidEnum(rocFileFailed + 1)), std::invalid_argument); -} - -TEST(ToHipFile, hipFileIOEvents_t) -{ - { - rocFileIOEvents_t rioe; - rioe.status = invalidEnum(rocFileWaiting - 1); - ASSERT_THROW(toHipFileIOEvents(rioe), std::invalid_argument); - } - - { - rocFileIOEvents_t rioe; - rioe.status = invalidEnum(rocFileFailed + 1); - ASSERT_THROW(toHipFileIOEvents(rioe), std::invalid_argument); - } - - { - rocFileIOEvents_t rioe; - rfill(static_cast(&rioe), sizeof(rioe)); - rioe.status = rocFileWaiting; - - auto hioe = toHipFileIOEvents(rioe); - - ASSERT_EQ(hioe.cookie, rioe.cookie); - ASSERT_EQ(hioe.status, hipFileWaiting); - ASSERT_EQ(hioe.ret, rioe.ret); - } -} - -TEST(ToRocFile, rocFileDescr_t) -{ - { - hipFileDescr_t hfd{}; - hfd.type = invalidEnum(hipFileHandleTypeOpaqueFD - 1); - ASSERT_THROW(toRocFileDescr(hfd), std::invalid_argument); - } - - { - hipFileDescr_t hfd{}; - hfd.type = hipFileHandleTypeOpaqueFD; - hfd.handle.fd = 0x1234; - hfd.fs_ops = reinterpret_cast(0xCAFEBABE); - - auto rfd = toRocFileDescr(hfd); - ASSERT_EQ(rfd.type, rocFileHandleTypeOpaqueFD); - ASSERT_EQ(rfd.handle.fd, hfd.handle.fd); - ASSERT_EQ(static_cast(rfd.fs_ops), static_cast(hfd.fs_ops)); - } - - { - hipFileDescr_t hfd{}; - hfd.type = hipFileHandleTypeOpaqueWin32; - hfd.handle.hFile = reinterpret_cast(0x5678); - hfd.fs_ops = reinterpret_cast(0xBADF00D); - - auto rfd = toRocFileDescr(hfd); - ASSERT_EQ(rfd.type, rocFileHandleTypeOpaqueWin32); - ASSERT_EQ(rfd.handle.hFile, hfd.handle.hFile); - ASSERT_EQ(static_cast(rfd.fs_ops), static_cast(hfd.fs_ops)); - } - - { - hipFileDescr_t hfd{}; - hfd.type = hipFileHandleTypeUserspaceFS; - hfd.handle.fd = 0x90AB; - hfd.fs_ops = reinterpret_cast(0xFACEFEED); - - auto rfd = toRocFileDescr(hfd); - ASSERT_EQ(rfd.type, rocFileHandleTypeUserspaceFS); - ASSERT_EQ(rfd.handle.fd, hfd.handle.fd); - ASSERT_EQ(static_cast(rfd.fs_ops), static_cast(hfd.fs_ops)); - } - - { - hipFileDescr_t hfd{}; - hfd.type = invalidEnum(hipFileHandleTypeUserspaceFS + 1); - ASSERT_THROW(toRocFileDescr(hfd), std::invalid_argument); - } -} - -TEST(ToRocFile, rocFileFileHandleType) -{ - ASSERT_THROW(toRocFileFileHandleType(invalidEnum(hipFileHandleTypeOpaqueFD - 1)), - std::invalid_argument); - -#define h2c(H, C) ASSERT_EQ(toRocFileFileHandleType((H)), (C)) - h2c(hipFileHandleTypeOpaqueFD, rocFileHandleTypeOpaqueFD); - h2c(hipFileHandleTypeOpaqueWin32, rocFileHandleTypeOpaqueWin32); - h2c(hipFileHandleTypeUserspaceFS, rocFileHandleTypeUserspaceFS); -#undef h2c - - ASSERT_THROW( - toRocFileFileHandleType(invalidEnum(hipFileHandleTypeUserspaceFS + 1)), - std::invalid_argument); -} - -TEST(ToRocFile, rocFileBatchMode) -{ - ASSERT_THROW(toRocFileBatchMode(invalidEnum(hipFileBatch - 1)), - std::invalid_argument); - - ASSERT_EQ(toRocFileBatchMode(hipFileBatch), rocFileBatch); - - ASSERT_THROW(toRocFileBatchMode(invalidEnum(hipFileBatch + 1)), - std::invalid_argument); -} - -TEST(ToRocFile, rocFileOpcode_t) -{ - ASSERT_THROW(toRocFileOpcode(invalidEnum(hipFileBatchRead - 1)), std::invalid_argument); - -#define h2c(H, C) ASSERT_EQ(toRocFileOpcode((H)), (C)) - h2c(hipFileBatchRead, rocFileBatchRead); - h2c(hipFileBatchWrite, rocFileBatchWrite); -#undef h2c - - ASSERT_THROW(toRocFileOpcode(invalidEnum(hipFileBatchWrite + 1)), std::invalid_argument); -} - -TEST(ToRocFile, rocFileIOParams_t) -{ - { - hipFileIOParams_t hiop{}; - hiop.mode = invalidEnum(hipFileBatch + 1); - hiop.opcode = hipFileBatchWrite; - - ASSERT_THROW(toRocFileIOParams(hiop), std::invalid_argument); - } - - { - hipFileIOParams_t hiop{}; - hiop.mode = hipFileBatch; - hiop.opcode = invalidEnum(hipFileBatchWrite + 1); - - ASSERT_THROW(toRocFileIOParams(hiop), std::invalid_argument); - } - - { - hipFileIOParams_t hiop; - - rfill(static_cast(&hiop), sizeof(hiop)); - - hiop.mode = hipFileBatch; - hiop.opcode = hipFileBatchWrite; - - auto ciop = toRocFileIOParams(hiop); - ASSERT_EQ(ciop.mode, rocFileBatch); - ASSERT_EQ(ciop.u.batch.devPtr_base, hiop.u.batch.devPtr_base); - ASSERT_EQ(ciop.u.batch.file_offset, hiop.u.batch.file_offset); - ASSERT_EQ(ciop.u.batch.devPtr_offset, hiop.u.batch.devPtr_offset); - ASSERT_EQ(ciop.u.batch.size, hiop.u.batch.size); - ASSERT_EQ(ciop.fh, ciop.fh); - ASSERT_EQ(ciop.opcode, rocFileBatchWrite); - ASSERT_EQ(ciop.cookie, hiop.cookie); - } -} - -HIPFILE_WARN_NO_GLOBAL_CTOR_ON From 9c9d0ef72fbf813196ae668f53c71ccfc77d6146 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 00:31:29 -0700 Subject: [PATCH 08/48] Move NVIDIA API compatibility tests Move the hipfile-cufile.cpp file to a new nvidia_detail directory and rename it to cufile-api-compat.cpp to make its purpose more obvious. Also added some explanatory text to the test file. Also removed the useless main.cpp file that was a leftover placeholder from when we first set up the testing. --- hipfile/test/CMakeLists.txt | 3 +- hipfile/test/main.cpp | 30 ------------------- .../cufile-api-compat.cpp} | 7 +++-- 3 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 hipfile/test/main.cpp rename hipfile/test/{hipfile-cufile.cpp => nvidia_detail/cufile-api-compat.cpp} (98%) diff --git a/hipfile/test/CMakeLists.txt b/hipfile/test/CMakeLists.txt index ca0d41f2..893e66df 100644 --- a/hipfile/test/CMakeLists.txt +++ b/hipfile/test/CMakeLists.txt @@ -17,7 +17,6 @@ set(SHARED_TEST_INCLUDE_PATH # These tests do not require a HIP capable GPU. # They should pass on a CPU-only system. set(UNIT_TEST_SOURCE_FILES - main.cpp ) # These tests call into the GPU Driver. @@ -38,7 +37,7 @@ set(TEST_SYSINCLS ) if(BUILD_NVIDIA_DETAIL) - list(APPEND UNIT_TEST_SOURCE_FILES hipfile-cufile.cpp) + list(APPEND UNIT_TEST_SOURCE_FILES nvidia_detail/cufile-api-compat.cpp) list(APPEND TEST_SYSINCLS ${HIPFILE_NVIDIA_SOURCE_PATH}) else() list(APPEND TEST_SYSINCLS ${HIPFILE_AMD_SOURCE_PATH}) diff --git a/hipfile/test/main.cpp b/hipfile/test/main.cpp deleted file mode 100644 index 1c8b8000..00000000 --- a/hipfile/test/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ - -#include "hipfile-warnings.h" -#include "invalid-enum.h" - -#include -#include - -using namespace std; - -// Put tests inside the macros to suppress the global constructor -// warnings -HIPFILE_WARN_NO_GLOBAL_CTOR_OFF - -TEST(Helpers, invalidEnum) -{ - enum foo { - a = -7, - b = 12, - }; - ASSERT_EQ(invalidEnum(a - 1), -8); - ASSERT_EQ(invalidEnum(a + 1), -6); - ASSERT_EQ(invalidEnum(b - 1), 11); - ASSERT_EQ(invalidEnum(b + 1), 13); -} - -HIPFILE_WARN_NO_GLOBAL_CTOR_ON diff --git a/hipfile/test/hipfile-cufile.cpp b/hipfile/test/nvidia_detail/cufile-api-compat.cpp similarity index 98% rename from hipfile/test/hipfile-cufile.cpp rename to hipfile/test/nvidia_detail/cufile-api-compat.cpp index 7649b1ee..af3b9f4e 100644 --- a/hipfile/test/hipfile-cufile.cpp +++ b/hipfile/test/nvidia_detail/cufile-api-compat.cpp @@ -14,10 +14,13 @@ #include #include -#ifdef __HIP_PLATFORM_NVIDIA__ #include #include -#endif + +/* These tests exist to ensure that the hipFile API stays compatible + * with the cuFile API. They check that things like struct members, + * enum values, etc. align with cufile.h. + */ // Put tests inside the macros to suppress the global constructor // warnings From dd1264cb4dcbc9b0675ab51135579ea90af01de4 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 00:46:59 -0700 Subject: [PATCH 09/48] Move test headers to test/common --- hipfile/CMakeLists.txt | 2 +- hipfile/test/CMakeLists.txt | 2 +- hipfile/test/amd_detail/CMakeLists.txt | 2 +- hipfile/test/{ => common}/test-common.h | 0 hipfile/test/{ => common}/test-shared-fixtures.h | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename hipfile/test/{ => common}/test-common.h (100%) rename hipfile/test/{ => common}/test-shared-fixtures.h (100%) diff --git a/hipfile/CMakeLists.txt b/hipfile/CMakeLists.txt index 39d919f1..0124c7fe 100644 --- a/hipfile/CMakeLists.txt +++ b/hipfile/CMakeLists.txt @@ -10,7 +10,7 @@ project("hipfile" DESCRIPTION "hipFile library" LANGUAGES CXX HIP) set(HIPFILE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") set(HIPFILE_AMD_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/amd_detail") set(HIPFILE_NVIDIA_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/nvidia_detail") -set(HIPFILE_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test") +set(HIPFILE_TEST_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/common") set(HIPFILE_AMD_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/amd_detail") # Add the src directory depending on the HIP platform diff --git a/hipfile/test/CMakeLists.txt b/hipfile/test/CMakeLists.txt index 893e66df..e546b1ab 100644 --- a/hipfile/test/CMakeLists.txt +++ b/hipfile/test/CMakeLists.txt @@ -32,7 +32,7 @@ set(SYSTEM_TEST_SOURCE_FILES set(TEST_SYSINCLS ${HIPFILE_INCLUDE_PATH} - ${HIPFILE_TEST_PATH} + ${HIPFILE_TEST_INCLUDE_PATH} ${SHARED_TEST_INCLUDE_PATH} ) diff --git a/hipfile/test/amd_detail/CMakeLists.txt b/hipfile/test/amd_detail/CMakeLists.txt index fc12fac1..72be741c 100644 --- a/hipfile/test/amd_detail/CMakeLists.txt +++ b/hipfile/test/amd_detail/CMakeLists.txt @@ -32,7 +32,7 @@ set(TEST_SOURCE_FILES set(TEST_SYSINCLS ${HIPFILE_AMD_SOURCE_PATH} ${HIPFILE_INCLUDE_PATH} - ${HIPFILE_TEST_PATH} + ${HIPFILE_TEST_INCLUDE_PATH} ${HIPFILE_AMD_TEST_PATH} ${SHARED_TEST_INCLUDE_PATH} ) diff --git a/hipfile/test/test-common.h b/hipfile/test/common/test-common.h similarity index 100% rename from hipfile/test/test-common.h rename to hipfile/test/common/test-common.h diff --git a/hipfile/test/test-shared-fixtures.h b/hipfile/test/common/test-shared-fixtures.h similarity index 100% rename from hipfile/test/test-shared-fixtures.h rename to hipfile/test/common/test-shared-fixtures.h From c2e222575fcefe04e2acc3bc229bf474f7fabd87 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 00:54:52 -0700 Subject: [PATCH 10/48] Add a README.md file that explains the test directory --- hipfile/test/README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 hipfile/test/README.md diff --git a/hipfile/test/README.md b/hipfile/test/README.md new file mode 100644 index 00000000..c4383974 --- /dev/null +++ b/hipfile/test/README.md @@ -0,0 +1,31 @@ +# hipFile Test Directories + +## `amd_detail` + +AMD-specific tests. Primarily consists of tests of the internals +of hipFile. + +## `common` + +Header and source files that are used by multiple test programs. + +## `legacy` + +A couple of test programs from the early days of hipFile. They are +built but require a bit of setup to run properly and are thus not +in CI. + +These will be removed when we have more extensive testing. + +## `nvidia_detail` + +NVIDIA-specific tests. Currently limited to API compatibility tests. + +## `system` + +hipFile API unit tests that require a GPU go here. These should run on +both AMD and NVIDIA. + +## `unit` + +Doesn't exist yet, but any hipFile unit tests that don't require a GPU would go here. From 7250b537f2db3337fd2af2c5f208523f8e131a55 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 01:06:34 -0700 Subject: [PATCH 11/48] Move magic-word.h/cpp to the test directory --- hipfile/test/CMakeLists.txt | 7 +------ hipfile/test/amd_detail/CMakeLists.txt | 7 +------ {shared/test => hipfile/test/common}/magic-word.cpp | 0 {shared/test => hipfile/test/common}/magic-word.h | 0 4 files changed, 2 insertions(+), 12 deletions(-) rename {shared/test => hipfile/test/common}/magic-word.cpp (100%) rename {shared/test => hipfile/test/common}/magic-word.h (100%) diff --git a/hipfile/test/CMakeLists.txt b/hipfile/test/CMakeLists.txt index e546b1ab..d8bfc736 100644 --- a/hipfile/test/CMakeLists.txt +++ b/hipfile/test/CMakeLists.txt @@ -7,11 +7,7 @@ include(AISUseGTest) find_package(Boost COMPONENTS program_options REQUIRED) set(SHARED_SOURCE_FILES - "${CMAKE_SOURCE_DIR}/shared/test/magic-word.cpp" -) - -set(SHARED_TEST_INCLUDE_PATH - "${CMAKE_SOURCE_DIR}/shared/test/" + common/magic-word.cpp ) # These tests do not require a HIP capable GPU. @@ -33,7 +29,6 @@ set(SYSTEM_TEST_SOURCE_FILES set(TEST_SYSINCLS ${HIPFILE_INCLUDE_PATH} ${HIPFILE_TEST_INCLUDE_PATH} - ${SHARED_TEST_INCLUDE_PATH} ) if(BUILD_NVIDIA_DETAIL) diff --git a/hipfile/test/amd_detail/CMakeLists.txt b/hipfile/test/amd_detail/CMakeLists.txt index 72be741c..a31c3ba2 100644 --- a/hipfile/test/amd_detail/CMakeLists.txt +++ b/hipfile/test/amd_detail/CMakeLists.txt @@ -6,11 +6,7 @@ include(AISAddExecutable) include(AISUseGTest) set(SHARED_SOURCE_FILES - "${CMAKE_SOURCE_DIR}/shared/test/magic-word.cpp" -) - -set(SHARED_TEST_INCLUDE_PATH - "${CMAKE_SOURCE_DIR}/shared/test/" + "${CMAKE_SOURCE_DIR}/hipfile/test/common/magic-word.cpp" ) set(TEST_SOURCE_FILES @@ -34,7 +30,6 @@ set(TEST_SYSINCLS ${HIPFILE_INCLUDE_PATH} ${HIPFILE_TEST_INCLUDE_PATH} ${HIPFILE_AMD_TEST_PATH} - ${SHARED_TEST_INCLUDE_PATH} ) ais_add_executable( diff --git a/shared/test/magic-word.cpp b/hipfile/test/common/magic-word.cpp similarity index 100% rename from shared/test/magic-word.cpp rename to hipfile/test/common/magic-word.cpp diff --git a/shared/test/magic-word.h b/hipfile/test/common/magic-word.h similarity index 100% rename from shared/test/magic-word.h rename to hipfile/test/common/magic-word.h From ba39b91104c78976a2b7cd96ffa60cebb4f350d3 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 01:10:36 -0700 Subject: [PATCH 12/48] Move test-options.h and invalid-enum.h Moved to hipfile/test/common --- {shared => hipfile/test/common}/invalid-enum.h | 0 {shared => hipfile/test/common}/test-options.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {shared => hipfile/test/common}/invalid-enum.h (100%) rename {shared => hipfile/test/common}/test-options.h (100%) diff --git a/shared/invalid-enum.h b/hipfile/test/common/invalid-enum.h similarity index 100% rename from shared/invalid-enum.h rename to hipfile/test/common/invalid-enum.h diff --git a/shared/test-options.h b/hipfile/test/common/test-options.h similarity index 100% rename from shared/test-options.h rename to hipfile/test/common/test-options.h From fa316daf555404558adbc014f759f4f07248a683 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 01:13:29 -0700 Subject: [PATCH 13/48] Minor comment change in magic-word.h --- hipfile/test/common/magic-word.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hipfile/test/common/magic-word.h b/hipfile/test/common/magic-word.h index 1532a2db..c94f008d 100644 --- a/hipfile/test/common/magic-word.h +++ b/hipfile/test/common/magic-word.h @@ -22,8 +22,8 @@ static const char *message = "Ah ah ah, you didn't say the magic word!\n" " | /\n" " \\ /\n" "\n" - "hipFile/rocFile tests should be run using ctest. ctest runs each test in\n" - "an isolated process, which prevents side effects from affecting subsequent\n" + "hipFile tests should be run using ctest. ctest runs each test in an\n" + "isolated process, which prevents side effects from affecting subsequent\n" "tests. Running the test binaries directly may result in test errors if\n" "running multiple tests.\n"; From 89a9bd86d24925c619a1fe03472fefb7e5031d1c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 01:45:19 -0700 Subject: [PATCH 14/48] Only use hipfile.h * Includes rocfile.h in hipfile.h * Replace rocfile.h with hipfile.h * Move hoff_t from shared/hipfile-types.h to hipfile.h * Remove hipfile-types.h --- cmake/AISInstall.cmake | 6 ------ hipfile/include/hipfile.h | 17 ++++++++++++++- hipfile/include/rocfile.h | 1 - hipfile/src/amd_detail/async.cpp | 1 + hipfile/src/amd_detail/async.h | 2 +- .../src/amd_detail/backend/asyncop-fallback.h | 1 - hipfile/src/amd_detail/backend/fallback.h | 1 - hipfile/src/amd_detail/backend/fastpath.h | 1 - hipfile/src/amd_detail/batch/batch.cpp | 2 +- hipfile/src/amd_detail/batch/batch.h | 2 +- hipfile/src/amd_detail/file.h | 2 +- hipfile/src/amd_detail/hipfile-rocfile.h | 2 -- hipfile/src/amd_detail/hipfile.cpp | 4 +--- hipfile/src/amd_detail/rocfile-private.h | 3 +-- hipfile/src/amd_detail/rocfile.cpp | 3 +-- hipfile/src/amd_detail/state.h | 2 +- hipfile/src/amd_detail/stream.cpp | 2 +- hipfile/src/nvidia_detail/hipfile.cpp | 1 - hipfile/test/amd_detail/async.cpp | 2 +- hipfile/test/amd_detail/batch/batch.cpp | 2 +- hipfile/test/amd_detail/batch/batch_mt.cpp | 2 +- hipfile/test/amd_detail/buffer.cpp | 2 +- hipfile/test/amd_detail/driver.cpp | 2 +- hipfile/test/amd_detail/fallback.cpp | 3 +-- hipfile/test/amd_detail/handle.cpp | 2 +- hipfile/test/amd_detail/mfile.h | 2 +- hipfile/test/amd_detail/misc.cpp | 2 +- hipfile/test/amd_detail/rocfile-test.h | 2 +- hipfile/test/amd_detail/rocfile.cpp | 3 +-- hipfile/test/amd_detail/state_mt.cpp | 2 +- hipfile/test/amd_detail/stream.cpp | 2 +- shared/hipfile-types.h | 21 ------------------- 32 files changed, 39 insertions(+), 63 deletions(-) delete mode 100644 shared/hipfile-types.h diff --git a/cmake/AISInstall.cmake b/cmake/AISInstall.cmake index e6792dbe..d7118a7d 100644 --- a/cmake/AISInstall.cmake +++ b/cmake/AISInstall.cmake @@ -18,12 +18,6 @@ rocm_install( DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -# Always install the hipfile-types.h file -rocm_install( - FILES ${CMAKE_SOURCE_DIR}/shared/hipfile-types.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) - # rocm_package_add_dependencies() line should go here # when we have dependencies diff --git a/hipfile/include/hipfile.h b/hipfile/include/hipfile.h index c2e58218..3a14d47f 100644 --- a/hipfile/include/hipfile.h +++ b/hipfile/include/hipfile.h @@ -5,7 +5,6 @@ #pragma once -#include #include #include #include @@ -83,6 +82,20 @@ extern "C" { */ #define HIPFILE_VERSION_PATCH 0 +// *********************************************************************** +// PLATFORM-INDEPENDENT TYPES +// *********************************************************************** + +/*! + * @brief Platform-independent offset type + * @ingroup core + */ +#ifndef _WIN32 +typedef off_t hoff_t; +#else +typedef __int64 hoff_t; +#endif + // *********************************************************************** // ERROR HANDLING // *********************************************************************** @@ -1097,3 +1110,5 @@ hipFileError_t hipFileSetParameterString(hipFileStringConfigParameter_t param, c #ifdef __cplusplus } #endif + +#include diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 6241d1b1..1d63ba2d 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -5,7 +5,6 @@ #pragma once -#include #include #include #include diff --git a/hipfile/src/amd_detail/async.cpp b/hipfile/src/amd_detail/async.cpp index 4d30cc07..40eb9808 100644 --- a/hipfile/src/amd_detail/async.cpp +++ b/hipfile/src/amd_detail/async.cpp @@ -5,6 +5,7 @@ #include "async.h" #include "context.h" +#include "hipfile.h" #include "stream.h" #include "sys.h" diff --git a/hipfile/src/amd_detail/async.h b/hipfile/src/amd_detail/async.h index dbb6e3de..aeb9f951 100644 --- a/hipfile/src/amd_detail/async.h +++ b/hipfile/src/amd_detail/async.h @@ -4,7 +4,7 @@ */ #pragma once -#include "hipfile-types.h" +#include "hipfile.h" #include #include diff --git a/hipfile/src/amd_detail/backend/asyncop-fallback.h b/hipfile/src/amd_detail/backend/asyncop-fallback.h index 98398e25..43958aef 100644 --- a/hipfile/src/amd_detail/backend/asyncop-fallback.h +++ b/hipfile/src/amd_detail/backend/asyncop-fallback.h @@ -5,7 +5,6 @@ #pragma once #include "async.h" -#include "hipfile-types.h" #include #include diff --git a/hipfile/src/amd_detail/backend/fallback.h b/hipfile/src/amd_detail/backend/fallback.h index 9213d67c..e9f5b161 100644 --- a/hipfile/src/amd_detail/backend/fallback.h +++ b/hipfile/src/amd_detail/backend/fallback.h @@ -6,7 +6,6 @@ #pragma once #include "backend.h" -#include "hipfile-types.h" #include #include diff --git a/hipfile/src/amd_detail/backend/fastpath.h b/hipfile/src/amd_detail/backend/fastpath.h index 33032b44..85132dc9 100644 --- a/hipfile/src/amd_detail/backend/fastpath.h +++ b/hipfile/src/amd_detail/backend/fastpath.h @@ -6,7 +6,6 @@ #pragma once #include "backend.h" -#include "hipfile-types.h" #include #include diff --git a/hipfile/src/amd_detail/batch/batch.cpp b/hipfile/src/amd_detail/batch/batch.cpp index e6aa3600..407023d5 100644 --- a/hipfile/src/amd_detail/batch/batch.cpp +++ b/hipfile/src/amd_detail/batch/batch.cpp @@ -7,7 +7,7 @@ #include "buffer.h" #include "context.h" #include "file.h" -#include "rocfile.h" +#include "hipfile.h" #include "state.h" #include diff --git a/hipfile/src/amd_detail/batch/batch.h b/hipfile/src/amd_detail/batch/batch.h index def314a0..a7ef74f4 100644 --- a/hipfile/src/amd_detail/batch/batch.h +++ b/hipfile/src/amd_detail/batch/batch.h @@ -5,7 +5,7 @@ #pragma once -#include "rocfile.h" +#include "hipfile.h" #include #include diff --git a/hipfile/src/amd_detail/file.h b/hipfile/src/amd_detail/file.h index 8a037d73..1f2707cf 100644 --- a/hipfile/src/amd_detail/file.h +++ b/hipfile/src/amd_detail/file.h @@ -5,7 +5,7 @@ #pragma once -#include "rocfile.h" +#include "hipfile.h" #include "mountinfo.h" #include diff --git a/hipfile/src/amd_detail/hipfile-rocfile.h b/hipfile/src/amd_detail/hipfile-rocfile.h index ff776a1d..6436d3b7 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.h +++ b/hipfile/src/amd_detail/hipfile-rocfile.h @@ -9,8 +9,6 @@ #include "hipfile.h" -#include "rocfile.h" - // rocFile to hipFile //////////////////////////////////////////////////////// hipFileOpError_t toHipFileOpError(rocFileOpError_t status); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index f7970a62..9a0a5332 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -3,10 +3,8 @@ * SPDX-License-Identifier: MIT */ -#include "hipfile-rocfile.h" -#include "hipfile-types.h" #include "hipfile.h" -#include "rocfile.h" +#include "hipfile-rocfile.h" #include #include diff --git a/hipfile/src/amd_detail/rocfile-private.h b/hipfile/src/amd_detail/rocfile-private.h index 48173fe5..97b441af 100644 --- a/hipfile/src/amd_detail/rocfile-private.h +++ b/hipfile/src/amd_detail/rocfile-private.h @@ -5,8 +5,7 @@ #pragma once -#include "hipfile-types.h" -#include "rocfile.h" +#include "hipfile.h" #include #include diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index b5c55602..8cd5e53c 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -9,10 +9,9 @@ #include "context.h" #include "file.h" #include "hip.h" -#include "hipfile-types.h" +#include "hipfile.h" #include "hipfile-warnings.h" #include "io.h" -#include "rocfile.h" #include "rocfile-private.h" #include "state.h" #include "sys.h" diff --git a/hipfile/src/amd_detail/state.h b/hipfile/src/amd_detail/state.h index f1f84315..f0e77d8c 100644 --- a/hipfile/src/amd_detail/state.h +++ b/hipfile/src/amd_detail/state.h @@ -9,7 +9,7 @@ #include "batch/batch.h" #include "buffer.h" #include "file.h" -#include "rocfile.h" +#include "hipfile.h" #include "stream.h" #include diff --git a/hipfile/src/amd_detail/stream.cpp b/hipfile/src/amd_detail/stream.cpp index 23bf1e7b..57c28a8a 100644 --- a/hipfile/src/amd_detail/stream.cpp +++ b/hipfile/src/amd_detail/stream.cpp @@ -3,7 +3,7 @@ * SPDX-License-Identifier: MIT */ #include "context.h" -#include "rocfile.h" +#include "hipfile.h" #include "stream.h" #include "sys.h" diff --git a/hipfile/src/nvidia_detail/hipfile.cpp b/hipfile/src/nvidia_detail/hipfile.cpp index 7e23022c..c3de95fe 100644 --- a/hipfile/src/nvidia_detail/hipfile.cpp +++ b/hipfile/src/nvidia_detail/hipfile.cpp @@ -5,7 +5,6 @@ #include "hipfile.h" #include "hipfile-cufile.h" -#include "hipfile-types.h" #include #include diff --git a/hipfile/test/amd_detail/async.cpp b/hipfile/test/amd_detail/async.cpp index 14f32c10..989edfbe 100644 --- a/hipfile/test/amd_detail/async.cpp +++ b/hipfile/test/amd_detail/async.cpp @@ -6,6 +6,7 @@ #include "async.h" #include "backend/asyncop-fallback.h" #include "hip.h" +#include "hipfile.h" #include "hipfile-warnings.h" #include "io.h" #include "mbuffer.h" @@ -13,7 +14,6 @@ #include "mhip.h" #include "mstream.h" #include "msys.h" -#include "rocfile.h" #include #include diff --git a/hipfile/test/amd_detail/batch/batch.cpp b/hipfile/test/amd_detail/batch/batch.cpp index 0285102b..1f69f43c 100644 --- a/hipfile/test/amd_detail/batch/batch.cpp +++ b/hipfile/test/amd_detail/batch/batch.cpp @@ -6,12 +6,12 @@ #include "batch/batch.h" #include "buffer.h" #include "file.h" +#include "hipfile.h" #include "hipfile-warnings.h" #include "invalid-enum.h" #include "mbuffer.h" #include "mfile.h" #include "mstate.h" -#include "rocfile.h" #include "rocfile-test.h" #include "state.h" diff --git a/hipfile/test/amd_detail/batch/batch_mt.cpp b/hipfile/test/amd_detail/batch/batch_mt.cpp index c932f976..e121beef 100644 --- a/hipfile/test/amd_detail/batch/batch_mt.cpp +++ b/hipfile/test/amd_detail/batch/batch_mt.cpp @@ -9,7 +9,7 @@ // #include "batch/batch.h" -#include "rocfile.h" +#include "hipfile.h" #include #include diff --git a/hipfile/test/amd_detail/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp index 133cd190..fcfa71ec 100644 --- a/hipfile/test/amd_detail/buffer.cpp +++ b/hipfile/test/amd_detail/buffer.cpp @@ -6,9 +6,9 @@ #include "buffer.h" #include "context.h" #include "hip.h" +#include "hipfile.h" #include "hipfile-warnings.h" #include "mhip.h" -#include "rocfile.h" #include "rocfile-test.h" #include "state.h" diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index f94f46c6..6dd98bb3 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -3,11 +3,11 @@ * SPDX-License-Identifier: MIT */ +#include "hipfile.h" #include "hipfile-warnings.h" #include "mhip.h" #include "mmountinfo.h" #include "msys.h" -#include "rocfile.h" #include "rocfile-test.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/fallback.cpp b/hipfile/test/amd_detail/fallback.cpp index 7a4b4f7e..f638ea0f 100644 --- a/hipfile/test/amd_detail/fallback.cpp +++ b/hipfile/test/amd_detail/fallback.cpp @@ -8,7 +8,7 @@ #include "buffer.h" #include "context.h" #include "hip.h" -#include "hipfile-types.h" +#include "hipfile.h" #include "hipfile-warnings.h" #include "io.h" #include "mbuffer.h" @@ -16,7 +16,6 @@ #include "mhip.h" #include "mmountinfo.h" #include "msys.h" -#include "rocfile.h" #include "rocfile-test.h" #include "state.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index 1bf69b80..5fd0981f 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -5,11 +5,11 @@ #include "context.h" #include "file.h" +#include "hipfile.h" #include "hipfile-warnings.h" #include "msys.h" #include "mmountinfo.h" #include "mountinfo.h" -#include "rocfile.h" #include "rocfile-test.h" #include "state.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/mfile.h b/hipfile/test/amd_detail/mfile.h index 967ee748..9ee15405 100644 --- a/hipfile/test/amd_detail/mfile.h +++ b/hipfile/test/amd_detail/mfile.h @@ -6,7 +6,7 @@ #pragma once #include "file.h" -#include "rocfile.h" +#include "hipfile.h" #include diff --git a/hipfile/test/amd_detail/misc.cpp b/hipfile/test/amd_detail/misc.cpp index d0a24eca..ce4741bc 100644 --- a/hipfile/test/amd_detail/misc.cpp +++ b/hipfile/test/amd_detail/misc.cpp @@ -4,8 +4,8 @@ */ #include "context.h" +#include "hipfile.h" #include "hipfile-warnings.h" -#include "rocfile.h" #include "rocfile-test.h" #include diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h index da537f18..c9a54aeb 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/rocfile-test.h @@ -7,12 +7,12 @@ // Common rocFile test functionality +#include "hipfile.h" #include "magic-word.h" #include "mhip.h" #include "mmountinfo.h" #include "msys.h" #include "rocfile-test.h" -#include "rocfile.h" #include #include diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index 5b1bcff5..0cbd4a24 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -14,7 +14,7 @@ #include "batch/batch.h" #include "context.h" #include "hip.h" -#include "hipfile-types.h" +#include "hipfile.h" #include "hipfile-warnings.h" #include "io.h" #include "mbackend.h" @@ -27,7 +27,6 @@ #include "msys.h" #include "rocfile-private.h" #include "rocfile-test.h" -#include "rocfile.h" #include "state.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/state_mt.cpp b/hipfile/test/amd_detail/state_mt.cpp index 6d77e715..87614ab3 100644 --- a/hipfile/test/amd_detail/state_mt.cpp +++ b/hipfile/test/amd_detail/state_mt.cpp @@ -8,7 +8,7 @@ // Just run the program. It takes no special arguments. #include "context.h" -#include "rocfile.h" +#include "hipfile.h" #include "state.h" #include diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index a4424f7b..dd61fc7f 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -3,10 +3,10 @@ * SPDX-License-Identifier: MIT */ +#include "hipfile.h" #include "hipfile-warnings.h" #include "mhip.h" #include "msys.h" -#include "rocfile.h" #include "rocfile-test.h" #include "stream.h" diff --git a/shared/hipfile-types.h b/shared/hipfile-types.h deleted file mode 100644 index 9d7cf75b..00000000 --- a/shared/hipfile-types.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ -#pragma once - -#include - -// *********************************************************************** -// PLATFORM-INDEPENDENT TYPES -// *********************************************************************** - -/*! - * @brief Platform-independent offset type - * @ingroup core - */ -#ifndef _WIN32 -typedef off_t hoff_t; -#else -typedef __int64 hoff_t; -#endif From a78f562727497db9dd7ca9776fdedafb5a096a66 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 01:55:07 -0700 Subject: [PATCH 15/48] Remove rocFile error macros --- hipfile/docs/errors.rst | 4 +-- hipfile/include/rocfile.h | 60 --------------------------------------- 2 files changed, 2 insertions(+), 62 deletions(-) diff --git a/hipfile/docs/errors.rst b/hipfile/docs/errors.rst index 44e3392f..655ef812 100644 --- a/hipfile/docs/errors.rst +++ b/hipfile/docs/errors.rst @@ -31,8 +31,8 @@ be set to ``hipSuccess``. Several helper macros are included in ``hipfile.h`` that help with error checking: -* ``IS_ROCFILE_ERR()`` -* ``ROCFILE_ERRSTR()`` +* ``IS_HIPFILE_ERR()`` +* ``HIPFILE_ERRSTR()`` * ``IS_HIP_DRV_ERR()`` * ``HIP_DRV_ERR()`` diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 1d63ba2d..42568e17 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -177,66 +177,6 @@ typedef struct __ROCFILE_NODISCARD rocFileError { hipError_t hip_drv_err; //!< Errors related to the GPU driver } rocFileError_t; -/*! - * @brief Determine if an error code is a rocFile error - * @ingroup error - * @hideinitializer - * - * Signature - * @code - * bool IS_ROCFILE_ERR(rocFileOpError err) - * @endcode - * - * @return true/false - */ -#define IS_ROCFILE_ERR(err) (abs((int)err) > ROCFILE_BASE_ERR) - -/*! - * @brief Get an error string for a rocFile error - * @ingroup error - * @hideinitializer - * - * Signature - * @code - * const char *ROCFILE_ERRSTR(rocFileOpError err) - * @endcode - * - * @return A string description of a rocFile error - */ -#define ROCFILE_ERRSTR(err) rocFileOpStatusError((rocFileOpError_t)abs(err)) - -/*! - * @brief Determine if an error is a rocFile driver error - * @ingroup error - * @hideinitializer - * - * Signature - * @code - * bool IS_HIP_DRV_ERR(rocFileError_t err) - * @endcode - * - * @return true/false - */ -#ifndef IS_HIP_DRV_ERR -#define IS_HIP_DRV_ERR(err) ((err).err == rocFileHipDriverError) -#endif - -/*! - * @brief Get the driver error from a rocFileError_t - * @ingroup error - * @hideinitializer - * - * Signature - * @code - * hipError_t HIP_DRV_ERR(rocFileError_t err) - * @endcode - * - * @return The hipError_t component of err - */ -#ifndef HIP_DRV_ERR -#define HIP_DRV_ERR(err) ((err).hip_drv_err) -#endif - // *********************************************************************** // GPU IO DRIVER API // *********************************************************************** From cefb2ec402232d5ae4be4bce3d11c67cbc480e43 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 01:58:18 -0700 Subject: [PATCH 16/48] Remove misc commenting from rocfile.h --- hipfile/include/rocfile.h | 55 --------------------------------------- 1 file changed, 55 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 42568e17..722a9a9f 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -21,47 +21,6 @@ extern "C" { #endif -// *********************************************************************** -// DOXYGEN SETUP -// *********************************************************************** - -// Without the `file`/`defgroup` directives, Doxgyen will not emit -// documentation for anything aside from structs in a C header. -// -// *ALL* Doxygen comment blocks should have an `ingroup` directive so they -// group properly in the output. - -/** - * @file - * - * @mainpage rocFile API Reference - * - * @section contents Contents - * - @ref core - * - @ref error - * - @ref driver - * - @ref rdma - * - @ref file - * - @ref batch - * - @ref async - */ - -/*! - * @defgroup core Core Functionality - * - * @defgroup error Errors and Error Handling - * - * @defgroup driver GPU IO Driver API - * - * @defgroup rdma Userspace RDMA API - * - * @defgroup file File Handle API - * - * @defgroup batch Batch API - * - * @defgroup async Async API - */ - // *********************************************************************** // LIBRARY VERSION NUMBERS // *********************************************************************** @@ -262,10 +221,6 @@ typedef struct rocFileDriverProps { // RDMA API // *********************************************************************** -/* - * NOTE: !! AIS UNSUPPORTED !! (Not related to NVMeoRDMA) - */ - /*! * @brief Userspace RDMA configuration * @ingroup rdma @@ -276,22 +231,12 @@ typedef struct rocFileRDMAInfo { const char *desc_str; //!< Describes the configuration of the RDMA operation } rocFileRDMAInfo_t; -/*! - * @defgroup rdma_flags RDMA Characteristic Flags - * @ingroup rdma - * - * @brief Bitwise flags for RDMA characteristics - * @{ - */ - /// Flag for if the RDMA operation is registered #define ROCFILE_RDMA_REGISTER 1 /// Flag for if the RDMA operation has relaxed ordering #define ROCFILE_RDMA_RELAXED_ORDERING (1 << 1) -/*! @} */ - // *********************************************************************** // FILE HANDLE API // *********************************************************************** From c0353430db98ca52a39d37ebfd30c346aaf4eb98 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 02:15:56 -0700 Subject: [PATCH 17/48] Remove the rocFile properties API --- hipfile/include/rocfile.h | 125 --------------------- hipfile/src/amd_detail/hipfile-rocfile.cpp | 81 ------------- hipfile/src/amd_detail/hipfile-rocfile.h | 6 - hipfile/src/amd_detail/hipfile.cpp | 54 --------- hipfile/src/amd_detail/rocfile.cpp | 58 +++++++--- 5 files changed, 40 insertions(+), 284 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 722a9a9f..dbd74774 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -749,131 +749,6 @@ rocFileError_t rocFileStreamDeregister(hipStream_t stream); ROCFILE_API rocFileError_t rocFileGetVersion(unsigned *major, unsigned *minor, unsigned *patch); -// *********************************************************************** -// PROPERTIES API -// *********************************************************************** - -/*! - * @brief size_t configuration parameters - * @ingroup core - */ -typedef enum rocFileSizeTConfigParameter_t { - rocFileParamProfileStats, //!< - rocFileParamExecutionMaxIOQueueDepth, //!< - rocFileParamExecutionMaxIOThreads, //!< - rocFileParamExecutionMinIOThresholdSizeKB, //!< - rocFileParamExecutionMaxRequestParallelism, //!< - rocFileParamPropertiesMaxDirectIOSizeKB, //!< - rocFileParamPropertiesMaxDeviceCacheSizeKB, //!< - rocFileParamPropertiesPerBufferCacheSizeKB, //!< - rocFileParamPropertiesMaxDevicePinnedMemSizeKB, //!< - rocFileParamPropertiesIOBatchsize, //!< - rocFileParamPollthresholdSizeKB, //!< - rocFileParamPropertiesBatchIOTimeoutMs, //!< -} rocFileSizeTConfigParameter_t; - -/*! - * @brief Boolean configuration parameters - * @ingroup core - */ -typedef enum rocFileBoolConfigParameter_t { - rocFileParamPropertiesUsePollMode, //!< - rocFileParamPropertiesAllowCompatMode, //!< - rocFileParamForceCompatMode, //!< - rocFileParamFsMiscApiCheckAggressive, //!< - rocFileParamExecutionParallelIO, //!< - rocFileParamProfileNvtx, //!< - rocFileParamPropertiesAllowSystemMemory, //!< - rocFileParamUsePcip2pdma, //!< - rocFileParamPreferIOUring, //!< - rocFileParamForceOdirectMode, //!< - rocFileParamSkipTopologyDetection, //!< - rocFileParamStreamMemopsBypass, //!< -} rocFileBoolConfigParameter_t; - -/*! - * @brief String configuration parameters - * @ingroup core - */ -typedef enum rocFileStringConfigParameter_t { - rocFileParamLoggingLevel, //!< - rocFileParamEnvLogfilePath, //!< - rocFileParamLogDir, //!< -} rocFileStringConfigParameter_t; - -/*! - * @brief Get the value of a size_t configuration parameter - * @ingroup core - * - * @param param The configuration parameter - * @param value The location to store the value of the configuration parameter - * - * @return rocFileSuccess - */ -ROCFILE_API -rocFileError_t rocFileGetParameterSizeT(rocFileSizeTConfigParameter_t param, size_t *value); - -/*! - * @brief Get the value of a Boolean configuration parameter - * @ingroup core - * - * @param param The configuration parameter - * @param value The location to store the value of the configuration parameter - * - * @return rocFileSuccess - */ -ROCFILE_API -rocFileError_t rocFileGetParameterBool(rocFileBoolConfigParameter_t param, bool *value); - -/*! - * @brief Get the value of a string configuration parameter - * @ingroup core - * - * @param param The configuration parameter - * @param desc_str The location to store the value of the configuration parameter - * @param len The length of the desc_str parameter - * - * @return rocFileSuccess - */ -ROCFILE_API -rocFileError_t rocFileGetParameterString(rocFileStringConfigParameter_t param, char *desc_str, int len); - -/*! - * @brief Set the value of a size_t configuration parameter - * @ingroup core - * - * @param param The configuration parameter - * @param value The value of the configuration parameter - * - * @return rocFileSuccess - */ -ROCFILE_API -rocFileError_t rocFileSetParameterSizeT(rocFileSizeTConfigParameter_t param, size_t value); - -/*! - * @brief Set the value of a Boolean configuration parameter - * @ingroup core - * - * @param param The configuration parameter - * @param value The value of the configuration parameter - * - * @return rocFileSuccess - */ -ROCFILE_API -rocFileError_t rocFileSetParameterBool(rocFileBoolConfigParameter_t param, bool value); - -/*! - * @brief Set the value of a string configuration parameter - * @ingroup core - * - * @param param The configuration parameter - * @param desc_str The value of the configuration parameter - * - * @return rocFileSuccess - */ -ROCFILE_API -rocFileError_t rocFileSetParameterString(rocFileStringConfigParameter_t param, const char *desc_str); - // Not a part of the public API #undef __ROCFILE_NODISCARD diff --git a/hipfile/src/amd_detail/hipfile-rocfile.cpp b/hipfile/src/amd_detail/hipfile-rocfile.cpp index 4e2e450e..1d27e5dd 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.cpp +++ b/hipfile/src/amd_detail/hipfile-rocfile.cpp @@ -236,84 +236,3 @@ toHipFileIOEvents(const rocFileIOEvents_t &rf_io_event) return hf_io_event; } - -rocFileSizeTConfigParameter_t -toRocFileSizeTConfigParameter(hipFileSizeTConfigParameter_t param) -{ - switch (param) { - case hipFileParamProfileStats: - return rocFileParamProfileStats; - case hipFileParamExecutionMaxIOQueueDepth: - return rocFileParamExecutionMaxIOQueueDepth; - case hipFileParamExecutionMaxIOThreads: - return rocFileParamExecutionMaxIOThreads; - case hipFileParamExecutionMinIOThresholdSizeKB: - return rocFileParamExecutionMinIOThresholdSizeKB; - case hipFileParamExecutionMaxRequestParallelism: - return rocFileParamExecutionMaxRequestParallelism; - case hipFileParamPropertiesMaxDirectIOSizeKB: - return rocFileParamPropertiesMaxDirectIOSizeKB; - case hipFileParamPropertiesMaxDeviceCacheSizeKB: - return rocFileParamPropertiesMaxDeviceCacheSizeKB; - case hipFileParamPropertiesPerBufferCacheSizeKB: - return rocFileParamPropertiesPerBufferCacheSizeKB; - case hipFileParamPropertiesMaxDevicePinnedMemSizeKB: - return rocFileParamPropertiesMaxDevicePinnedMemSizeKB; - case hipFileParamPropertiesIOBatchsize: - return rocFileParamPropertiesIOBatchsize; - case hipFileParamPollthresholdSizeKB: - return rocFileParamPollthresholdSizeKB; - case hipFileParamPropertiesBatchIOTimeoutMs: - return rocFileParamPropertiesBatchIOTimeoutMs; - default: - throw std::invalid_argument("Invalid hipFileSizeTConfigParameter_t value"); - } -} - -rocFileBoolConfigParameter_t -toRocFileBoolConfigParameter(hipFileBoolConfigParameter_t param) -{ - switch (param) { - case hipFileParamPropertiesUsePollMode: - return rocFileParamPropertiesUsePollMode; - case hipFileParamPropertiesAllowCompatMode: - return rocFileParamPropertiesAllowCompatMode; - case hipFileParamForceCompatMode: - return rocFileParamForceCompatMode; - case hipFileParamFsMiscApiCheckAggressive: - return rocFileParamFsMiscApiCheckAggressive; - case hipFileParamExecutionParallelIO: - return rocFileParamExecutionParallelIO; - case hipFileParamProfileNvtx: - return rocFileParamProfileNvtx; - case hipFileParamPropertiesAllowSystemMemory: - return rocFileParamPropertiesAllowSystemMemory; - case hipFileParamUsePcip2pdma: - return rocFileParamUsePcip2pdma; - case hipFileParamPreferIOUring: - return rocFileParamPreferIOUring; - case hipFileParamForceOdirectMode: - return rocFileParamForceOdirectMode; - case hipFileParamSkipTopologyDetection: - return rocFileParamSkipTopologyDetection; - case hipFileParamStreamMemopsBypass: - return rocFileParamStreamMemopsBypass; - default: - throw std::invalid_argument("Invalid hipFileBoolConfigParameter_t value"); - } -} - -rocFileStringConfigParameter_t -toRocFileStringConfigParameter(hipFileStringConfigParameter_t param) -{ - switch (param) { - case hipFileParamLoggingLevel: - return rocFileParamLoggingLevel; - case hipFileParamEnvLogfilePath: - return rocFileParamEnvLogfilePath; - case hipFileParamLogDir: - return rocFileParamLogDir; - default: - throw std::invalid_argument("Invalid hipFileStringConfigParameter_t value"); - } -} diff --git a/hipfile/src/amd_detail/hipfile-rocfile.h b/hipfile/src/amd_detail/hipfile-rocfile.h index 6436d3b7..0301f2ae 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.h +++ b/hipfile/src/amd_detail/hipfile-rocfile.h @@ -32,9 +32,3 @@ rocFileIOParams_t toRocFileIOParams(const hipFileIOParams_t &hf_io_params); rocFileOpcode_t toRocFileOpcode(hipFileOpcode_t hf_opcode); rocFileBatchMode toRocFileBatchMode(hipFileBatchMode_t hf_batch_mode); - -rocFileSizeTConfigParameter_t toRocFileSizeTConfigParameter(hipFileSizeTConfigParameter_t param); - -rocFileBoolConfigParameter_t toRocFileBoolConfigParameter(hipFileBoolConfigParameter_t param); - -rocFileStringConfigParameter_t toRocFileStringConfigParameter(hipFileStringConfigParameter_t param); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index 9a0a5332..30d05f57 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -302,57 +302,3 @@ try { catch (...) { return {hipFileInternalError, hipSuccess}; } - -hipFileError_t -hipFileGetParameterSizeT(hipFileSizeTConfigParameter_t param, size_t *value) -try { - return toHipFileError(rocFileGetParameterSizeT(toRocFileSizeTConfigParameter(param), value)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileGetParameterBool(hipFileBoolConfigParameter_t param, bool *value) -try { - return toHipFileError(rocFileGetParameterBool(toRocFileBoolConfigParameter(param), value)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileGetParameterString(hipFileStringConfigParameter_t param, char *desc_str, int len) -try { - return toHipFileError(rocFileGetParameterString(toRocFileStringConfigParameter(param), desc_str, len)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileSetParameterSizeT(hipFileSizeTConfigParameter_t param, size_t value) -try { - return toHipFileError(rocFileSetParameterSizeT(toRocFileSizeTConfigParameter(param), value)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileSetParameterBool(hipFileBoolConfigParameter_t param, bool value) -try { - return toHipFileError(rocFileSetParameterBool(toRocFileBoolConfigParameter(param), value)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileSetParameterString(hipFileStringConfigParameter_t param, const char *desc_str) -try { - return toHipFileError(rocFileSetParameterString(toRocFileStringConfigParameter(param), desc_str)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 8cd5e53c..746fb6f7 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -128,6 +128,24 @@ catch (...) { return {rocFileInternalError, hipSuccess}; } +/// Catch C++ exceptions from the hipFile code and convert +/// them into error values that can be returned from public +/// C API calls. +static inline hipFileError_t +handle_exception2() noexcept +try { + throw; +} +catch (hipFileError_t e) { + return e; +} +catch (const Hip::RuntimeError &e) { + return {hipFileHipDriverError, e.error}; +} +catch (...) { + return {hipFileInternalError, hipSuccess}; +} + rocFileError_t rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr) try { @@ -558,8 +576,12 @@ catch (...) { return handle_exception(); } -rocFileError_t -rocFileGetParameterSizeT(rocFileSizeTConfigParameter_t param, size_t *value) +// *********************************************************************** +// PROPERTIES API +// *********************************************************************** + +hipFileError_t +hipFileGetParameterSizeT(hipFileSizeTConfigParameter_t param, size_t *value) try { (void)param; (void)value; @@ -567,11 +589,11 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileGetParameterBool(rocFileBoolConfigParameter_t param, bool *value) +hipFileError_t +hipFileGetParameterBool(hipFileBoolConfigParameter_t param, bool *value) try { (void)param; (void)value; @@ -579,11 +601,11 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileGetParameterString(rocFileStringConfigParameter_t param, char *desc_str, int len) +hipFileError_t +hipFileGetParameterString(hipFileStringConfigParameter_t param, char *desc_str, int len) try { (void)param; (void)desc_str; @@ -592,11 +614,11 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileSetParameterSizeT(rocFileSizeTConfigParameter_t param, size_t value) +hipFileError_t +hipFileSetParameterSizeT(hipFileSizeTConfigParameter_t param, size_t value) try { (void)param; (void)value; @@ -604,11 +626,11 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileSetParameterBool(rocFileBoolConfigParameter_t param, bool value) +hipFileError_t +hipFileSetParameterBool(hipFileBoolConfigParameter_t param, bool value) try { (void)param; (void)value; @@ -616,11 +638,11 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileSetParameterString(rocFileStringConfigParameter_t param, const char *desc_str) +hipFileError_t +hipFileSetParameterString(hipFileStringConfigParameter_t param, const char *desc_str) try { (void)param; (void)desc_str; @@ -628,5 +650,5 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } From 2f37a42b556b4a35fcf46e95c47d327c527fc7c8 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 02:26:24 -0700 Subject: [PATCH 18/48] Remove the rocFile version API --- hipfile/include/rocfile.h | 39 -------------------------- hipfile/src/amd_detail/rocfile.cpp | 20 ------------- hipfile/test/amd_detail/CMakeLists.txt | 1 - hipfile/test/amd_detail/misc.cpp | 39 -------------------------- 4 files changed, 99 deletions(-) delete mode 100644 hipfile/test/amd_detail/misc.cpp diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index dbd74774..8c402e99 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -21,26 +21,6 @@ extern "C" { #endif -// *********************************************************************** -// LIBRARY VERSION NUMBERS -// *********************************************************************** - -/*! - * @brief rocFile major version number - * @ingroup core - */ -#define ROCFILE_VERSION_MAJOR 0 -/*! - * @brief rocFile minor version number - * @ingroup core - */ -#define ROCFILE_VERSION_MINOR 2 -/*! - * @brief rocFile patch version number - * @ingroup core - */ -#define ROCFILE_VERSION_PATCH 0 - // *********************************************************************** // ERROR HANDLING // *********************************************************************** @@ -730,25 +710,6 @@ rocFileError_t rocFileStreamRegister(hipStream_t stream, unsigned flags); ROCFILE_API rocFileError_t rocFileStreamDeregister(hipStream_t stream); -// *********************************************************************** -// CORE API -// *********************************************************************** - -/*! - * @brief Get the rocFile version - * @ingroup core - * - * @param [out] major The major version - * @param [out] minor The minor version - * @param [out] patch The patch version - * - * @note Parameters can be set to NULL to ignore that part of the version - * - * @return rocFileSuccess - */ -ROCFILE_API -rocFileError_t rocFileGetVersion(unsigned *major, unsigned *minor, unsigned *patch); - // Not a part of the public API #undef __ROCFILE_NODISCARD diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 746fb6f7..04b231d7 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -556,26 +556,6 @@ catch (...) { return handle_exception(); } -rocFileError_t -rocFileGetVersion(unsigned *major, unsigned *minor, unsigned *patch) -try { - // NULL parameters are ignored - if (major != nullptr) { - *major = ROCFILE_VERSION_MAJOR; - } - if (minor != nullptr) { - *minor = ROCFILE_VERSION_MINOR; - } - if (patch != nullptr) { - *patch = ROCFILE_VERSION_PATCH; - } - - return {rocFileSuccess, hipSuccess}; -} -catch (...) { - return handle_exception(); -} - // *********************************************************************** // PROPERTIES API // *********************************************************************** diff --git a/hipfile/test/amd_detail/CMakeLists.txt b/hipfile/test/amd_detail/CMakeLists.txt index a31c3ba2..8b5d153d 100644 --- a/hipfile/test/amd_detail/CMakeLists.txt +++ b/hipfile/test/amd_detail/CMakeLists.txt @@ -19,7 +19,6 @@ set(TEST_SOURCE_FILES hip.cpp fallback.cpp fastpath.cpp - misc.cpp mountinfo.cpp rocfile.cpp stream.cpp diff --git a/hipfile/test/amd_detail/misc.cpp b/hipfile/test/amd_detail/misc.cpp deleted file mode 100644 index ce4741bc..00000000 --- a/hipfile/test/amd_detail/misc.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ - -#include "context.h" -#include "hipfile.h" -#include "hipfile-warnings.h" -#include "rocfile-test.h" - -#include -#include -#include - -using namespace hipFile; - -// Put tests inside the macros to suppress the global constructor -// warnings -HIPFILE_WARN_NO_GLOBAL_CTOR_OFF - -struct RocFileVersioning : public RocFileUnopened {}; - -TEST_F(RocFileVersioning, Get) -{ - unsigned major = UINT_MAX; - unsigned minor = UINT_MAX; - unsigned patch = UINT_MAX; - - // Check for correct values - ASSERT_EQ(rocFileGetVersion(&major, &minor, &patch), ROCFILE_SUCCESS); - ASSERT_EQ(major, ROCFILE_VERSION_MAJOR); - ASSERT_EQ(minor, ROCFILE_VERSION_MINOR); - ASSERT_EQ(patch, ROCFILE_VERSION_PATCH); - - // NULL pointers should NOT produce errors - ASSERT_EQ(rocFileGetVersion(nullptr, nullptr, nullptr), ROCFILE_SUCCESS); -} - -HIPFILE_WARN_NO_GLOBAL_CTOR_ON From 3fce02f1c568e49b50497c08c1bd51d50859098b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 02:33:16 -0700 Subject: [PATCH 19/48] Rename rocfile-private.* to hipfile-private.* --- hipfile/src/amd_detail/CMakeLists.txt | 2 +- .../src/amd_detail/{rocfile-private.cpp => hipfile-private.cpp} | 2 +- hipfile/src/amd_detail/{rocfile-private.h => hipfile-private.h} | 0 hipfile/src/amd_detail/rocfile.cpp | 2 +- hipfile/test/amd_detail/rocfile.cpp | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename hipfile/src/amd_detail/{rocfile-private.cpp => hipfile-private.cpp} (90%) rename hipfile/src/amd_detail/{rocfile-private.h => hipfile-private.h} (100%) diff --git a/hipfile/src/amd_detail/CMakeLists.txt b/hipfile/src/amd_detail/CMakeLists.txt index 78b2a622..5de9a008 100644 --- a/hipfile/src/amd_detail/CMakeLists.txt +++ b/hipfile/src/amd_detail/CMakeLists.txt @@ -16,10 +16,10 @@ set(HIPFILE_SOURCES file.cpp hip.cpp hipfile.cpp + hipfile-private.cpp hipfile-rocfile.cpp mountinfo.cpp rocfile.cpp - rocfile-private.cpp state.cpp stream.cpp sys.cpp diff --git a/hipfile/src/amd_detail/rocfile-private.cpp b/hipfile/src/amd_detail/hipfile-private.cpp similarity index 90% rename from hipfile/src/amd_detail/rocfile-private.cpp rename to hipfile/src/amd_detail/hipfile-private.cpp index d5a65e4c..5b4f0d4c 100644 --- a/hipfile/src/amd_detail/rocfile-private.cpp +++ b/hipfile/src/amd_detail/hipfile-private.cpp @@ -4,7 +4,7 @@ */ #include "context.h" -#include "rocfile-private.h" +#include "hipfile-private.h" #include "state.h" void diff --git a/hipfile/src/amd_detail/rocfile-private.h b/hipfile/src/amd_detail/hipfile-private.h similarity index 100% rename from hipfile/src/amd_detail/rocfile-private.h rename to hipfile/src/amd_detail/hipfile-private.h diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 04b231d7..9b15e94e 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -10,9 +10,9 @@ #include "file.h" #include "hip.h" #include "hipfile.h" +#include "hipfile-private.h" #include "hipfile-warnings.h" #include "io.h" -#include "rocfile-private.h" #include "state.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index 0cbd4a24..907064e6 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -15,6 +15,7 @@ #include "context.h" #include "hip.h" #include "hipfile.h" +#include "hipfile-private.h" #include "hipfile-warnings.h" #include "io.h" #include "mbackend.h" @@ -25,7 +26,6 @@ #include "mmountinfo.h" #include "mstate.h" #include "msys.h" -#include "rocfile-private.h" #include "rocfile-test.h" #include "state.h" #include "sys.h" From 62531d8a89617d3ae11c04b858d1160c8655e6e9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 02:42:37 -0700 Subject: [PATCH 20/48] Remove misc unimplemented rocFile getters --- hipfile/include/rocfile.h | 57 ----------------------------- hipfile/src/amd_detail/hipfile.cpp | 58 ------------------------------ hipfile/src/amd_detail/rocfile.cpp | 30 ++++++++-------- 3 files changed, 15 insertions(+), 130 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 8c402e99..ee3d00d9 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -423,63 +423,6 @@ rocFileError_t rocFileDriverClose(void); ROCFILE_API int64_t rocFileUseCount(void); -/*! - * @brief Get a list of GPU IO driver properties - * @ingroup driver - * - * @param [out] props See `rocFileDriverProps_t` for what properties are reported - * - * @return A rocFile error - */ -ROCFILE_API -rocFileError_t rocFileDriverGetProperties(rocFileDriverProps_t *props); - -/*! - * @brief Enable/disable polling mode for GPU IO - * @ingroup driver - * - * @param [in] poll `true` to enable polling, `false` to disable - * @param [in] poll_threshold_size Maximum IO size (in KiB) for which polling is - * used when enabled - * - * @return A rocFile error - */ -ROCFILE_API -rocFileError_t rocFileDriverSetPollMode(bool poll, size_t poll_threshold_size); - -/*! - * @brief Set the maximum IO chunk size - * @ingroup driver - * - * @param [in] max_direct_io_size Maximum IO chunk size (in KiB) for each IO request - * - * @return A rocFile error - */ -ROCFILE_API -rocFileError_t rocFileDriverSetMaxDirectIOSize(size_t max_direct_io_size); - -/*! - * @brief Set the maximum amount of GPU memory that can be used for bounce buffers - * @ingroup driver - * - * @param [in] max_cache_size Maximum GPU memory (in KiB) that can be reserved for bounce buffers - * - * @return A rocFile error - */ -ROCFILE_API -rocFileError_t rocFileDriverSetMaxCacheSize(size_t max_cache_size); - -/*! - * @brief Set the maximum amount of GPU memory that can be pinned - * @ingroup driver - * - * @param [in] max_pinned_size Maximum GPU memory (in KiB) that can be pinned - * - * @return A rocFile error - */ -ROCFILE_API -rocFileError_t rocFileDriverSetMaxPinnedMemSize(size_t max_pinned_size); - // *********************************************************************** // BATCH API // *********************************************************************** diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index 30d05f57..87ef9067 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -116,64 +116,6 @@ hipFileUseCount() return rocFileUseCount(); } -hipFileError_t -hipFileDriverGetProperties(hipFileDriverProps_t *props) -try { - rocFileError_t status; - - if (props) { - rocFileDriverProps_t roc_props; - status = rocFileDriverGetProperties(&roc_props); - if (status.err == rocFileSuccess) { - *props = toHipFileDriverProps(roc_props); - } - } - else { - status = rocFileDriverGetProperties(nullptr); - } - - return toHipFileError(status); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileDriverSetPollMode(bool poll, size_t poll_threshold_size) -try { - return toHipFileError(rocFileDriverSetPollMode(poll, poll_threshold_size)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileDriverSetMaxDirectIOSize(size_t max_direct_io_size) -try { - return toHipFileError(rocFileDriverSetMaxDirectIOSize(max_direct_io_size)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileDriverSetMaxCacheSize(size_t max_cache_size) -try { - return toHipFileError(rocFileDriverSetMaxCacheSize(max_cache_size)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileDriverSetMaxPinnedMemSize(size_t max_pinned_size) -try { - return toHipFileError(rocFileDriverSetMaxPinnedMemSize(max_pinned_size)); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - hipFileError_t hipFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr) try { diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 9b15e94e..8bee97ce 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -357,19 +357,19 @@ catch (...) { return -1; } -rocFileError_t -rocFileDriverGetProperties(rocFileDriverProps_t *props) +hipFileError_t +hipFileDriverGetProperties(hipFileDriverProps_t *props) try { (void)props; throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileDriverSetPollMode(bool poll, size_t poll_threshold_size) +hipFileError_t +hipFileDriverSetPollMode(bool poll, size_t poll_threshold_size) try { (void)poll; (void)poll_threshold_size; @@ -377,40 +377,40 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileDriverSetMaxDirectIOSize(size_t max_direct_io_size) +hipFileError_t +hipFileDriverSetMaxDirectIOSize(size_t max_direct_io_size) try { (void)max_direct_io_size; throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileDriverSetMaxCacheSize(size_t max_cache_size) +hipFileError_t +hipFileDriverSetMaxCacheSize(size_t max_cache_size) try { (void)max_cache_size; throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } -rocFileError_t -rocFileDriverSetMaxPinnedMemSize(size_t max_pinned_size) +hipFileError_t +hipFileDriverSetMaxPinnedMemSize(size_t max_pinned_size) try { (void)max_pinned_size; throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return handle_exception2(); } rocFileError_t From 06d244d03ddf858c70dc570a631eb9e5eba1c028 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 02:47:38 -0700 Subject: [PATCH 21/48] Remove ROCFILE_STREAM_* flags --- hipfile/include/rocfile.h | 24 ------------------------ hipfile/src/amd_detail/stream.cpp | 10 +++++----- hipfile/test/amd_detail/async.cpp | 10 +++++----- hipfile/test/amd_detail/stream.cpp | 10 +++++----- 4 files changed, 15 insertions(+), 39 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index ee3d00d9..b5ae10df 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -567,30 +567,6 @@ rocFileError_t rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp); // ASYNC API // *********************************************************************** -/*! - * @defgroup stream_flags Stream registration flags - * @ingroup async - * - * @brief Flags to configure async GPU IO behaviour at stream registration - * @{ - */ - -/// Buffer offset is fixed at time of submission -#define ROCFILE_STREAM_FIXED_BUF_OFFSET 1 - -/// File offset is fixed at time of submission -#define ROCFILE_STREAM_FIXED_FILE_OFFSET (1 << 1) - -/// File size is fixed at time of submission -#define ROCFILE_STREAM_FIXED_FILE_SIZE (1 << 2) - -/// Offsets and size are 4k aligned -#define ROCFILE_STREAM_PAGE_ALIGNED_INPUTS (1 << 3) - -/// Mask for selecting flag bits -#define ROCFILE_STREAM_FLAGS_MASK 0xf -/*! @} */ - /*! * @brief Perform an asynchronous read from a stream * @ingroup async diff --git a/hipfile/src/amd_detail/stream.cpp b/hipfile/src/amd_detail/stream.cpp index 57c28a8a..24dfcb47 100644 --- a/hipfile/src/amd_detail/stream.cpp +++ b/hipfile/src/amd_detail/stream.cpp @@ -16,13 +16,13 @@ namespace hipFile { Stream::Stream(const hipStream_t _hip_stream, uint32_t flags) - : hip_stream{_hip_stream}, fixed_buf_offset{(flags & ROCFILE_STREAM_FIXED_BUF_OFFSET) != 0}, - fixed_file_offset{(flags & ROCFILE_STREAM_FIXED_FILE_OFFSET) != 0}, - fixed_io_size{(flags & ROCFILE_STREAM_FIXED_FILE_SIZE) != 0}, - page_aligned{(flags & ROCFILE_STREAM_PAGE_ALIGNED_INPUTS) != 0} + : hip_stream{_hip_stream}, fixed_buf_offset{(flags & HIPFILE_STREAM_FIXED_BUF_OFFSET) != 0}, + fixed_file_offset{(flags & HIPFILE_STREAM_FIXED_FILE_OFFSET) != 0}, + fixed_io_size{(flags & HIPFILE_STREAM_FIXED_FILE_SIZE) != 0}, + page_aligned{(flags & HIPFILE_STREAM_PAGE_ALIGNED_INPUTS) != 0} { - if ((flags & ROCFILE_STREAM_FLAGS_MASK) != flags) { + if ((flags & HIPFILE_STREAM_FLAGS_MASK) != flags) { throw std::invalid_argument("Invalid flags for stream"); } } diff --git a/hipfile/test/amd_detail/async.cpp b/hipfile/test/amd_detail/async.cpp index 989edfbe..340d0dbe 100644 --- a/hipfile/test/amd_detail/async.cpp +++ b/hipfile/test/amd_detail/async.cpp @@ -75,8 +75,8 @@ struct RocFileAsyncMonitor : RocFileAsyncOp { static auto rocfileFlagsPowerSet() { - return Combine(Values(0, ROCFILE_STREAM_FIXED_BUF_OFFSET), Values(0, ROCFILE_STREAM_FIXED_FILE_OFFSET), - Values(0, ROCFILE_STREAM_FIXED_FILE_SIZE), Values(0, ROCFILE_STREAM_PAGE_ALIGNED_INPUTS)); + return Combine(Values(0, HIPFILE_STREAM_FIXED_BUF_OFFSET), Values(0, HIPFILE_STREAM_FIXED_FILE_OFFSET), + Values(0, HIPFILE_STREAM_FIXED_FILE_SIZE), Values(0, HIPFILE_STREAM_PAGE_ALIGNED_INPUTS)); } struct RocFileAsyncOpStreamParams @@ -112,19 +112,19 @@ TEST_P(RocFileAsyncOpStreamParams, asyncOp_construction_has_correct_variants) &buffer_offset, &bytes_transferred); // Unfixed flags will be pointers - if (flags & ROCFILE_STREAM_FIXED_BUF_OFFSET) { + if (flags & HIPFILE_STREAM_FIXED_BUF_OFFSET) { EXPECT_NO_THROW(std::get(op->buffer_offset)); } else { EXPECT_NO_THROW(std::get(op->buffer_offset)); } - if (flags & ROCFILE_STREAM_FIXED_FILE_OFFSET) { + if (flags & HIPFILE_STREAM_FIXED_FILE_OFFSET) { EXPECT_NO_THROW(std::get(op->file_offset)); } else { EXPECT_NO_THROW(std::get(op->file_offset)); } - if (flags & ROCFILE_STREAM_FIXED_FILE_SIZE) { + if (flags & HIPFILE_STREAM_FIXED_FILE_SIZE) { EXPECT_NO_THROW(std::get(op->size)); } else { diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index dd61fc7f..bd72a5bb 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -29,10 +29,10 @@ HIPFILE_WARN_NO_GLOBAL_CTOR_OFF static auto rocFileFlagsPowerSet() { - return ::testing::Combine(::testing::Values(0, ROCFILE_STREAM_FIXED_BUF_OFFSET), - ::testing::Values(0, ROCFILE_STREAM_FIXED_FILE_OFFSET), - ::testing::Values(0, ROCFILE_STREAM_FIXED_FILE_SIZE), - ::testing::Values(0, ROCFILE_STREAM_PAGE_ALIGNED_INPUTS)); + return ::testing::Combine(::testing::Values(0, HIPFILE_STREAM_FIXED_BUF_OFFSET), + ::testing::Values(0, HIPFILE_STREAM_FIXED_FILE_OFFSET), + ::testing::Values(0, HIPFILE_STREAM_FIXED_FILE_SIZE), + ::testing::Values(0, HIPFILE_STREAM_PAGE_ALIGNED_INPUTS)); } struct RocFileStream : public ::testing::Test { @@ -75,7 +75,7 @@ TEST_F(RocFileStream, get_stream_with_unregistered_stream_works) TEST_F(RocFileStream, register_with_invalid_flags_throws) { - ASSERT_THROW(stream_map.registerStream(nonnull_stream, ROCFILE_STREAM_FLAGS_MASK + 1), + ASSERT_THROW(stream_map.registerStream(nonnull_stream, HIPFILE_STREAM_FLAGS_MASK + 1), std::invalid_argument); } From 6ba617421c8a33b5a2911c0ac90b809d82729e19 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 02:53:21 -0700 Subject: [PATCH 22/48] Remove rocFileOpStatusError() --- hipfile/include/rocfile.h | 11 ---- hipfile/src/amd_detail/rocfile.cpp | 85 ------------------------------ 2 files changed, 96 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index b5ae10df..d58f85ce 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -85,17 +85,6 @@ typedef enum rocFileOpError { } rocFileOpError_t; /* clang-format on */ -/*! - * @brief Return a descriptive string for a rocFile error - * @ingroup error - * - * @param [in] status Return code provided by rocFile - * - * @return Description of the error encountered - */ -ROCFILE_API -const char *rocFileOpStatusError(rocFileOpError_t status); - // Ignoring return values from rocFile APIs is discouraged. // On C++17 and C23 and up, we can make that emit a warning. #if __cplusplus >= 201703L || __STDC_VERSION__ >= 202311L diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 8bee97ce..625c48b2 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -25,91 +25,6 @@ using namespace hipFile; using namespace std; -const char * -rocFileOpStatusError(rocFileOpError_t status) -{ - switch (status) { - case rocFileSuccess: - return "rocFile success"; - case rocFileDriverNotInitialized: - return "GPU IO driver is not loaded"; - case rocFileDriverInvalidProps: - return "Invalid GPU IO driver property provided"; - case rocFileDriverUnsupportedLimit: - return "GPU IO Driver property value is unsupported"; - case rocFileDriverVersionMismatch: - return "rocFile version does not match GPU IO driver version"; - case rocFileDriverVersionReadError: - return "Unable to read the GPU IO driver version"; - case rocFileDriverClosing: - return "GPU IO driver is closing and not accepting new requests"; - case rocFilePlatformNotSupported: - return "rocFile is not supported on the current platform"; - case rocFileIONotSupported: - return "rocFile is not supported on the selected file"; - case rocFileDeviceNotSupported: - return "The selected GPU does not support rocFile"; - case rocFileDriverError: - return "GPU IO driver error"; - case rocFileHipDriverError: - return "GPU driver error: Inspect hip_drv_err for additional information"; - case rocFileHipPointerInvalid: - return "Invalid GPU pointer"; - case rocFileHipMemoryTypeInvalid: - return "Memory type backing pointer is incompatible with rocFile"; - case rocFileHipPointerRangeError: - return "Pointer range exceeds allocated memory region"; - case rocFileHipContextMismatch: - return "GPU driver context mismatch"; - case rocFileInvalidMappingSize: - return "Accessing memory beyond pinned memory buffer"; - case rocFileInvalidMappingRange: - return "Accessing memory beyond mapped memory region"; - case rocFileInvalidFileType: - return "Unsupported file type"; - case rocFileInvalidFileOpenFlag: - return "Unsupported file open flags"; - case rocFileDIONotSet: - return "O_DIRECT flag not set"; - case rocFileInvalidValue: - return "One or more arguments have an invalid value"; - case rocFileMemoryAlreadyRegistered: - return "Device pointer is already registered"; - case rocFileMemoryNotRegistered: - return "Device pointer is not registered"; - case rocFilePermissionDenied: - return "Permission error on device or file access"; - case rocFileDriverAlreadyOpen: - return "GPU IO driver is already open"; - case rocFileHandleNotRegistered: - return "File handle for GPU IO is not registered"; - case rocFileHandleAlreadyRegistered: - return "File handle for GPU IO is already registered"; - case rocFileDeviceNotFound: - return "Selected device not found"; - case rocFileInternalError: - return "Internal GPU IO library error"; - case rocFileGetNewFDFailed: - return "Unable to obtain a new file descriptor"; - case rocFileDriverSetupError: - return "GPU IO Driver initialization error"; - case rocFileIODisabled: - return "GPU IO config file prohibits GPU IO on specified file"; - case rocFileBatchSubmitFailed: - return "Failed to submit request for batch operation"; - case rocFileGPUMemoryPinningFailed: - return "Failed to allocated pinned device memory"; - case rocFileBatchFull: - return "Batch operation queue is full"; - case rocFileAsyncNotSupported: - return "rocFile async IO is not supported"; - case rocFileIOMaxError: - return "Internal flag to mark largest rocFile error code"; - default: - return "Unknown rocFile error"; - } -} - /// Catch C++ exceptions from the rocFile code and convert /// them into error values that can be returned from public /// C API calls. From e76aa8dab9fa4e057bde0398c1a383c3b6844163 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 02:57:58 -0700 Subject: [PATCH 23/48] Remove unused rocFile structs --- hipfile/include/rocfile.h | 42 --------------------------------------- 1 file changed, 42 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index d58f85ce..58d0e811 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -113,48 +113,6 @@ typedef struct __ROCFILE_NODISCARD rocFileError { * following enums. */ -/*! - * @brief Filesystems/storage protocols supported by GPU IO on this system - * @ingroup driver - * - * @note Value 10 is reserved for YRCloudFile - */ -typedef enum rocFileDriverStatusFlags { - rocFileLustreSupported = 0, //!< Lustre is supported (UNSUPPORTED in rocFile) - rocFileWekaFSSupported = 1, //!< Weka is supported (UNSUPPORTED in rocFile) - rocFileNFSSupported = 2, //!< NFS is supported - rocFileGPFSSupported = 3, //!< GPFS/IBM Storage Scale is supported (UNSUPPORTED in rocFile) - rocFileNVMeSupported = 4, //!< Local NVMe is supported - rocFileNVMeoFSupported = 5, //!< NVMeoF is supported - rocFileSCSISupported = 6, //!< SCSI is supported (UNSUPPORTED in rocFile) - rocFileScaleFluxCSDSupported = 7, //!< ScaleFlux CSD is supported (UNSUPPORTED in rocFile) - rocFileNVMeshSupported = 8, //!< NVMesh is supported (UNSUPPORTED in rocFile) - rocFileBeeGFSSupported = 9, //!< BeeGFS is supported (UNSUPPORTED in rocFile) - /* 10 is reserved for YRCloudFile */ - rocFileNVMeP2PSsupported = 11, //!< NVMeP2P is supported (UNSUPPORTED in rocFile) - rocFileScatefsSupported = 12, //!< ScateFS is supported (UNSUPPORTED in rocFile) -} rocFileDriverStatusFlags_t; - -/*! - * @brief Control flags for passing to the GPU IO driver - * @ingroup driver - */ -typedef enum rocFileDriverControlFlags { - rocFileUsePollMode = 0, //!< Enable polling for IO completion - rocFileAllowCompatMode = 1, //!< Allow GPU IO to fall back to POSIX IO -} rocFileDriverControlFlags_t; - -/*! - * @brief GPU IO Transport & Features supported by the system - * @ingroup driver - */ -typedef enum rocFileFeatureFlags { - rocFileDynRoutingSupported = 0, //!< RDMA dynamic routing is supported - rocFileBatchIOSupported = 1, //!< Batch operations are supported - rocFileStreamsSupported = 2, //!< Streams are supported - rocFileParallelIOSupported = 3, //!< Parallel IO is supported -} rocFileFeatureFlags_t; - /*! * @brief GPU IO configuration * @ingroup driver From bcfd6e3ebbf4e29ba4103d97ab2868e728ef0bae Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 03:15:00 -0700 Subject: [PATCH 24/48] Minor comment fixes --- hipfile/src/amd_detail/hip.h | 2 +- hipfile/src/amd_detail/sys.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hipfile/src/amd_detail/hip.h b/hipfile/src/amd_detail/hip.h index c78a951c..11dc0638 100644 --- a/hipfile/src/amd_detail/hip.h +++ b/hipfile/src/amd_detail/hip.h @@ -14,7 +14,7 @@ /* hipxx (hip++) * - * hipxx wraps HIP APIs used by hipFile/rocFile libraries. This enables unit + * hipxx wraps HIP APIs used by the hipFile library. This enables unit * tests to mock HIP APIs. * * The wrapper methods should diff --git a/hipfile/src/amd_detail/sys.h b/hipfile/src/amd_detail/sys.h index 9ec2532d..240cefd2 100644 --- a/hipfile/src/amd_detail/sys.h +++ b/hipfile/src/amd_detail/sys.h @@ -13,7 +13,7 @@ #include #include -/* sys wraps system APIs used by rocFile which enables unit tests to mock system calls. +/* sys wraps system APIs used by hipFile which enables unit tests to mock system calls. * * The wrapper methods should * - Throw a Sys::RuntimeError if the wrapped function fails From 3c36d2e80f2f20a8a719c335b099a1c6ab1cff2c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 03:19:04 -0700 Subject: [PATCH 25/48] Rename rocFileEnsureDriverInitPrivate() --- hipfile/src/amd_detail/hipfile-private.cpp | 2 +- hipfile/src/amd_detail/hipfile-private.h | 4 ++-- hipfile/src/amd_detail/hipfile.cpp | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hipfile/src/amd_detail/hipfile-private.cpp b/hipfile/src/amd_detail/hipfile-private.cpp index 5b4f0d4c..89b2ad93 100644 --- a/hipfile/src/amd_detail/hipfile-private.cpp +++ b/hipfile/src/amd_detail/hipfile-private.cpp @@ -8,7 +8,7 @@ #include "state.h" void -rocFileEnsureDriverInitPrivate() +hipFileEnsureDriverInitPrivate() { hipFile::Context::get()->ensureInitialized(); } diff --git a/hipfile/src/amd_detail/hipfile-private.h b/hipfile/src/amd_detail/hipfile-private.h index 97b441af..ab4146c5 100644 --- a/hipfile/src/amd_detail/hipfile-private.h +++ b/hipfile/src/amd_detail/hipfile-private.h @@ -22,8 +22,8 @@ struct Backend; // Ensures that the driver is initialized without incrementing the reference // count if the driver is already initialized. Used by hipFile to ensure its // behaviour is consistent on AMD and NVIDIA -ROCFILE_API -void rocFileEnsureDriverInitPrivate(); +HIPFILE_API +void hipFileEnsureDriverInitPrivate(); ssize_t rocFileIo(hipFile::IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset, diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index 87ef9067..32d4cebb 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -4,6 +4,7 @@ */ #include "hipfile.h" +#include "hipfile-private.h" #include "hipfile-rocfile.h" #include @@ -16,8 +17,6 @@ using namespace std; -void rocFileEnsureDriverInitPrivate(); - hipFileError_t hipFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) try { @@ -201,7 +200,7 @@ try { rocFileReadAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_read_p, stream)); if (result.err == hipFileDriverNotInitialized) { // Match cuFile behaviour - rocFileEnsureDriverInitPrivate(); + hipFileEnsureDriverInitPrivate(); result.err = hipFileInvalidValue; } return result; @@ -218,7 +217,7 @@ try { rocFileWriteAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_written_p, stream)); if (result.err == hipFileDriverNotInitialized) { // Match cuFile behaviour - rocFileEnsureDriverInitPrivate(); + hipFileEnsureDriverInitPrivate(); result.err = hipFileInvalidValue; } return result; From bb21cc513f4b51c4a53843bc670d0624fb0746cd Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 04:13:22 -0700 Subject: [PATCH 26/48] Move rocFile errors to hipFile --- hipfile/include/rocfile.h | 121 +++-------------- hipfile/src/amd_detail/hipfile-rocfile.cpp | 91 ------------- hipfile/src/amd_detail/hipfile-rocfile.h | 4 - hipfile/src/amd_detail/hipfile.cpp | 42 +++--- hipfile/src/amd_detail/rocfile.cpp | 150 +++++++++------------ hipfile/test/amd_detail/buffer.cpp | 44 +++--- hipfile/test/amd_detail/driver.cpp | 48 +++---- hipfile/test/amd_detail/fallback.cpp | 4 +- hipfile/test/amd_detail/handle.cpp | 30 ++--- hipfile/test/amd_detail/rocfile-test.h | 32 ++--- hipfile/test/amd_detail/rocfile.cpp | 28 ++-- hipfile/test/amd_detail/stream.cpp | 6 +- 12 files changed, 200 insertions(+), 400 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 58d0e811..733201d7 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -21,90 +21,6 @@ extern "C" { #endif -// *********************************************************************** -// ERROR HANDLING -// *********************************************************************** - -/*! - * @brief The base value for rocFile error codes - * @ingroup error - */ -#define ROCFILE_BASE_ERR 5000 - -/* clang-format off */ -/*! - * @brief rocFile function return codes - * @ingroup error - * - * An error code of -1 indicates a that a C or POSIX error has occurred and - * errno is likely to have been set. - * - * @note ROCFILE_BASE_ERR + 21 and 32 are intentionally omitted. - */ -typedef enum rocFileOpError { - rocFileSuccess = 0, //!< rocFile success - rocFileDriverNotInitialized = ROCFILE_BASE_ERR + 1, //!< GPU IO driver is not loaded - rocFileDriverInvalidProps = ROCFILE_BASE_ERR + 2, //!< Invalid GPU IO driver property provided - rocFileDriverUnsupportedLimit = ROCFILE_BASE_ERR + 3, //!< GPU IO Driver property value is unsupported - rocFileDriverVersionMismatch = ROCFILE_BASE_ERR + 4, //!< rocFile version does not match GPU IO driver version - rocFileDriverVersionReadError = ROCFILE_BASE_ERR + 5, //!< Unable to read the GPU IO driver version - rocFileDriverClosing = ROCFILE_BASE_ERR + 6, //!< GPU IO driver is closing and not accepting new requests - rocFilePlatformNotSupported = ROCFILE_BASE_ERR + 7, //!< rocFile is not supported on the current platform - rocFileIONotSupported = ROCFILE_BASE_ERR + 8, //!< rocFile is not supported on the selected file - rocFileDeviceNotSupported = ROCFILE_BASE_ERR + 9, //!< The selected GPU does not support rocFile - rocFileDriverError = ROCFILE_BASE_ERR + 10, //!< GPU IO driver error - rocFileHipDriverError = ROCFILE_BASE_ERR + 11, //!< GPU driver error: Inspect the hipError_t value for additional information - rocFileHipPointerInvalid = ROCFILE_BASE_ERR + 12, //!< Invalid GPU pointer - rocFileHipMemoryTypeInvalid = ROCFILE_BASE_ERR + 13, //!< Memory type backing pointer is incompatible with rocFile - rocFileHipPointerRangeError = ROCFILE_BASE_ERR + 14, //!< Pointer range exceeds allocated memory region - rocFileHipContextMismatch = ROCFILE_BASE_ERR + 15, //!< GPU driver context mismatch - rocFileInvalidMappingSize = ROCFILE_BASE_ERR + 16, //!< Accessing memory beyond pinned memory buffer - rocFileInvalidMappingRange = ROCFILE_BASE_ERR + 17, //!< Accessing memory beyond mapped memory region - rocFileInvalidFileType = ROCFILE_BASE_ERR + 18, //!< Unsupported file type - rocFileInvalidFileOpenFlag = ROCFILE_BASE_ERR + 19, //!< Unsupported file open flags - rocFileDIONotSet = ROCFILE_BASE_ERR + 20, //!< O_DIRECT flag not set - /* Value 5021 intentionally unused */ - rocFileInvalidValue = ROCFILE_BASE_ERR + 22, //!< One or more arguments have an invalid value - rocFileMemoryAlreadyRegistered = ROCFILE_BASE_ERR + 23, //!< Device pointer is already registered - rocFileMemoryNotRegistered = ROCFILE_BASE_ERR + 24, //!< Device pointer is not registered - rocFilePermissionDenied = ROCFILE_BASE_ERR + 25, //!< Permission error on device or file access - rocFileDriverAlreadyOpen = ROCFILE_BASE_ERR + 26, //!< GPU IO driver is already open - rocFileHandleNotRegistered = ROCFILE_BASE_ERR + 27, //!< File handle for GPU IO is not registered - rocFileHandleAlreadyRegistered = ROCFILE_BASE_ERR + 28, //!< File handle for GPU IO is already registered - rocFileDeviceNotFound = ROCFILE_BASE_ERR + 29, //!< Selected device not found - rocFileInternalError = ROCFILE_BASE_ERR + 30, //!< Internal GPU IO library error - rocFileGetNewFDFailed = ROCFILE_BASE_ERR + 31, //!< Unable to obtain a new file descriptor - /* Value 5032 intentionally unused */ - rocFileDriverSetupError = ROCFILE_BASE_ERR + 33, //!< GPU IO Driver initialization error - rocFileIODisabled = ROCFILE_BASE_ERR + 34, //!< GPU IO config file prohibits GPU IO on specified file - rocFileBatchSubmitFailed = ROCFILE_BASE_ERR + 35, //!< Failed to submit request for batch operation - rocFileGPUMemoryPinningFailed = ROCFILE_BASE_ERR + 36, //!< Failed to allocated pinned device memory - rocFileBatchFull = ROCFILE_BASE_ERR + 37, //!< Batch operation queue is full - rocFileAsyncNotSupported = ROCFILE_BASE_ERR + 38, //!< rocFile async IO is not supported - rocFileIOMaxError = ROCFILE_BASE_ERR + 39, //!< Internal flag to mark largest rocFile error code -} rocFileOpError_t; -/* clang-format on */ - -// Ignoring return values from rocFile APIs is discouraged. -// On C++17 and C23 and up, we can make that emit a warning. -#if __cplusplus >= 201703L || __STDC_VERSION__ >= 202311L -#define __ROCFILE_NODISCARD [[nodiscard]] -#else -#define __ROCFILE_NODISCARD -#endif - -/*! - * @brief Error status returned from rocFile API calls - * @ingroup error - * - * @note This struct has the `[[nodiscard]]` attribute in C++ >= 17 and - * C >= 23 so unhandled return values will generate warnings - */ -typedef struct __ROCFILE_NODISCARD rocFileError { - rocFileOpError_t err; //!< Errors related to rocFile or the GPU IO driver - hipError_t hip_drv_err; //!< Errors related to the GPU driver -} rocFileError_t; - // *********************************************************************** // GPU IO DRIVER API // *********************************************************************** @@ -242,7 +158,7 @@ typedef void *rocFileHandle_t; * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr); +hipFileError_t rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr); /*! * @brief Deregisters a file from GPU IO @@ -253,7 +169,7 @@ rocFileError_t rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr) * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileHandleDeregister(rocFileHandle_t fh); +hipFileError_t rocFileHandleDeregister(rocFileHandle_t fh); /*! * @brief Registers a GPU memory region to be used with GPU IO @@ -272,7 +188,7 @@ rocFileError_t rocFileHandleDeregister(rocFileHandle_t fh); * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileBufRegister(const void *buffer_base, size_t length, int flags); +hipFileError_t rocFileBufRegister(const void *buffer_base, size_t length, int flags); /*! * @brief Deregisters a GPU memory region from being used with GPU IO @@ -283,7 +199,7 @@ rocFileError_t rocFileBufRegister(const void *buffer_base, size_t length, int fl * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileBufDeregister(const void *buffer_base); +hipFileError_t rocFileBufDeregister(const void *buffer_base); /*! * @brief Synchronously read data from a file into a GPU buffer @@ -297,7 +213,7 @@ rocFileError_t rocFileBufDeregister(const void *buffer_base); * * @return if >= 0: Number of bytes read * @return if -1: System error (check `errno` for the specific error) - * @return else: Negative value of the related rocFileOpError_t + * @return else: Negative value of the related hipFileOpError_t */ ROCFILE_API ssize_t rocFileRead(rocFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, @@ -315,7 +231,7 @@ ssize_t rocFileRead(rocFileHandle_t fh, void *buffer_base, size_t size, hoff_t f * * @return if >= 0: Number of bytes written * @return if -1: System error (check `errno` for the specific error) - * @return else: Negative value of the related rocFileOpError_t + * @return else: Negative value of the related hipFileOpError_t */ ROCFILE_API ssize_t rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, @@ -340,7 +256,7 @@ ssize_t rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, h * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileDriverOpen(void); +hipFileError_t rocFileDriverOpen(void); /*! * @brief Close the GPU IO driver for this process @@ -356,7 +272,7 @@ rocFileError_t rocFileDriverOpen(void); * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileDriverClose(void); +hipFileError_t rocFileDriverClose(void); /*! * @brief Obtain the current reference count for the library @@ -450,7 +366,7 @@ typedef void *rocFileBatchHandle_t; * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileBatchIOSetUp(rocFileBatchHandle_t *batch_idp, unsigned max_nr); +hipFileError_t rocFileBatchIOSetUp(rocFileBatchHandle_t *batch_idp, unsigned max_nr); /*! * @brief Enqueue a batch of IO requests for the GPU to complete asynchronously @@ -466,7 +382,7 @@ rocFileError_t rocFileBatchIOSetUp(rocFileBatchHandle_t *batch_idp, unsigned max * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileBatchIOSubmit(rocFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, +hipFileError_t rocFileBatchIOSubmit(rocFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, unsigned flags); /*! @@ -485,7 +401,7 @@ rocFileError_t rocFileBatchIOSubmit(rocFileBatchHandle_t batch_idp, unsigned nr, * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileBatchIOGetStatus(rocFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, +hipFileError_t rocFileBatchIOGetStatus(rocFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, rocFileIOEvents_t *iocbp, struct timespec *timeout); /*! @@ -497,7 +413,7 @@ rocFileError_t rocFileBatchIOGetStatus(rocFileBatchHandle_t batch_idp, unsigned * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileBatchIOCancel(rocFileBatchHandle_t batch_idp); +hipFileError_t rocFileBatchIOCancel(rocFileBatchHandle_t batch_idp); /*! * @brief Destroys the batch IO handle and frees the associated resources @@ -508,7 +424,7 @@ rocFileError_t rocFileBatchIOCancel(rocFileBatchHandle_t batch_idp); * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp); +hipFileError_t rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp); // *********************************************************************** // ASYNC API @@ -530,7 +446,7 @@ rocFileError_t rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp); * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileReadAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +hipFileError_t rocFileReadAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream); /*! @@ -549,7 +465,7 @@ rocFileError_t rocFileReadAsync(rocFileHandle_t fh, void *buffer_base, size_t *s * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileWriteAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +hipFileError_t rocFileWriteAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream); /*! @@ -563,7 +479,7 @@ rocFileError_t rocFileWriteAsync(rocFileHandle_t fh, void *buffer_base, size_t * * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileStreamRegister(hipStream_t stream, unsigned flags); +hipFileError_t rocFileStreamRegister(hipStream_t stream, unsigned flags); /*! * @brief Deregister a stream and free the associated resources @@ -574,10 +490,7 @@ rocFileError_t rocFileStreamRegister(hipStream_t stream, unsigned flags); * @return A rocFile error */ ROCFILE_API -rocFileError_t rocFileStreamDeregister(hipStream_t stream); - -// Not a part of the public API -#undef __ROCFILE_NODISCARD +hipFileError_t rocFileStreamDeregister(hipStream_t stream); #ifdef __cplusplus } diff --git a/hipfile/src/amd_detail/hipfile-rocfile.cpp b/hipfile/src/amd_detail/hipfile-rocfile.cpp index 1d27e5dd..7444f98c 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.cpp +++ b/hipfile/src/amd_detail/hipfile-rocfile.cpp @@ -7,97 +7,6 @@ #include -hipFileOpError_t -toHipFileOpError(rocFileOpError_t status) -{ - switch (status) { - case rocFileSuccess: - return hipFileSuccess; - case rocFileDriverNotInitialized: - return hipFileDriverNotInitialized; - case rocFileDriverInvalidProps: - return hipFileDriverInvalidProps; - case rocFileDriverUnsupportedLimit: - return hipFileDriverUnsupportedLimit; - case rocFileDriverVersionMismatch: - return hipFileDriverVersionMismatch; - case rocFileDriverVersionReadError: - return hipFileDriverVersionReadError; - case rocFileDriverClosing: - return hipFileDriverClosing; - case rocFilePlatformNotSupported: - return hipFilePlatformNotSupported; - case rocFileIONotSupported: - return hipFileIONotSupported; - case rocFileDeviceNotSupported: - return hipFileDeviceNotSupported; - case rocFileDriverError: - return hipFileDriverError; - case rocFileHipDriverError: - return hipFileHipDriverError; - case rocFileHipPointerInvalid: - return hipFileHipPointerInvalid; - case rocFileHipMemoryTypeInvalid: - return hipFileHipMemoryTypeInvalid; - case rocFileHipPointerRangeError: - return hipFileHipPointerRangeError; - case rocFileHipContextMismatch: - return hipFileHipContextMismatch; - case rocFileInvalidMappingSize: - return hipFileInvalidMappingSize; - case rocFileInvalidMappingRange: - return hipFileInvalidMappingRange; - case rocFileInvalidFileType: - return hipFileInvalidFileType; - case rocFileInvalidFileOpenFlag: - return hipFileInvalidFileOpenFlag; - case rocFileDIONotSet: - return hipFileDIONotSet; - case rocFileInvalidValue: - return hipFileInvalidValue; - case rocFileMemoryAlreadyRegistered: - return hipFileMemoryAlreadyRegistered; - case rocFileMemoryNotRegistered: - return hipFileMemoryNotRegistered; - case rocFilePermissionDenied: - return hipFilePermissionDenied; - case rocFileDriverAlreadyOpen: - return hipFileDriverAlreadyOpen; - case rocFileHandleNotRegistered: - return hipFileHandleNotRegistered; - case rocFileHandleAlreadyRegistered: - return hipFileHandleAlreadyRegistered; - case rocFileDeviceNotFound: - return hipFileDeviceNotFound; - case rocFileInternalError: - return hipFileInternalError; - case rocFileGetNewFDFailed: - return hipFileGetNewFDFailed; - case rocFileDriverSetupError: - return hipFileDriverSetupError; - case rocFileIODisabled: - return hipFileIODisabled; - case rocFileBatchSubmitFailed: - return hipFileBatchSubmitFailed; - case rocFileGPUMemoryPinningFailed: - return hipFileGPUMemoryPinningFailed; - case rocFileBatchFull: - return hipFileBatchFull; - case rocFileAsyncNotSupported: - return hipFileAsyncNotSupported; - case rocFileIOMaxError: - return hipFileIOMaxError; - default: - throw std::invalid_argument("Invalid rocFileOpError_t value"); - } -} - -hipFileError_t -toHipFileError(const rocFileError_t &status) -{ - return {toHipFileOpError(status.err), status.hip_drv_err}; -} - rocFileFileHandleType_t toRocFileFileHandleType(hipFileFileHandleType_t hf_type) { diff --git a/hipfile/src/amd_detail/hipfile-rocfile.h b/hipfile/src/amd_detail/hipfile-rocfile.h index 0301f2ae..951c813f 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.h +++ b/hipfile/src/amd_detail/hipfile-rocfile.h @@ -11,10 +11,6 @@ // rocFile to hipFile //////////////////////////////////////////////////////// -hipFileOpError_t toHipFileOpError(rocFileOpError_t status); - -hipFileError_t toHipFileError(const rocFileError_t &status); - hipFileDriverProps_t toHipFileDriverProps(const rocFileDriverProps_t &rf_props); hipFileStatus_t toHipFileStatus(rocFileStatus_t rf_status); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index 32d4cebb..818e5abe 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -21,7 +21,7 @@ hipFileError_t hipFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) try { rocFileHandle_t *rocfile_fh = fh; - rocFileError_t status; + hipFileError_t status; if (descr) { auto rocfile_descr = toRocFileDescr(*descr); @@ -32,7 +32,7 @@ try { status = rocFileHandleRegister(rocfile_fh, nullptr); } - return toHipFileError(status); + return status; } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -47,7 +47,7 @@ hipFileHandleDeregister(hipFileHandle_t fh) hipFileError_t hipFileBufRegister(const void *buffer_base, size_t length, int flags) try { - return toHipFileError(rocFileBufRegister(buffer_base, length, flags)); + return rocFileBufRegister(buffer_base, length, flags); } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -56,7 +56,7 @@ catch (...) { hipFileError_t hipFileBufDeregister(const void *buffer_base) try { - auto error = toHipFileError(rocFileBufDeregister(buffer_base)); + auto error = rocFileBufDeregister(buffer_base); if (error.err == hipFileDriverNotInitialized) { error.err = hipFileDriverClosing; } @@ -70,7 +70,7 @@ ssize_t hipFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) { auto result = rocFileRead(fh, buffer_base, size, file_offset, buffer_offset); - if (result == -rocFileDriverNotInitialized) { + if (result == -hipFileDriverNotInitialized) { // Match cuFile behaviour errno = EINVAL; result = -1; @@ -83,7 +83,7 @@ hipFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t fi hoff_t buffer_offset) { auto result = rocFileWrite(fh, buffer_base, size, file_offset, buffer_offset); - if (result == -rocFileDriverNotInitialized) { + if (result == -hipFileDriverNotInitialized) { // Match cuFile behaviour errno = EINVAL; result = -1; @@ -94,7 +94,7 @@ hipFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t fi hipFileError_t hipFileDriverOpen() try { - return toHipFileError(rocFileDriverOpen()); + return rocFileDriverOpen(); } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -103,7 +103,7 @@ catch (...) { hipFileError_t hipFileDriverClose() try { - return toHipFileError(rocFileDriverClose()); + return rocFileDriverClose(); } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -118,7 +118,7 @@ hipFileUseCount() hipFileError_t hipFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr) try { - return toHipFileError(rocFileBatchIOSetUp(batch_idp, max_nr)); + return rocFileBatchIOSetUp(batch_idp, max_nr); } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -128,7 +128,7 @@ hipFileError_t hipFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, hipFileIOParams_t *iocbp, unsigned flags) try { auto rf_batch_idp = batch_idp; - rocFileError_t status; + hipFileError_t status; if (iocbp) { vector io_params(nr); @@ -143,7 +143,7 @@ try { status = rocFileBatchIOSubmit(rf_batch_idp, nr, nullptr, flags); } - return toHipFileError(status); + return status; } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -154,14 +154,14 @@ hipFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigne hipFileIOEvents_t *iocbp, struct timespec *timeout) try { auto rf_batch_idp = batch_idp; - rocFileError_t status; + hipFileError_t status; if (iocbp) { vector io_events(*nr); status = rocFileBatchIOGetStatus(rf_batch_idp, min_nr, nr, io_events.data(), timeout); - if (status.err == rocFileSuccess) { + if (status.err == hipFileSuccess) { for (unsigned i = 0; i < *nr; i++) { iocbp[i] = toHipFileIOEvents(io_events[i]); } @@ -171,7 +171,7 @@ try { status = rocFileBatchIOGetStatus(rf_batch_idp, min_nr, nr, nullptr, timeout); } - return toHipFileError(status); + return status; } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -180,7 +180,7 @@ catch (...) { hipFileError_t hipFileBatchIOCancel(hipFileBatchHandle_t batch_idp) try { - return toHipFileError(rocFileBatchIOCancel(batch_idp)); + return rocFileBatchIOCancel(batch_idp); } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -196,8 +196,8 @@ hipFileError_t hipFileReadAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream) try { - auto result = toHipFileError( - rocFileReadAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_read_p, stream)); + auto result = + rocFileReadAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_read_p, stream); if (result.err == hipFileDriverNotInitialized) { // Match cuFile behaviour hipFileEnsureDriverInitPrivate(); @@ -213,8 +213,8 @@ hipFileError_t hipFileWriteAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream) try { - auto result = toHipFileError( - rocFileWriteAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_written_p, stream)); + auto result = + rocFileWriteAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_written_p, stream); if (result.err == hipFileDriverNotInitialized) { // Match cuFile behaviour hipFileEnsureDriverInitPrivate(); @@ -229,7 +229,7 @@ catch (...) { hipFileError_t hipFileStreamRegister(hipStream_t stream, unsigned flags) try { - return toHipFileError(rocFileStreamRegister(stream, flags)); + return rocFileStreamRegister(stream, flags); } catch (...) { return {hipFileInternalError, hipSuccess}; @@ -238,7 +238,7 @@ catch (...) { hipFileError_t hipFileStreamDeregister(hipStream_t stream) try { - return toHipFileError(rocFileStreamDeregister(stream)); + return rocFileStreamDeregister(stream); } catch (...) { return {hipFileInternalError, hipSuccess}; diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 625c48b2..9ac058c3 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -25,29 +25,11 @@ using namespace hipFile; using namespace std; -/// Catch C++ exceptions from the rocFile code and convert -/// them into error values that can be returned from public -/// C API calls. -static inline rocFileError_t -handle_exception() noexcept -try { - throw; -} -catch (rocFileError_t e) { - return e; -} -catch (const Hip::RuntimeError &e) { - return {rocFileHipDriverError, e.error}; -} -catch (...) { - return {rocFileInternalError, hipSuccess}; -} - /// Catch C++ exceptions from the hipFile code and convert /// them into error values that can be returned from public /// C API calls. static inline hipFileError_t -handle_exception2() noexcept +handle_exception() noexcept try { throw; } @@ -61,97 +43,97 @@ catch (...) { return {hipFileInternalError, hipSuccess}; } -rocFileError_t +hipFileError_t rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr) try { if (fh == nullptr || descr == nullptr) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } switch (descr->type) { case rocFileHandleTypeOpaqueFD: { UnregisteredFile uf{descr->handle.fd}; *fh = Context::get()->registerFile(uf); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } case rocFileHandleTypeOpaqueWin32: case rocFileHandleTypeUserspaceFS: default: - return {rocFileIONotSupported, hipSuccess}; + return {hipFileIONotSupported, hipSuccess}; } } catch (const FileAlreadyRegistered &) { - return {rocFileHandleAlreadyRegistered, hipSuccess}; + return {hipFileHandleAlreadyRegistered, hipSuccess}; } catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileHandleDeregister(rocFileHandle_t fh) try { if (fh == nullptr) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } Context::get()->deregisterFile(fh); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (const DriverNotInitialized &) { - return {rocFileDriverNotInitialized, hipSuccess}; + return {hipFileDriverNotInitialized, hipSuccess}; } catch (const FileOperationsOutstanding &) { - return {rocFileInternalError, hipSuccess}; + return {hipFileInternalError, hipSuccess}; } catch (const FileNotRegistered &) { - return {rocFileHandleNotRegistered, hipSuccess}; + return {hipFileHandleNotRegistered, hipSuccess}; } catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileBufRegister(const void *buffer_base, size_t length, int flags) try { Context::get()->registerBuffer(buffer_base, length, flags); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (const BufferAlreadyRegistered &) { - return {rocFileMemoryAlreadyRegistered, hipSuccess}; + return {hipFileMemoryAlreadyRegistered, hipSuccess}; } catch (const InvalidMemoryType &) { - return {rocFileHipMemoryTypeInvalid, hipSuccess}; + return {hipFileHipMemoryTypeInvalid, hipSuccess}; } catch (const InvalidPointerRange &) { - return {rocFileHipPointerRangeError, hipSuccess}; + return {hipFileHipPointerRangeError, hipSuccess}; } catch (const Hip::RuntimeError &e) { if (e.error == hipErrorInvalidValue) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } return handle_exception(); } catch (const std::invalid_argument &) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileBufDeregister(const void *buffer_base) try { Context::get()->deregisterBuffer(buffer_base); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (const DriverNotInitialized &) { - return {rocFileDriverNotInitialized, hipSuccess}; + return {hipFileDriverNotInitialized, hipSuccess}; } catch (const BufferNotRegistered &) { - return {rocFileMemoryNotRegistered, hipSuccess}; + return {hipFileMemoryNotRegistered, hipSuccess}; } catch (const BufferOperationsOutstanding &) { - return {rocFileInternalError, hipSuccess}; + return {hipFileInternalError, hipSuccess}; } catch (...) { return handle_exception(); @@ -195,19 +177,19 @@ try { return backend->io(type, file, buffer, size, file_offset, buffer_offset); } catch (const DriverNotInitialized &) { - return -rocFileDriverNotInitialized; + return -hipFileDriverNotInitialized; } -catch (rocFileError_t e) { +catch (hipFileError_t e) { return -e.err; } catch (const InvalidMemoryType &) { - return -rocFileHipMemoryTypeInvalid; + return -hipFileHipMemoryTypeInvalid; } catch (const std::invalid_argument &) { - return -rocFileInvalidValue; + return -hipFileInvalidValue; } catch (const FileNotRegistered &) { - return -rocFileHandleNotRegistered; + return -hipFileHandleNotRegistered; } catch (const Hip::RuntimeError &e) { return -e.error; @@ -221,7 +203,7 @@ catch (const std::system_error &e) { return -1; } catch (...) { - return -rocFileInternalError; + return -hipFileInternalError; } ssize_t @@ -237,26 +219,26 @@ rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t fi return rocFileIo(IoType::Write, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); } -rocFileError_t +hipFileError_t rocFileDriverOpen() try { Context::get()->incrRefCount(); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileDriverClose() try { if (Context::get()->getRefCount() > 0) { Context::get()->decrRefCount(); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } else { - return {rocFileDriverNotInitialized, hipSuccess}; + return {hipFileDriverNotInitialized, hipSuccess}; } } catch (...) { @@ -280,7 +262,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -292,7 +274,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -303,7 +285,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -314,7 +296,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -325,28 +307,28 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } -rocFileError_t +hipFileError_t rocFileBatchIOSetUp(rocFileBatchHandle_t *batch_idp, unsigned max_nr) try { if (batch_idp == nullptr) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } *batch_idp = Context::get()->createBatchContext(max_nr); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (const std::invalid_argument &) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileBatchIOSubmit(rocFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, unsigned flags) try { (void)flags; // Unused at this time. @@ -354,16 +336,16 @@ try { std::shared_ptr batch_context = Context::get()->getBatchContext(batch_idp); batch_context->submit_operations(iocbp, nr); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (const std::invalid_argument &) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileBatchIOGetStatus(rocFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, rocFileIOEvents_t *iocbp, struct timespec *timeout) try { @@ -379,7 +361,7 @@ catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileBatchIOCancel(rocFileBatchHandle_t batch_idp) try { (void)batch_idp; @@ -390,7 +372,7 @@ catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp) try { (void)batch_idp; @@ -401,12 +383,12 @@ catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileReadAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream) try { if (Context::get()->getRefCount() == 0) { - return {rocFileDriverNotInitialized, hipSuccess}; + return {hipFileDriverNotInitialized, hipSuccess}; } (void)fh; @@ -423,12 +405,12 @@ catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileWriteAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream) try { if (Context::get()->getRefCount() == 0) { - return {rocFileDriverNotInitialized, hipSuccess}; + return {hipFileDriverNotInitialized, hipSuccess}; } (void)fh; @@ -445,27 +427,27 @@ catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileStreamRegister(hipStream_t stream, unsigned flags) try { Context::get()->registerStream(stream, flags); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (std::invalid_argument &) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } catch (...) { return handle_exception(); } -rocFileError_t +hipFileError_t rocFileStreamDeregister(hipStream_t stream) try { Context::get()->deregisterStream(stream); - return {rocFileSuccess, hipSuccess}; + return {hipFileSuccess, hipSuccess}; } catch (std::invalid_argument &) { - return {rocFileInvalidValue, hipSuccess}; + return {hipFileInvalidValue, hipSuccess}; } catch (...) { return handle_exception(); @@ -484,7 +466,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -496,7 +478,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -509,7 +491,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -521,7 +503,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -533,7 +515,7 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } hipFileError_t @@ -545,5 +527,5 @@ try { throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception2(); + return handle_exception(); } diff --git a/hipfile/test/amd_detail/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp index fcfa71ec..2b5136a4 100644 --- a/hipfile/test/amd_detail/buffer.cpp +++ b/hipfile/test/amd_detail/buffer.cpp @@ -60,7 +60,7 @@ TEST_F(RocFileBuffer, register_supported_hip_memory) for (const auto memoryType : SupportedHipMemoryTypes) { StrictMock mhip; expect_buffer_registration(mhip, memoryType); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); } } @@ -82,7 +82,7 @@ TEST_F(RocFileBuffer, register_unsupported_hip_memory) hipPointerAttribute_t attrs{}; attrs.type = memoryType; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(rocFileHipMemoryTypeInvalid)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(hipFileHipMemoryTypeInvalid)); } } @@ -102,14 +102,14 @@ TEST_F(RocFileBuffer, register_hip_pointer_get_attributes_error) // hipErrorInvalidValue is handled differently to match the behaviour of cufile EXPECT_CALL(mhip, hipPointerGetAttributes) .WillOnce(testing::Throw(Hip::RuntimeError(hipErrorInvalidValue))); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(rocFileInvalidValue)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(hipFileInvalidValue)); } TEST_F(RocFileBuffer, register_internal_already_registered) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); ASSERT_THROW(Context::get()->registerBuffer(nonnull_ptr, 0, 0), BufferAlreadyRegistered); } @@ -117,13 +117,13 @@ TEST_F(RocFileBuffer, register_already_registered) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(rocFileMemoryAlreadyRegistered)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(hipFileMemoryAlreadyRegistered)); } TEST_F(RocFileBuffer, registerNullPointerReturnsError) { - ASSERT_EQ(rocFileBufRegister(nullptr, 0x10000, 0), RocFileOpError(rocFileInvalidValue)); + ASSERT_EQ(rocFileBufRegister(nullptr, 0x10000, 0), RocFileOpError(hipFileInvalidValue)); } TEST_F(RocFileBuffer, registerOversizeRangeReturnsError) @@ -135,7 +135,7 @@ TEST_F(RocFileBuffer, registerOversizeRangeReturnsError) attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 101, 0), - RocFileOpError(rocFileHipPointerRangeError)); + RocFileOpError(hipFileHipPointerRangeError)); } TEST_F(RocFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) @@ -145,7 +145,7 @@ TEST_F(RocFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) hipPointerAttribute_t attrs{}; attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 100, 0), RocFileOpError(rocFileInvalidValue)); + ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 100, 0), RocFileOpError(hipFileInvalidValue)); } TEST_F(RocFileBuffer, registerOverflowingRangeReturnsError) @@ -157,7 +157,7 @@ TEST_F(RocFileBuffer, registerOverflowingRangeReturnsError) attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0xFFFF0000), 0x10000, 0), - RocFileOpError(rocFileHipPointerRangeError)); + RocFileOpError(hipFileHipPointerRangeError)); } TEST_F(RocFileBuffer, deregister_internal_not_registered) @@ -167,7 +167,7 @@ TEST_F(RocFileBuffer, deregister_internal_not_registered) TEST_F(RocFileBuffer, deregister_not_registered) { - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(rocFileMemoryNotRegistered)); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(hipFileMemoryNotRegistered)); } TEST_F(RocFileBuffer, deregister_internal) @@ -182,8 +182,8 @@ TEST_F(RocFileBuffer, deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); } TEST_F(RocFileBuffer, deregister_internal_duplicate_deregister) @@ -199,9 +199,9 @@ TEST_F(RocFileBuffer, deregister_duplicate_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(rocFileMemoryNotRegistered)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(hipFileMemoryNotRegistered)); } TEST_F(RocFileBuffer, deregister_internal_get_prevents_deregister) @@ -220,12 +220,12 @@ TEST_F(RocFileBuffer, deregister_get_prevents_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); { auto buffer = Context::get()->getBuffer(nonnull_ptr); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(rocFileInternalError)); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(hipFileInternalError)); } - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); } TEST_F(RocFileBuffer, get_not_registered) @@ -245,7 +245,7 @@ TEST_F(RocFileBuffer, get_after_register) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); auto buffer = Context::get()->getBuffer(nonnull_ptr); } @@ -262,8 +262,8 @@ TEST_F(RocFileBuffer, get_after_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); ASSERT_THROW(Context::get()->getBuffer(nonnull_ptr), BufferNotRegistered); } diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index 6dd98bb3..a9e6d814 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -36,12 +36,12 @@ TEST_F(RocFileDriverAdmin, OpenClose) ASSERT_EQ(rocFileUseCount(), 0); for (int64_t i = 1; i <= N; i++) { - ASSERT_EQ(rocFileDriverOpen(), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileDriverOpen(), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), i); } for (int64_t i = N; i >= 1; i--) { - ASSERT_EQ(rocFileDriverClose(), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileDriverClose(), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), i - 1); } @@ -64,7 +64,7 @@ TEST_F(RocFileDriverAdmin, HandleRegisterInitsDriver) ASSERT_EQ(rocFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); } @@ -86,9 +86,9 @@ TEST_F(RocFileDriverAdmin, HandleRegisterGoodFD) expect_file_registration(msys, mlibmounthelper); ASSERT_EQ(rocFileUseCount(), 0); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); - ASSERT_EQ(rocFileHandleDeregister(handle), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleDeregister(handle), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); } @@ -108,7 +108,7 @@ TEST_F(RocFileDriverAdmin, HandleRegisterBadFD) EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); ASSERT_EQ(rocFileUseCount(), 0); - ASSERT_NE(rocFileHandleRegister(&handle, &descr), ROCFILE_SUCCESS); + ASSERT_NE(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 0); } @@ -121,14 +121,14 @@ TEST_F(RocFileDriverAdmin, HandleDeregisterDoesNotInitDriver) // Check NULL ASSERT_EQ(rocFileUseCount(), 0); - ASSERT_NE(rocFileHandleDeregister(nullptr), ROCFILE_SUCCESS); + ASSERT_NE(rocFileHandleDeregister(nullptr), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 0); // Check unregistered handle rocFileHandle_t handle{}; ASSERT_EQ(rocFileUseCount(), 0); - ASSERT_NE(rocFileHandleDeregister(handle), ROCFILE_SUCCESS); + ASSERT_NE(rocFileHandleDeregister(handle), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 0); } @@ -149,12 +149,12 @@ TEST_F(RocFileDriverAdmin, CloseDeregistersFile) ASSERT_EQ(rocFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); - ASSERT_EQ(rocFileDriverClose(), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileDriverClose(), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); } @@ -167,7 +167,7 @@ TEST_F(RocFileDriverAdmin, BufRegisterInitsDriver) expect_buffer_registration(mhip, hipMemoryTypeDevice); ASSERT_EQ(rocFileUseCount(), 0); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); } @@ -176,7 +176,7 @@ TEST_F(RocFileDriverAdmin, BufRegisterInitsDriver) TEST_F(RocFileDriverAdmin, BufDeregisterDoesNotInitDriver) { ASSERT_EQ(rocFileUseCount(), 0); - ASSERT_EQ(rocFileBufDeregister(nullptr), RocFileOpError(rocFileDriverNotInitialized)); + ASSERT_EQ(rocFileBufDeregister(nullptr), RocFileOpError(hipFileDriverNotInitialized)); ASSERT_EQ(rocFileUseCount(), 0); } @@ -189,54 +189,54 @@ TEST_F(RocFileDriverAdmin, CloseDeregistersBuffer) ASSERT_EQ(rocFileUseCount(), 0); expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); - ASSERT_EQ(rocFileDriverClose(), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileDriverClose(), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 0); expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); ASSERT_EQ(rocFileUseCount(), 1); } // Ensure rocFileReadAsync(): -// * Returns rocFileDriverNotInitialized when called w/o a driver init +// * Returns hipFileDriverNotInitialized when called w/o a driver init // * Does NOT initialize the driver and returns a reference count of 0 TEST_F(RocFileDriverAdmin, ReadAsyncDoesNotInitDriver) { ASSERT_EQ(rocFileReadAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), - RocFileOpError(rocFileDriverNotInitialized)); + RocFileOpError(hipFileDriverNotInitialized)); ASSERT_EQ(rocFileUseCount(), 0); } // Ensure rocFileWriteAsync(): -// * Returns rocFileDriverNotInitialized when called w/o a driver init +// * Returns hipFileDriverNotInitialized when called w/o a driver init // * Does NOT initialize the driver and returns a reference count of 0 TEST_F(RocFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) { ASSERT_EQ(rocFileWriteAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), - RocFileOpError(rocFileDriverNotInitialized)); + RocFileOpError(hipFileDriverNotInitialized)); ASSERT_EQ(rocFileUseCount(), 0); } // Ensure rocFileRead(): -// * Returns rocFileDriverNotInitialized when called w/o a driver init +// * Returns hipFileDriverNotInitialized when called w/o a driver init // (the weird negative sign is a quirk of returning a ssize_t) // * Does NOT initialize the driver and returns a reference count of 0 TEST_F(RocFileDriverAdmin, ReadDoesNotInitDriver) { - ASSERT_EQ(rocFileRead(nullptr, nullptr, 0, 0, 0), -rocFileDriverNotInitialized); + ASSERT_EQ(rocFileRead(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); ASSERT_EQ(rocFileUseCount(), 0); } // Ensure rocFileWrite(): -// * Returns rocFileDriverNotInitialized when called w/o a driver init +// * Returns hipFileDriverNotInitialized when called w/o a driver init // (the weird negative sign is a quirk of returning a ssize_t) // * Does NOT initialize the driver and returns a reference count of 0 TEST_F(RocFileDriverAdmin, WriteDoesNotInitDriver) { - ASSERT_EQ(rocFileWrite(nullptr, nullptr, 0, 0, 0), -rocFileDriverNotInitialized); + ASSERT_EQ(rocFileWrite(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); ASSERT_EQ(rocFileUseCount(), 0); } diff --git a/hipfile/test/amd_detail/fallback.cpp b/hipfile/test/amd_detail/fallback.cpp index f638ea0f..874b5c43 100644 --- a/hipfile/test/amd_detail/fallback.cpp +++ b/hipfile/test/amd_detail/fallback.cpp @@ -188,7 +188,7 @@ struct FallbackParam : ::testing::TestWithParam { StrictMock msys; StrictMock mlibmounthelper; - assert(rocFileDriverOpen() == ROCFILE_SUCCESS); + assert(rocFileDriverOpen() == HIPFILE_SUCCESS); expect_buffer_registration(mhip, hipMemoryTypeDevice); void *buf = reinterpret_cast(0xFEFEFEFE); @@ -207,7 +207,7 @@ struct FallbackParam : ::testing::TestWithParam { buffer.reset(); while (rocFileUseCount()) { - assert(rocFileDriverClose() == ROCFILE_SUCCESS); + assert(rocFileDriverClose() == HIPFILE_SUCCESS); } } diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index 5fd0981f..99255b40 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -104,7 +104,7 @@ TEST_F(RocFileHandle, register_handle_linux_fd) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); ASSERT_NE(fh, nullptr); } @@ -118,7 +118,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterStatxError) EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(rocFileInternalError)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileInternalError)); } // If the fcntl() fails during file registration return rocfileInternalError @@ -132,7 +132,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterFcntlError) EXPECT_CALL(msys, statx); EXPECT_CALL(msys, fcntl).WillOnce(Throw(Sys::RuntimeError(EBADF))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(rocFileInternalError)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileInternalError)); } // If getting mount information fails during file registration return rocfileInternalError @@ -147,7 +147,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterLibMountError) EXPECT_CALL(msys, fcntl); EXPECT_CALL(mlibmounthelper, getMountInfo).WillOnce(Throw(std::runtime_error("error from test"))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(rocFileInternalError)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileInternalError)); } TEST_F(RocFileHandle, register_handle_linux_fd_already_registered) @@ -159,10 +159,10 @@ TEST_F(RocFileHandle, register_handle_linux_fd_already_registered) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); ASSERT_NE(fh, nullptr); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(rocFileHandleAlreadyRegistered)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileHandleAlreadyRegistered)); } TEST_F(RocFileHandle, register_handle_windows_handle_not_supported) @@ -173,7 +173,7 @@ TEST_F(RocFileHandle, register_handle_windows_handle_not_supported) rfd.type = rocFileHandleTypeOpaqueWin32; rfd.handle.fd = 0xBADF00D; - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(rocFileIONotSupported)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileIONotSupported)); } TEST_F(RocFileHandle, register_handle_userspace_fs_not_supported) @@ -184,7 +184,7 @@ TEST_F(RocFileHandle, register_handle_userspace_fs_not_supported) rfd.type = rocFileHandleTypeUserspaceFS; rfd.handle.fd = 0xBADF00D; - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(rocFileIONotSupported)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileIONotSupported)); } TEST_F(RocFileHandle, deregister_handle_internal_throws_if_not_registered) @@ -196,7 +196,7 @@ TEST_F(RocFileHandle, deregister_handle_internal_throws_if_not_registered) TEST_F(RocFileHandle, deregister_handle_returns_error_if_not_registered) { ASSERT_EQ(rocFileHandleDeregister(reinterpret_cast(0xdeadbeef)), - RocFileOpError(rocFileHandleNotRegistered)); + RocFileOpError(hipFileHandleNotRegistered)); } TEST_F(RocFileHandle, deregister_handle_internal) @@ -216,9 +216,9 @@ TEST_F(RocFileHandle, deregister_handle) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileHandleDeregister(fh), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileHandleDeregister(fh), RocFileOpError(rocFileHandleNotRegistered)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileHandleDeregister(fh), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileHandleDeregister(fh), RocFileOpError(hipFileHandleNotRegistered)); } TEST_F(RocFileHandle, deregister_handle_internal_fails_when_operations_are_oustanding) @@ -241,12 +241,12 @@ TEST_F(RocFileHandle, deregister_handle_fails_when_operations_are_oustanding) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); { auto file = Context::get()->getFile(fh); - ASSERT_EQ(rocFileHandleDeregister(fh), RocFileOpError(rocFileInternalError)); + ASSERT_EQ(rocFileHandleDeregister(fh), RocFileOpError(hipFileInternalError)); } - ASSERT_EQ(rocFileHandleDeregister(fh), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileHandleDeregister(fh), HIPFILE_SUCCESS); } HIPFILE_WARN_NO_GLOBAL_CTOR_ON diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h index c9a54aeb..d3721426 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/rocfile-test.h @@ -25,50 +25,50 @@ // *********************************************************************** // Set a particular rocFile error -constexpr rocFileError_t +constexpr hipFileError_t RocFileHipError(hipError_t err) { - return {rocFileHipDriverError, err}; + return {hipFileHipDriverError, err}; } // Set a particular HIP error -constexpr rocFileError_t -RocFileOpError(rocFileOpError_t err) +constexpr hipFileError_t +RocFileOpError(hipFileOpError_t err) { return {err, hipSuccess}; } -// == overload for rocFileError_t values +// == overload for hipFileError_t values inline bool -operator==(const rocFileError_t &lhs, const rocFileError_t &rhs) +operator==(const hipFileError_t &lhs, const hipFileError_t &rhs) { return lhs.err == rhs.err && lhs.hip_drv_err == rhs.hip_drv_err; } -// != overload for rocFileError_t values +// != overload for hipFileError_t values inline bool -operator!=(const rocFileError_t &lhs, const rocFileError_t &rhs) +operator!=(const hipFileError_t &lhs, const hipFileError_t &rhs) { return lhs.err != rhs.err || lhs.hip_drv_err != rhs.hip_drv_err; } -// << overload for rocFileError_t values +// << overload for hipFileError_t values // // Unused in the test code, but kept here for iostream debugging #ifndef NDEBUG #include inline std::ostream & -operator<<(std::ostream &os, const rocFileError_t &rfe) +operator<<(std::ostream &os, const hipFileError_t &rfe) { - return os << "rocFileError_t{ err: " << rfe.err << ", hip_drv_err: " << rfe.hip_drv_err << " }"; + return os << "hipFileError_t{ err: " << rfe.err << ", hip_drv_err: " << rfe.hip_drv_err << " }"; } #endif // Convenience "success" value -inline constexpr rocFileError_t ROCFILE_SUCCESS{rocFileSuccess, hipSuccess}; +inline constexpr hipFileError_t HIPFILE_SUCCESS{hipFileSuccess, hipSuccess}; // Convenience "invalid argument" value -inline constexpr rocFileError_t ROCFILE_INVALID_VALUE{rocFileInvalidValue, hipSuccess}; +inline constexpr hipFileError_t HIPFILE_INVALID_VALUE{hipFileInvalidValue, hipSuccess}; // *********************************************************************** // BASE ERROR CLASSES @@ -80,13 +80,13 @@ struct RocFileOpened : public ::testing::Test { RocFileOpened() { assert(rocFileUseCount() == 0); - assert(rocFileDriverOpen() == ROCFILE_SUCCESS); + assert(rocFileDriverOpen() == HIPFILE_SUCCESS); } virtual ~RocFileOpened() override { while (rocFileUseCount()) { - assert(rocFileDriverClose() == ROCFILE_SUCCESS); + assert(rocFileDriverClose() == HIPFILE_SUCCESS); } assert(rocFileUseCount() == 0); } @@ -103,7 +103,7 @@ struct RocFileUnopened : public ::testing::Test { virtual ~RocFileUnopened() override { while (rocFileUseCount()) { - assert(rocFileDriverClose() == ROCFILE_SUCCESS); + assert(rocFileDriverClose() == HIPFILE_SUCCESS); } assert(rocFileUseCount() == 0); } diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index 907064e6..fd3f4479 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -67,7 +67,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSetupSuccess) EXPECT_CALL(mock_state, createBatchContext).WillOnce(Return(expected_b_handle)); auto result = rocFileBatchIOSetUp(&b_handle, 1); - EXPECT_EQ(result, ROCFILE_SUCCESS); + EXPECT_EQ(result, HIPFILE_SUCCESS); EXPECT_EQ(b_handle, expected_b_handle); } @@ -78,14 +78,14 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSetupBadArgument) EXPECT_CALL(mock_state, createBatchContext).WillOnce(Throw(std::invalid_argument(""))); auto result = rocFileBatchIOSetUp(&b_handle, 0); - EXPECT_EQ(result, ROCFILE_INVALID_VALUE); + EXPECT_EQ(result, HIPFILE_INVALID_VALUE); EXPECT_EQ(b_handle, nullptr); } TEST_F(RocFileUnit, TestRocFileBatchIOSetupNullptrHandle) { auto result = rocFileBatchIOSetUp(nullptr, 1); - ASSERT_EQ(result, ROCFILE_INVALID_VALUE); + ASSERT_EQ(result, HIPFILE_INVALID_VALUE); } TEST_F(RocFileUnit, TestRocFileBatchIOSubmitSuccess) @@ -98,7 +98,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSubmitSuccess) EXPECT_CALL(*mock_b_context, submit_operations); auto result = rocFileBatchIOSubmit(b_handle, 1, &io_param, 0); - ASSERT_EQ(result, ROCFILE_SUCCESS); + ASSERT_EQ(result, HIPFILE_SUCCESS); } TEST_F(RocFileUnit, TestRocFileBatchIOSubmitBadHandle) @@ -111,7 +111,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSubmitBadHandle) EXPECT_CALL(*mock_b_context, submit_operations).Times(0); auto result = rocFileBatchIOSubmit(b_handle, 1, &io_param, 0); - rocFileError_t expected_result = {rocFileInvalidValue, hipSuccess}; + hipFileError_t expected_result = {hipFileInvalidValue, hipSuccess}; ASSERT_EQ(result, expected_result); } @@ -125,7 +125,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSubmitBadArgument) EXPECT_CALL(*mock_b_context, submit_operations).WillOnce(Throw(std::invalid_argument(""))); auto result = rocFileBatchIOSubmit(b_handle, 1, &io_param, 0); - ASSERT_EQ(result, ROCFILE_INVALID_VALUE); + ASSERT_EQ(result, HIPFILE_INVALID_VALUE); } /// @brief Test rocFileIO function @@ -169,7 +169,7 @@ TEST_P(RocFileIoParam, RocFileIoHandlesUnsupportedHipMemoryType) attrs.type = memoryType; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); ASSERT_EQ(rocFileIo(GetParam(), file_handle, unreg_bufptr, 0, 0, 0, mbackends), - -static_cast(rocFileHipMemoryTypeInvalid)); + -static_cast(hipFileHipMemoryTypeInvalid)); } } @@ -177,13 +177,13 @@ TEST_P(RocFileIoParam, RocFileIoHandlesInvalidRegisteredBufferLength) { StrictMock mhip; ASSERT_EQ(rocFileIo(GetParam(), file_handle, bufptr, buflen + 1, 0, 0, mbackends), - -static_cast(rocFileInvalidValue)); + -static_cast(hipFileInvalidValue)); } TEST_P(RocFileIoParam, RocFileIoHandlesInvalidFileHandle) { auto invalid_handle{reinterpret_cast(0xdeadbeef)}; - ASSERT_EQ(rocFileIo(GetParam(), invalid_handle, bufptr, 0, 0, 0, mbackends), -rocFileHandleNotRegistered); + ASSERT_EQ(rocFileIo(GetParam(), invalid_handle, bufptr, 0, 0, 0, mbackends), -hipFileHandleNotRegistered); } TEST_P(RocFileIoParam, RocFileIoHandlesSysRuntimeError) @@ -206,7 +206,7 @@ TEST_P(RocFileIoParam, RocFileIoHandlesInvalidArgumentError) { EXPECT_CALL(*mbackend, score).WillOnce(Return(1)); EXPECT_CALL(*mbackend, io).WillOnce(Throw(std::invalid_argument(""))); - ASSERT_EQ(rocFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -rocFileInvalidValue); + ASSERT_EQ(rocFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -hipFileInvalidValue); } INSTANTIATE_TEST_SUITE_P(RocFileIo, RocFileIoParam, Values(IoType::Read, IoType::Write)); @@ -248,11 +248,11 @@ TEST_P(RocFileIoBackendSelectionParam, RocFileIoThrowsIfThereAreNoBackends) switch (io_type) { case IoType::Read: ASSERT_EQ(rocFileRead(handle, buffer, io_size, file_offset, buffer_offset), - -rocFileInternalError); + -hipFileInternalError); break; case IoType::Write: ASSERT_EQ(rocFileWrite(handle, buffer, io_size, file_offset, buffer_offset), - -rocFileInternalError); + -hipFileInternalError); break; default: FAIL() << "Unhandled IO Type"; @@ -276,11 +276,11 @@ TEST_P(RocFileIoBackendSelectionParam, RocFileIoThrowsIfAllBackendsRejectTheIO) switch (io_type) { case IoType::Read: ASSERT_EQ(rocFileRead(handle, buffer, io_size, file_offset, buffer_offset), - -rocFileInternalError); + -hipFileInternalError); break; case IoType::Write: ASSERT_EQ(rocFileWrite(handle, buffer, io_size, file_offset, buffer_offset), - -rocFileInternalError); + -hipFileInternalError); break; default: FAIL() << "Unhandled IO Type"; diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index bd72a5bb..faed4ba7 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -128,13 +128,13 @@ struct RocFileStreamExternal : public RocFileOpened { TEST_F(RocFileStreamExternal, register_and_deregister_with_valid_stream_works) { - ASSERT_EQ(rocFileStreamRegister(nonnull_stream, 0), ROCFILE_SUCCESS); - ASSERT_EQ(rocFileStreamDeregister(nonnull_stream), ROCFILE_SUCCESS); + ASSERT_EQ(rocFileStreamRegister(nonnull_stream, 0), HIPFILE_SUCCESS); + ASSERT_EQ(rocFileStreamDeregister(nonnull_stream), HIPFILE_SUCCESS); } TEST_F(RocFileStreamExternal, deregister_exception_returns_error) { - ASSERT_EQ(rocFileStreamDeregister(nullptr), RocFileOpError(rocFileInvalidValue)); + ASSERT_EQ(rocFileStreamDeregister(nullptr), RocFileOpError(hipFileInvalidValue)); } HIPFILE_WARN_NO_GLOBAL_CTOR_ON From b00d81f3734912b0500add9c47a2294ff9461682 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 04:21:47 -0700 Subject: [PATCH 27/48] Migrate the driver API to hipFile --- hipfile/include/rocfile.h | 49 ------------------ hipfile/src/amd_detail/hipfile.cpp | 24 --------- hipfile/src/amd_detail/rocfile.cpp | 6 +-- hipfile/test/amd_detail/driver.cpp | 70 +++++++++++++------------- hipfile/test/amd_detail/fallback.cpp | 8 +-- hipfile/test/amd_detail/rocfile-test.h | 18 +++---- 6 files changed, 51 insertions(+), 124 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 733201d7..3f8cd649 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -237,55 +237,6 @@ ROCFILE_API ssize_t rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset); -// *********************************************************************** -// GPU IO DRIVER API -// *********************************************************************** - -/*! - * @brief Initialize the GPU IO driver for this process - * @ingroup driver - * - * Each call to `rocFileDriverOpen()` increments the library's reference - * count. If a call to `rocFileDriverOpen()` results in the reference count - * transitioning from zero to one, the library's state will be initialized. - * - * Calling `rocFileDriverOpen()` is optional. The first call to - * `rocFileBufRegister()` or `rocFileHandleRegister()` will trigger - * library initialization and increment the library's reference count. - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileDriverOpen(void); - -/*! - * @brief Close the GPU IO driver for this process - * @ingroup driver - * - * Each call to `rocFileDriverClose()` decrements the library's reference - * count. If a call to `rocFileDriverClose()` results in the reference count - * transitioning from one to zero, the library's state will be destroyed. - * - * Explicitly closing the library is not required; the library's state will be - * destroyed automatically at program exit. - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileDriverClose(void); - -/*! - * @brief Obtain the current reference count for the library - * @ingroup driver - * - * @see rocFileDriverOpen() - * @see rocFileDriverClose() - * - * @return The library's reference count - */ -ROCFILE_API -int64_t rocFileUseCount(void); - // *********************************************************************** // BATCH API // *********************************************************************** diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index 818e5abe..fda43c40 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -91,30 +91,6 @@ hipFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t fi return result; } -hipFileError_t -hipFileDriverOpen() -try { - return rocFileDriverOpen(); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileDriverClose() -try { - return rocFileDriverClose(); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -int64_t -hipFileUseCount() -{ - return rocFileUseCount(); -} - hipFileError_t hipFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr) try { diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 9ac058c3..fb9faf56 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -220,7 +220,7 @@ rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t fi } hipFileError_t -rocFileDriverOpen() +hipFileDriverOpen() try { Context::get()->incrRefCount(); @@ -231,7 +231,7 @@ catch (...) { } hipFileError_t -rocFileDriverClose() +hipFileDriverClose() try { if (Context::get()->getRefCount() > 0) { Context::get()->decrRefCount(); @@ -246,7 +246,7 @@ catch (...) { } int64_t -rocFileUseCount() +hipFileUseCount() try { return Context::get()->getRefCount(); } diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index a9e6d814..f339fa05 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -33,19 +33,19 @@ TEST_F(RocFileDriverAdmin, OpenClose) { const int64_t N = 10; - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); for (int64_t i = 1; i <= N; i++) { - ASSERT_EQ(rocFileDriverOpen(), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), i); + ASSERT_EQ(hipFileDriverOpen(), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileUseCount(), i); } for (int64_t i = N; i >= 1; i--) { - ASSERT_EQ(rocFileDriverClose(), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), i - 1); + ASSERT_EQ(hipFileDriverClose(), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileUseCount(), i - 1); } - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } // Ensure rocFileHandleRegister() initializes the driver @@ -62,10 +62,10 @@ TEST_F(RocFileDriverAdmin, HandleRegisterInitsDriver) descr.type = rocFileHandleTypeOpaqueFD; descr.fs_ops = nullptr; - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); + ASSERT_EQ(hipFileUseCount(), 1); } // Ensure rocFileHandleRegister() handles a file descriptor @@ -85,11 +85,11 @@ TEST_F(RocFileDriverAdmin, HandleRegisterGoodFD) expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); + ASSERT_EQ(hipFileUseCount(), 1); ASSERT_EQ(rocFileHandleDeregister(handle), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); + ASSERT_EQ(hipFileUseCount(), 1); } // Ensure rocFileHandleRegister() fails when passed a negative file @@ -107,9 +107,9 @@ TEST_F(RocFileDriverAdmin, HandleRegisterBadFD) EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); ASSERT_NE(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } // Ensure rocFileHandleDeregister() fails when passed a NULL or @@ -120,16 +120,16 @@ TEST_F(RocFileDriverAdmin, HandleDeregisterDoesNotInitDriver) StrictMock mlibmounthelper{}; // Check NULL - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); ASSERT_NE(rocFileHandleDeregister(nullptr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); // Check unregistered handle rocFileHandle_t handle{}; - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); ASSERT_NE(rocFileHandleDeregister(handle), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } // Ensure that closing the driver will also close any open handles. This @@ -147,15 +147,15 @@ TEST_F(RocFileDriverAdmin, CloseDeregistersFile) descr.type = rocFileHandleTypeOpaqueFD; descr.fs_ops = nullptr; - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); - ASSERT_EQ(rocFileDriverClose(), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 1); + ASSERT_EQ(hipFileDriverClose(), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); + ASSERT_EQ(hipFileUseCount(), 1); } // Ensure that registering a buffer increments the driver reference @@ -166,18 +166,18 @@ TEST_F(RocFileDriverAdmin, BufRegisterInitsDriver) expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); + ASSERT_EQ(hipFileUseCount(), 1); } // Ensure that buffer deregistration does not increment the driver // reference count TEST_F(RocFileDriverAdmin, BufDeregisterDoesNotInitDriver) { - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); ASSERT_EQ(rocFileBufDeregister(nullptr), RocFileOpError(hipFileDriverNotInitialized)); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } // Ensure that closing the driver also closes open buffers. This is @@ -187,17 +187,17 @@ TEST_F(RocFileDriverAdmin, CloseDeregistersBuffer) { StrictMock mhip; - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); expect_buffer_registration(mhip, hipMemoryTypeDevice); ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); + ASSERT_EQ(hipFileUseCount(), 1); - ASSERT_EQ(rocFileDriverClose(), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileDriverClose(), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileUseCount(), 0); expect_buffer_registration(mhip, hipMemoryTypeDevice); ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileUseCount(), 1); + ASSERT_EQ(hipFileUseCount(), 1); } // Ensure rocFileReadAsync(): @@ -207,7 +207,7 @@ TEST_F(RocFileDriverAdmin, ReadAsyncDoesNotInitDriver) { ASSERT_EQ(rocFileReadAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), RocFileOpError(hipFileDriverNotInitialized)); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } // Ensure rocFileWriteAsync(): @@ -217,7 +217,7 @@ TEST_F(RocFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) { ASSERT_EQ(rocFileWriteAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), RocFileOpError(hipFileDriverNotInitialized)); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } // Ensure rocFileRead(): @@ -227,7 +227,7 @@ TEST_F(RocFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) TEST_F(RocFileDriverAdmin, ReadDoesNotInitDriver) { ASSERT_EQ(rocFileRead(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } // Ensure rocFileWrite(): @@ -237,7 +237,7 @@ TEST_F(RocFileDriverAdmin, ReadDoesNotInitDriver) TEST_F(RocFileDriverAdmin, WriteDoesNotInitDriver) { ASSERT_EQ(rocFileWrite(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); - ASSERT_EQ(rocFileUseCount(), 0); + ASSERT_EQ(hipFileUseCount(), 0); } HIPFILE_WARN_NO_GLOBAL_CTOR_ON diff --git a/hipfile/test/amd_detail/fallback.cpp b/hipfile/test/amd_detail/fallback.cpp index 874b5c43..632bfa84 100644 --- a/hipfile/test/amd_detail/fallback.cpp +++ b/hipfile/test/amd_detail/fallback.cpp @@ -188,7 +188,7 @@ struct FallbackParam : ::testing::TestWithParam { StrictMock msys; StrictMock mlibmounthelper; - assert(rocFileDriverOpen() == HIPFILE_SUCCESS); + assert(hipFileDriverOpen() == HIPFILE_SUCCESS); expect_buffer_registration(mhip, hipMemoryTypeDevice); void *buf = reinterpret_cast(0xFEFEFEFE); @@ -202,12 +202,12 @@ struct FallbackParam : ::testing::TestWithParam { ~FallbackParam() override { // Drop the references to the file & buffer so that they can be - // deregistered in rocFileDriverClose() + // deregistered in hipFileDriverClose() file.reset(); buffer.reset(); - while (rocFileUseCount()) { - assert(rocFileDriverClose() == HIPFILE_SUCCESS); + while (hipFileUseCount()) { + assert(hipFileDriverClose() == HIPFILE_SUCCESS); } } diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h index d3721426..2f781713 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/rocfile-test.h @@ -79,16 +79,16 @@ struct RocFileOpened : public ::testing::Test { RocFileOpened() { - assert(rocFileUseCount() == 0); - assert(rocFileDriverOpen() == HIPFILE_SUCCESS); + assert(hipFileUseCount() == 0); + assert(hipFileDriverOpen() == HIPFILE_SUCCESS); } virtual ~RocFileOpened() override { - while (rocFileUseCount()) { - assert(rocFileDriverClose() == HIPFILE_SUCCESS); + while (hipFileUseCount()) { + assert(hipFileDriverClose() == HIPFILE_SUCCESS); } - assert(rocFileUseCount() == 0); + assert(hipFileUseCount() == 0); } }; @@ -97,15 +97,15 @@ struct RocFileUnopened : public ::testing::Test { RocFileUnopened() { - assert(rocFileUseCount() == 0); + assert(hipFileUseCount() == 0); } virtual ~RocFileUnopened() override { - while (rocFileUseCount()) { - assert(rocFileDriverClose() == HIPFILE_SUCCESS); + while (hipFileUseCount()) { + assert(hipFileDriverClose() == HIPFILE_SUCCESS); } - assert(rocFileUseCount() == 0); + assert(hipFileUseCount() == 0); } }; From 8d16d3cdfe505611f97a7de32b784e093c330d8c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 04:32:59 -0700 Subject: [PATCH 28/48] Rename rocFileIo --> hipFileIo --- hipfile/src/amd_detail/hipfile-private.h | 2 +- hipfile/src/amd_detail/rocfile.cpp | 6 +++--- hipfile/test/amd_detail/rocfile.cpp | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hipfile/src/amd_detail/hipfile-private.h b/hipfile/src/amd_detail/hipfile-private.h index ab4146c5..7807b2d4 100644 --- a/hipfile/src/amd_detail/hipfile-private.h +++ b/hipfile/src/amd_detail/hipfile-private.h @@ -25,6 +25,6 @@ struct Backend; HIPFILE_API void hipFileEnsureDriverInitPrivate(); -ssize_t rocFileIo(hipFile::IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, +ssize_t hipFileIo(hipFile::IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset, const std::vector> &backends); diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index fb9faf56..b5550411 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -150,7 +150,7 @@ getCachedBackends() } ssize_t -rocFileIo(IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, +hipFileIo(IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset, const vector> &backends) try { auto [file, buffer] = Context::get()->getFileAndBuffer(fh, buffer_base, size, 0); @@ -209,14 +209,14 @@ catch (...) { ssize_t rocFileRead(rocFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) { - return rocFileIo(IoType::Read, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); + return hipFileIo(IoType::Read, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); } ssize_t rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) { - return rocFileIo(IoType::Write, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); + return hipFileIo(IoType::Write, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); } hipFileError_t diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index fd3f4479..b158964a 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -158,7 +158,7 @@ TEST_P(RocFileIoParam, RocFileIoHandlesHipPointerGetAttributesError) { StrictMock mhip; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorUnknown))); - ASSERT_EQ(rocFileIo(GetParam(), file_handle, unreg_bufptr, 0, 0, 0, mbackends), -hipErrorUnknown); + ASSERT_EQ(hipFileIo(GetParam(), file_handle, unreg_bufptr, 0, 0, 0, mbackends), -hipErrorUnknown); } TEST_P(RocFileIoParam, RocFileIoHandlesUnsupportedHipMemoryType) @@ -168,7 +168,7 @@ TEST_P(RocFileIoParam, RocFileIoHandlesUnsupportedHipMemoryType) hipPointerAttribute_t attrs{}; attrs.type = memoryType; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileIo(GetParam(), file_handle, unreg_bufptr, 0, 0, 0, mbackends), + ASSERT_EQ(hipFileIo(GetParam(), file_handle, unreg_bufptr, 0, 0, 0, mbackends), -static_cast(hipFileHipMemoryTypeInvalid)); } } @@ -176,14 +176,14 @@ TEST_P(RocFileIoParam, RocFileIoHandlesUnsupportedHipMemoryType) TEST_P(RocFileIoParam, RocFileIoHandlesInvalidRegisteredBufferLength) { StrictMock mhip; - ASSERT_EQ(rocFileIo(GetParam(), file_handle, bufptr, buflen + 1, 0, 0, mbackends), + ASSERT_EQ(hipFileIo(GetParam(), file_handle, bufptr, buflen + 1, 0, 0, mbackends), -static_cast(hipFileInvalidValue)); } TEST_P(RocFileIoParam, RocFileIoHandlesInvalidFileHandle) { auto invalid_handle{reinterpret_cast(0xdeadbeef)}; - ASSERT_EQ(rocFileIo(GetParam(), invalid_handle, bufptr, 0, 0, 0, mbackends), -hipFileHandleNotRegistered); + ASSERT_EQ(hipFileIo(GetParam(), invalid_handle, bufptr, 0, 0, 0, mbackends), -hipFileHandleNotRegistered); } TEST_P(RocFileIoParam, RocFileIoHandlesSysRuntimeError) @@ -191,7 +191,7 @@ TEST_P(RocFileIoParam, RocFileIoHandlesSysRuntimeError) EXPECT_CALL(*mbackend, score).WillOnce(Return(1)); EXPECT_CALL(*mbackend, io).WillOnce(Throw(Sys::RuntimeError(EBADFD))); errno = 0; - ASSERT_EQ(rocFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -1); + ASSERT_EQ(hipFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -1); ASSERT_EQ(errno, EBADFD); } @@ -199,14 +199,14 @@ TEST_P(RocFileIoParam, RocFileIoHandlesHipRuntimeError) { EXPECT_CALL(*mbackend, score).WillOnce(Return(1)); EXPECT_CALL(*mbackend, io).WillOnce(Throw(Hip::RuntimeError(hipErrorUnknown))); - ASSERT_EQ(rocFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -hipErrorUnknown); + ASSERT_EQ(hipFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -hipErrorUnknown); } TEST_P(RocFileIoParam, RocFileIoHandlesInvalidArgumentError) { EXPECT_CALL(*mbackend, score).WillOnce(Return(1)); EXPECT_CALL(*mbackend, io).WillOnce(Throw(std::invalid_argument(""))); - ASSERT_EQ(rocFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -hipFileInvalidValue); + ASSERT_EQ(hipFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -hipFileInvalidValue); } INSTANTIATE_TEST_SUITE_P(RocFileIo, RocFileIoParam, Values(IoType::Read, IoType::Write)); From 1dc55e9074365dfde603bb0c8dc814380d69342c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 04:35:32 -0700 Subject: [PATCH 29/48] Minor comment fix --- hipfile/test/amd_detail/rocfile-test.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h index 2f781713..4d4f3871 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/rocfile-test.h @@ -5,7 +5,7 @@ #pragma once -// Common rocFile test functionality +// Common hipFile test functionality #include "hipfile.h" #include "magic-word.h" @@ -24,7 +24,7 @@ // ERRORS AND ERROR HANDLING // *********************************************************************** -// Set a particular rocFile error +// Set a particular hipFile error constexpr hipFileError_t RocFileHipError(hipError_t err) { From 761397c005426c8f77a0bae329eb8f3b4ac131f0 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 04:41:03 -0700 Subject: [PATCH 30/48] Rename RocFileOpError and RocFileHipError --- hipfile/test/amd_detail/buffer.cpp | 22 +++++++++++----------- hipfile/test/amd_detail/driver.cpp | 6 +++--- hipfile/test/amd_detail/handle.cpp | 18 +++++++++--------- hipfile/test/amd_detail/rocfile-test.h | 4 ++-- hipfile/test/amd_detail/stream.cpp | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/hipfile/test/amd_detail/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp index 2b5136a4..cbaa60b5 100644 --- a/hipfile/test/amd_detail/buffer.cpp +++ b/hipfile/test/amd_detail/buffer.cpp @@ -82,7 +82,7 @@ TEST_F(RocFileBuffer, register_unsupported_hip_memory) hipPointerAttribute_t attrs{}; attrs.type = memoryType; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(hipFileHipMemoryTypeInvalid)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileHipMemoryTypeInvalid)); } } @@ -97,12 +97,12 @@ TEST_F(RocFileBuffer, register_hip_pointer_get_attributes_error) { StrictMock mhip; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorUnknown))); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileHipError(hipErrorUnknown)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileHipError(hipErrorUnknown)); // hipErrorInvalidValue is handled differently to match the behaviour of cufile EXPECT_CALL(mhip, hipPointerGetAttributes) .WillOnce(testing::Throw(Hip::RuntimeError(hipErrorInvalidValue))); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(hipFileInvalidValue)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileInvalidValue)); } TEST_F(RocFileBuffer, register_internal_already_registered) @@ -118,12 +118,12 @@ TEST_F(RocFileBuffer, register_already_registered) StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), RocFileOpError(hipFileMemoryAlreadyRegistered)); + ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileMemoryAlreadyRegistered)); } TEST_F(RocFileBuffer, registerNullPointerReturnsError) { - ASSERT_EQ(rocFileBufRegister(nullptr, 0x10000, 0), RocFileOpError(hipFileInvalidValue)); + ASSERT_EQ(rocFileBufRegister(nullptr, 0x10000, 0), HipFileOpError(hipFileInvalidValue)); } TEST_F(RocFileBuffer, registerOversizeRangeReturnsError) @@ -135,7 +135,7 @@ TEST_F(RocFileBuffer, registerOversizeRangeReturnsError) attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 101, 0), - RocFileOpError(hipFileHipPointerRangeError)); + HipFileOpError(hipFileHipPointerRangeError)); } TEST_F(RocFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) @@ -145,7 +145,7 @@ TEST_F(RocFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) hipPointerAttribute_t attrs{}; attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 100, 0), RocFileOpError(hipFileInvalidValue)); + ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 100, 0), HipFileOpError(hipFileInvalidValue)); } TEST_F(RocFileBuffer, registerOverflowingRangeReturnsError) @@ -157,7 +157,7 @@ TEST_F(RocFileBuffer, registerOverflowingRangeReturnsError) attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0xFFFF0000), 0x10000, 0), - RocFileOpError(hipFileHipPointerRangeError)); + HipFileOpError(hipFileHipPointerRangeError)); } TEST_F(RocFileBuffer, deregister_internal_not_registered) @@ -167,7 +167,7 @@ TEST_F(RocFileBuffer, deregister_internal_not_registered) TEST_F(RocFileBuffer, deregister_not_registered) { - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(hipFileMemoryNotRegistered)); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); } TEST_F(RocFileBuffer, deregister_internal) @@ -201,7 +201,7 @@ TEST_F(RocFileBuffer, deregister_duplicate_deregister) expect_buffer_registration(mhip, hipMemoryTypeDevice); ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(hipFileMemoryNotRegistered)); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); } TEST_F(RocFileBuffer, deregister_internal_get_prevents_deregister) @@ -223,7 +223,7 @@ TEST_F(RocFileBuffer, deregister_get_prevents_deregister) ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); { auto buffer = Context::get()->getBuffer(nonnull_ptr); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), RocFileOpError(hipFileInternalError)); + ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileInternalError)); } ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); } diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index f339fa05..00f778dd 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -176,7 +176,7 @@ TEST_F(RocFileDriverAdmin, BufRegisterInitsDriver) TEST_F(RocFileDriverAdmin, BufDeregisterDoesNotInitDriver) { ASSERT_EQ(hipFileUseCount(), 0); - ASSERT_EQ(rocFileBufDeregister(nullptr), RocFileOpError(hipFileDriverNotInitialized)); + ASSERT_EQ(rocFileBufDeregister(nullptr), HipFileOpError(hipFileDriverNotInitialized)); ASSERT_EQ(hipFileUseCount(), 0); } @@ -206,7 +206,7 @@ TEST_F(RocFileDriverAdmin, CloseDeregistersBuffer) TEST_F(RocFileDriverAdmin, ReadAsyncDoesNotInitDriver) { ASSERT_EQ(rocFileReadAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), - RocFileOpError(hipFileDriverNotInitialized)); + HipFileOpError(hipFileDriverNotInitialized)); ASSERT_EQ(hipFileUseCount(), 0); } @@ -216,7 +216,7 @@ TEST_F(RocFileDriverAdmin, ReadAsyncDoesNotInitDriver) TEST_F(RocFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) { ASSERT_EQ(rocFileWriteAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), - RocFileOpError(hipFileDriverNotInitialized)); + HipFileOpError(hipFileDriverNotInitialized)); ASSERT_EQ(hipFileUseCount(), 0); } diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index 99255b40..6b4b31fe 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -118,7 +118,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterStatxError) EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileInternalError)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); } // If the fcntl() fails during file registration return rocfileInternalError @@ -132,7 +132,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterFcntlError) EXPECT_CALL(msys, statx); EXPECT_CALL(msys, fcntl).WillOnce(Throw(Sys::RuntimeError(EBADF))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileInternalError)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); } // If getting mount information fails during file registration return rocfileInternalError @@ -147,7 +147,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterLibMountError) EXPECT_CALL(msys, fcntl); EXPECT_CALL(mlibmounthelper, getMountInfo).WillOnce(Throw(std::runtime_error("error from test"))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileInternalError)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); } TEST_F(RocFileHandle, register_handle_linux_fd_already_registered) @@ -162,7 +162,7 @@ TEST_F(RocFileHandle, register_handle_linux_fd_already_registered) ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); ASSERT_NE(fh, nullptr); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileHandleAlreadyRegistered)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileHandleAlreadyRegistered)); } TEST_F(RocFileHandle, register_handle_windows_handle_not_supported) @@ -173,7 +173,7 @@ TEST_F(RocFileHandle, register_handle_windows_handle_not_supported) rfd.type = rocFileHandleTypeOpaqueWin32; rfd.handle.fd = 0xBADF00D; - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileIONotSupported)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); } TEST_F(RocFileHandle, register_handle_userspace_fs_not_supported) @@ -184,7 +184,7 @@ TEST_F(RocFileHandle, register_handle_userspace_fs_not_supported) rfd.type = rocFileHandleTypeUserspaceFS; rfd.handle.fd = 0xBADF00D; - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), RocFileOpError(hipFileIONotSupported)); + ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); } TEST_F(RocFileHandle, deregister_handle_internal_throws_if_not_registered) @@ -196,7 +196,7 @@ TEST_F(RocFileHandle, deregister_handle_internal_throws_if_not_registered) TEST_F(RocFileHandle, deregister_handle_returns_error_if_not_registered) { ASSERT_EQ(rocFileHandleDeregister(reinterpret_cast(0xdeadbeef)), - RocFileOpError(hipFileHandleNotRegistered)); + HipFileOpError(hipFileHandleNotRegistered)); } TEST_F(RocFileHandle, deregister_handle_internal) @@ -218,7 +218,7 @@ TEST_F(RocFileHandle, deregister_handle) expect_file_registration(msys, mlibmounthelper); ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); ASSERT_EQ(rocFileHandleDeregister(fh), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileHandleDeregister(fh), RocFileOpError(hipFileHandleNotRegistered)); + ASSERT_EQ(rocFileHandleDeregister(fh), HipFileOpError(hipFileHandleNotRegistered)); } TEST_F(RocFileHandle, deregister_handle_internal_fails_when_operations_are_oustanding) @@ -244,7 +244,7 @@ TEST_F(RocFileHandle, deregister_handle_fails_when_operations_are_oustanding) ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); { auto file = Context::get()->getFile(fh); - ASSERT_EQ(rocFileHandleDeregister(fh), RocFileOpError(hipFileInternalError)); + ASSERT_EQ(rocFileHandleDeregister(fh), HipFileOpError(hipFileInternalError)); } ASSERT_EQ(rocFileHandleDeregister(fh), HIPFILE_SUCCESS); } diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h index 4d4f3871..01cbf103 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/rocfile-test.h @@ -26,14 +26,14 @@ // Set a particular hipFile error constexpr hipFileError_t -RocFileHipError(hipError_t err) +HipFileHipError(hipError_t err) { return {hipFileHipDriverError, err}; } // Set a particular HIP error constexpr hipFileError_t -RocFileOpError(hipFileOpError_t err) +HipFileOpError(hipFileOpError_t err) { return {err, hipSuccess}; } diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index faed4ba7..2cd03f38 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -134,7 +134,7 @@ TEST_F(RocFileStreamExternal, register_and_deregister_with_valid_stream_works) TEST_F(RocFileStreamExternal, deregister_exception_returns_error) { - ASSERT_EQ(rocFileStreamDeregister(nullptr), RocFileOpError(hipFileInvalidValue)); + ASSERT_EQ(rocFileStreamDeregister(nullptr), HipFileOpError(hipFileInvalidValue)); } HIPFILE_WARN_NO_GLOBAL_CTOR_ON From ffd51b204240d8840c223000427f155fc62338f1 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 04:48:35 -0700 Subject: [PATCH 31/48] Rename everything RocFile* to HipFile* --- hipfile/src/amd_detail/buffer.h | 8 +-- hipfile/src/amd_detail/context.cpp | 4 +- hipfile/src/amd_detail/context.h | 6 +- hipfile/src/amd_detail/file.h | 6 +- hipfile/test/amd_detail/async.cpp | 42 +++++++------- hipfile/test/amd_detail/batch/batch.cpp | 76 ++++++++++++------------- hipfile/test/amd_detail/buffer.cpp | 62 ++++++++++---------- hipfile/test/amd_detail/context.cpp | 8 +-- hipfile/test/amd_detail/driver.cpp | 28 ++++----- hipfile/test/amd_detail/fallback.cpp | 6 +- hipfile/test/amd_detail/handle.cpp | 34 +++++------ hipfile/test/amd_detail/rocfile-test.h | 12 ++-- hipfile/test/amd_detail/rocfile.cpp | 46 +++++++-------- hipfile/test/amd_detail/stream.cpp | 36 ++++++------ 14 files changed, 187 insertions(+), 187 deletions(-) diff --git a/hipfile/src/amd_detail/buffer.h b/hipfile/src/amd_detail/buffer.h index f837dc64..02a219ed 100644 --- a/hipfile/src/amd_detail/buffer.h +++ b/hipfile/src/amd_detail/buffer.h @@ -108,26 +108,26 @@ class BufferMap { virtual ~BufferMap(); /// @brief Creates and registers a buffer - /// @attention A unique_lock on RocFileMutex must be held + /// @attention A unique_lock on HipFileMutex must be held /// @param buf Buffer pointer /// @param length Buffer length /// @param flags Buffer flags (unused) virtual void registerBuffer(const void *buf, size_t length, int flags); /// @brief Deregisters and destroys a buffer - /// @attention A unique_lock on RocFileMutex must be held + /// @attention A unique_lock on HipFileMutex must be held /// @param buf Buffer pointer virtual void deregisterBuffer(const void *buf); /// @brief Look up a registered buffer using the buffer pointer - /// @attention A shared_lock on RocFileMutex must be held + /// @attention A shared_lock on HipFileMutex must be held /// @param buf Buffer pointer /// @return A registered buffer virtual std::shared_ptr getBuffer(const void *buf); /// @brief Look up a registered buffer. Returns a temporary unregistered /// buffer (of size length, using flags) if no matching buffer is found. - /// @attention A shared_lock on RocFileMutex must be held + /// @attention A shared_lock on HipFileMutex must be held /// @param buf Buffer pointer /// @param length Buffer length /// @return A registered or temporary unregistered buffer diff --git a/hipfile/src/amd_detail/context.cpp b/hipfile/src/amd_detail/context.cpp index 41136cb0..746e0cd7 100644 --- a/hipfile/src/amd_detail/context.cpp +++ b/hipfile/src/amd_detail/context.cpp @@ -11,7 +11,7 @@ namespace hipFile { -RocFileInit::RocFileInit() +HipFileInit::HipFileInit() { Context::get(); Context::get(); @@ -20,7 +20,7 @@ RocFileInit::RocFileInit() HIPFILE_WARN_NO_GLOBAL_CTOR_OFF HIPFILE_WARN_NO_EXIT_DTOR_OFF -static RocFileInit *rocfile_init = Context::get(); +static HipFileInit *rocfile_init = Context::get(); HIPFILE_WARN_NO_EXIT_DTOR_ON HIPFILE_WARN_NO_GLOBAL_CTOR_ON diff --git a/hipfile/src/amd_detail/context.h b/hipfile/src/amd_detail/context.h index 6817369f..b568c9f6 100644 --- a/hipfile/src/amd_detail/context.h +++ b/hipfile/src/amd_detail/context.h @@ -92,9 +92,9 @@ template struct ContextOverride { }; #endif -class RocFileInit { - RocFileInit(); - friend struct Context; +class HipFileInit { + HipFileInit(); + friend struct Context; }; } diff --git a/hipfile/src/amd_detail/file.h b/hipfile/src/amd_detail/file.h index 1f2707cf..5908f891 100644 --- a/hipfile/src/amd_detail/file.h +++ b/hipfile/src/amd_detail/file.h @@ -132,17 +132,17 @@ class FileMap { virtual ~FileMap(); /// @brief Registers a file. Files must be registered before they can be used with rocFile IO APIs - /// @attention A unique_lock on RocFileMutex must be held + /// @attention A unique_lock on HipFileMutex must be held /// @param uf An unregistered file virtual rocFileHandle_t registerFile(const UnregisteredFile &uf); /// @brief Deregisters the file associated with the provided file handle - /// @attention A unique_lock on RocFileMutex must be held + /// @attention A unique_lock on HipFileMutex must be held /// @param fh The handle of the file to deregister virtual void deregisterFile(rocFileHandle_t fh); /// @brief Look up a file given a rocFileHandle_t - /// @attention A shared_lock on RocFileMutex must be held + /// @attention A shared_lock on HipFileMutex must be held /// @param fh The file handle to lookup the file with /// @return If file handle is valid, return a shared pointer to the file, otherwise throw NotRegistered. virtual std::shared_ptr getFile(rocFileHandle_t fh); diff --git a/hipfile/test/amd_detail/async.cpp b/hipfile/test/amd_detail/async.cpp index 340d0dbe..8d93b76c 100644 --- a/hipfile/test/amd_detail/async.cpp +++ b/hipfile/test/amd_detail/async.cpp @@ -47,8 +47,8 @@ using ::testing::WithParamInterface; typedef struct stat stat_t; -struct RocFileAsyncOp : public Test { - RocFileAsyncOp() +struct HipFileAsyncOp : public Test { + HipFileAsyncOp() : buffer{std::make_shared>()}, file{std::make_shared>()}, stream{std::make_shared>()} { @@ -68,7 +68,7 @@ struct RocFileAsyncOp : public Test { shared_ptr stream; }; -struct RocFileAsyncMonitor : RocFileAsyncOp { +struct HipFileAsyncMonitor : HipFileAsyncOp { AsyncMonitor monitor; }; @@ -79,10 +79,10 @@ rocfileFlagsPowerSet() Values(0, HIPFILE_STREAM_FIXED_FILE_SIZE), Values(0, HIPFILE_STREAM_PAGE_ALIGNED_INPUTS)); } -struct RocFileAsyncOpStreamParams - : public RocFileAsyncOp, +struct HipFileAsyncOpStreamParams + : public HipFileAsyncOp, public WithParamInterface> { - RocFileAsyncOpStreamParams() : RocFileAsyncOp{} + HipFileAsyncOpStreamParams() : HipFileAsyncOp{} { auto params = GetParam(); bool fixed_buf_offset = std::get<0>(params) > 0; @@ -102,7 +102,7 @@ struct RocFileAsyncOpStreamParams unsigned flags; }; -TEST_P(RocFileAsyncOpStreamParams, asyncOp_construction_has_correct_variants) +TEST_P(HipFileAsyncOpStreamParams, asyncOp_construction_has_correct_variants) { size_t size = 100; hoff_t file_offset = 0; @@ -131,9 +131,9 @@ TEST_P(RocFileAsyncOpStreamParams, asyncOp_construction_has_correct_variants) EXPECT_NO_THROW(std::get(op->size)); } } -INSTANTIATE_TEST_SUITE_P(StreamSuite, RocFileAsyncOpStreamParams, rocfileFlagsPowerSet()); +INSTANTIATE_TEST_SUITE_P(StreamSuite, HipFileAsyncOpStreamParams, rocfileFlagsPowerSet()); -TEST_F(RocFileAsyncOp, AsyncOpFallback_new_uses_pinned_host_memory) +TEST_F(HipFileAsyncOp, AsyncOpFallback_new_uses_pinned_host_memory) { size_t size = 100; hoff_t file_offset = 0; @@ -149,7 +149,7 @@ TEST_F(RocFileAsyncOp, AsyncOpFallback_new_uses_pinned_host_memory) IoType::Read, file, buffer, stream, &size, &file_offset, &buffer_offset, &bytes_transferred}); } -TEST_F(RocFileAsyncOp, AsyncOpFallback_new_failure_throws_bad_alloc) +TEST_F(HipFileAsyncOp, AsyncOpFallback_new_failure_throws_bad_alloc) { size_t size = 100; hoff_t file_offset = 0; @@ -163,7 +163,7 @@ TEST_F(RocFileAsyncOp, AsyncOpFallback_new_failure_throws_bad_alloc) std::bad_alloc); } -TEST_F(RocFileAsyncOp, AsyncOpFallback_bounce_alloc_failure_throws) +TEST_F(HipFileAsyncOp, AsyncOpFallback_bounce_alloc_failure_throws) { size_t size = 100; hoff_t file_offset = 0; @@ -180,7 +180,7 @@ TEST_F(RocFileAsyncOp, AsyncOpFallback_bounce_alloc_failure_throws) Hip::RuntimeError); } -TEST_F(RocFileAsyncOp, AsyncOpFallback_bounce_buffer_deleter_failure_calls_syslog) +TEST_F(HipFileAsyncOp, AsyncOpFallback_bounce_buffer_deleter_failure_calls_syslog) { size_t size = 100; hoff_t file_offset = 0; @@ -198,7 +198,7 @@ TEST_F(RocFileAsyncOp, AsyncOpFallback_bounce_buffer_deleter_failure_calls_syslo IoType::Read, file, buffer, stream, &size, &file_offset, &buffer_offset, &bytes_transferred}); } -TEST_F(RocFileAsyncOp, AsyncOpFallback_delete_failure_calls_syslog) +TEST_F(HipFileAsyncOp, AsyncOpFallback_delete_failure_calls_syslog) { size_t size = 100; hoff_t file_offset = 0; @@ -216,8 +216,8 @@ TEST_F(RocFileAsyncOp, AsyncOpFallback_delete_failure_calls_syslog) IoType::Read, file, buffer, stream, &size, &file_offset, &buffer_offset, &bytes_transferred}); } -struct RocFileAsyncOpFallbackFunctions : public RocFileAsyncOp { - RocFileAsyncOpFallbackFunctions() : bounce_buffer{new uint8_t[size]} +struct HipFileAsyncOpFallbackFunctions : public HipFileAsyncOp { + HipFileAsyncOpFallbackFunctions() : bounce_buffer{new uint8_t[size]} { // make_shared uses placement new, which will not use hipHostMalloc/hipHostFree for // AsyncOpFallback @@ -226,7 +226,7 @@ struct RocFileAsyncOpFallbackFunctions : public RocFileAsyncOp { op = std::make_shared(IoType::Read, file, buffer, stream, &size, &file_offset, &buffer_offset, &bytes_transferred); } - ~RocFileAsyncOpFallbackFunctions() override + ~HipFileAsyncOpFallbackFunctions() override { EXPECT_CALL(mhip, hipHostFree(Eq(bounce_buffer.get()))); } @@ -239,19 +239,19 @@ struct RocFileAsyncOpFallbackFunctions : public RocFileAsyncOp { std::shared_ptr op; }; -TEST_F(RocFileAsyncOpFallbackFunctions, bounceBufferHostPtr_returns_pointer) +TEST_F(HipFileAsyncOpFallbackFunctions, bounceBufferHostPtr_returns_pointer) { ASSERT_EQ(op->bounceBufferHostPtr(), bounce_buffer.get()); } -TEST_F(RocFileAsyncOpFallbackFunctions, devPtr_calls_hipHostGetDevicePointer) +TEST_F(HipFileAsyncOpFallbackFunctions, devPtr_calls_hipHostGetDevicePointer) { void *addr = reinterpret_cast(0xABACADBA); EXPECT_CALL(mhip, hipHostGetDevicePointer).WillOnce(Return(addr)); ASSERT_EQ(op->devPtr(), addr); } -TEST_F(RocFileAsyncMonitor, addOp_and_completeOp_with_valid_params_works) +TEST_F(HipFileAsyncMonitor, addOp_and_completeOp_with_valid_params_works) { size_t size = 100; hoff_t file_offset = 0; @@ -264,12 +264,12 @@ TEST_F(RocFileAsyncMonitor, addOp_and_completeOp_with_valid_params_works) EXPECT_NO_THROW(monitor.completeOp(op.get())); } -TEST_F(RocFileAsyncMonitor, completeOp_with_invalid_op_throws) +TEST_F(HipFileAsyncMonitor, completeOp_with_invalid_op_throws) { EXPECT_THROW(monitor.completeOp(reinterpret_cast(0xDEADBEEF)), std::invalid_argument); } -TEST_F(RocFileAsyncMonitor, addOp_without_completeOp_prints_error_on_AsyncMonitor_destruction) +TEST_F(HipFileAsyncMonitor, addOp_without_completeOp_prints_error_on_AsyncMonitor_destruction) { size_t size = 100; hoff_t file_offset = 0; diff --git a/hipfile/test/amd_detail/batch/batch.cpp b/hipfile/test/amd_detail/batch/batch.cpp index 1f69f43c..46b2a770 100644 --- a/hipfile/test/amd_detail/batch/batch.cpp +++ b/hipfile/test/amd_detail/batch/batch.cpp @@ -32,7 +32,7 @@ using namespace hipFile; HIPFILE_WARN_NO_GLOBAL_CTOR_OFF -struct RocFileBatch : public RocFileUnopened { +struct HipFileBatch : public HipFileUnopened { BatchContextMap batch_map = BatchContextMap{}; std::unique_ptr io_params; std::shared_ptr> default_mock_buffer; @@ -57,34 +57,34 @@ struct RocFileBatch : public RocFileUnopened { io_params->opcode = rocFileBatchRead; } - RocFileBatch() + HipFileBatch() { batch_map.clear(); } }; -TEST_F(RocFileBatch, CreateOperationRead) +TEST_F(HipFileBatch, CreateOperationRead) { io_params->opcode = rocFileBatchRead; BatchOperation op = BatchOperation{std::move(io_params), default_mock_buffer, default_mock_file}; } -TEST_F(RocFileBatch, CreateOperationWrite) +TEST_F(HipFileBatch, CreateOperationWrite) { io_params->opcode = rocFileBatchWrite; BatchOperation op = BatchOperation{std::move(io_params), default_mock_buffer, default_mock_file}; } -TEST_F(RocFileBatch, CreateOperationBadBuffer) +TEST_F(HipFileBatch, CreateOperationBadBuffer) { EXPECT_CALL(*default_mock_buffer, getBuffer).WillOnce(Return(reinterpret_cast(0xFACEFEED))); EXPECT_THROW(BatchOperation(std::move(io_params), default_mock_buffer, default_mock_file), std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadFileHandle) +TEST_F(HipFileBatch, CreateOperationBadFileHandle) { EXPECT_CALL(*default_mock_file, getHandle) .WillOnce(Return(reinterpret_cast(0xFACEFEED))); @@ -92,7 +92,7 @@ TEST_F(RocFileBatch, CreateOperationBadFileHandle) std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadbufferOffsetIsNegative) +TEST_F(HipFileBatch, CreateOperationBadbufferOffsetIsNegative) { io_params->u.batch.devPtr_offset = -1; @@ -100,7 +100,7 @@ TEST_F(RocFileBatch, CreateOperationBadbufferOffsetIsNegative) std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadBufferOffsetExceedsBuffer) +TEST_F(HipFileBatch, CreateOperationBadBufferOffsetExceedsBuffer) { io_params->u.batch.devPtr_offset = 1; @@ -108,7 +108,7 @@ TEST_F(RocFileBatch, CreateOperationBadBufferOffsetExceedsBuffer) std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadOperationLargerThanBuffer) +TEST_F(HipFileBatch, CreateOperationBadOperationLargerThanBuffer) { io_params->u.batch.size = 2; @@ -116,7 +116,7 @@ TEST_F(RocFileBatch, CreateOperationBadOperationLargerThanBuffer) std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadOperationLargerThanBufferWithOffset) +TEST_F(HipFileBatch, CreateOperationBadOperationLargerThanBufferWithOffset) { EXPECT_CALL(*default_mock_buffer, getLength).WillRepeatedly(Return(10)); io_params->u.batch.devPtr_offset = 6; @@ -126,7 +126,7 @@ TEST_F(RocFileBatch, CreateOperationBadOperationLargerThanBufferWithOffset) std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadFileOffsetIsNegative) +TEST_F(HipFileBatch, CreateOperationBadFileOffsetIsNegative) { io_params->u.batch.file_offset = -1; @@ -134,7 +134,7 @@ TEST_F(RocFileBatch, CreateOperationBadFileOffsetIsNegative) std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadOpcode) +TEST_F(HipFileBatch, CreateOperationBadOpcode) { io_params->opcode = invalidEnum(-1); @@ -142,7 +142,7 @@ TEST_F(RocFileBatch, CreateOperationBadOpcode) std::invalid_argument); } -TEST_F(RocFileBatch, CreateOperationBadMode) +TEST_F(HipFileBatch, CreateOperationBadMode) { io_params->mode = invalidEnum(-1); @@ -150,14 +150,14 @@ TEST_F(RocFileBatch, CreateOperationBadMode) std::invalid_argument); } -TEST_F(RocFileBatch, CreateContext) +TEST_F(HipFileBatch, CreateContext) { rocFileBatchHandle_t handle = batch_map.createContext(32); ASSERT_NE(nullptr, handle); } -TEST_F(RocFileBatch, CreateTwoContexts) +TEST_F(HipFileBatch, CreateTwoContexts) { rocFileBatchHandle_t handle1 = batch_map.createContext(1); rocFileBatchHandle_t handle2 = batch_map.createContext(1); @@ -165,41 +165,41 @@ TEST_F(RocFileBatch, CreateTwoContexts) ASSERT_NE(handle1, handle2); } -TEST_F(RocFileBatch, CreateContextZeroCapacity) +TEST_F(HipFileBatch, CreateContextZeroCapacity) { ASSERT_THROW(batch_map.createContext(0), std::invalid_argument); } -TEST_F(RocFileBatch, CreateContextMaxCapacity) +TEST_F(HipFileBatch, CreateContextMaxCapacity) { rocFileBatchHandle_t handle = batch_map.createContext(BatchContext::MAX_SIZE); ASSERT_NE(nullptr, handle); } -TEST_F(RocFileBatch, CreateContextOverCapacity) +TEST_F(HipFileBatch, CreateContextOverCapacity) { ASSERT_THROW(batch_map.createContext(BatchContext::MAX_SIZE + 1), std::invalid_argument); } -TEST_F(RocFileBatch, DestroyContext) +TEST_F(HipFileBatch, DestroyContext) { rocFileBatchHandle_t handle = batch_map.createContext(1); batch_map.destroyContext(handle); } -TEST_F(RocFileBatch, DestroyMissingContext) +TEST_F(HipFileBatch, DestroyMissingContext) { ASSERT_THROW(batch_map.destroyContext(reinterpret_cast(1)), InvalidBatchHandle); } -TEST_F(RocFileBatch, DestroyNullptrContext) +TEST_F(HipFileBatch, DestroyNullptrContext) { ASSERT_THROW(batch_map.destroyContext(nullptr), InvalidBatchHandle); } -TEST_F(RocFileBatch, GetContext) +TEST_F(HipFileBatch, GetContext) { rocFileBatchHandle_t handle = batch_map.createContext(1); std::shared_ptr context = batch_map.get(handle); @@ -207,24 +207,24 @@ TEST_F(RocFileBatch, GetContext) ASSERT_EQ(handle, context.get()); } -TEST_F(RocFileBatch, GetNullptrContext) +TEST_F(HipFileBatch, GetNullptrContext) { ASSERT_THROW(batch_map.get(nullptr), InvalidBatchHandle); } -TEST_F(RocFileBatch, GetInvalidContext) +TEST_F(HipFileBatch, GetInvalidContext) { ASSERT_THROW(batch_map.get(reinterpret_cast(0xBAC00001)), InvalidBatchHandle); } -TEST_F(RocFileBatch, GetDestroyedContext) +TEST_F(HipFileBatch, GetDestroyedContext) { rocFileBatchHandle_t handle = batch_map.createContext(1); batch_map.destroyContext(handle); ASSERT_THROW(batch_map.get(handle), InvalidBatchHandle); } -struct RocFileBatchContext : public RocFileUnopened { +struct HipFileBatchContext : public HipFileUnopened { BatchContextMap batch_map = BatchContextMap{}; std::shared_ptr _context; unsigned _context_capacity = 2; @@ -265,23 +265,23 @@ struct RocFileBatchContext : public RocFileUnopened { } }; -TEST_F(RocFileBatchContext, SubmitSingleGoodOp) +TEST_F(HipFileBatchContext, SubmitSingleGoodOp) { _context->submit_operations(&io_params, 1); } -TEST_F(RocFileBatchContext, SubmitZeroOperations) +TEST_F(HipFileBatchContext, SubmitZeroOperations) { _context->submit_operations(nullptr, 0); } -TEST_F(RocFileBatchContext, SubmitOverCapacity) +TEST_F(HipFileBatchContext, SubmitOverCapacity) { // We should fail before we ever try touching the nullptr. ASSERT_THROW(_context->submit_operations(nullptr, _context_capacity + 1), std::invalid_argument); } -TEST_F(RocFileBatchContext, SubmitOverCapacityOverMultipleSubmissions) +TEST_F(HipFileBatchContext, SubmitOverCapacityOverMultipleSubmissions) { // Submit one at a time up to the capacity. // In the future we might care that we are submitting the same operation. @@ -293,55 +293,55 @@ TEST_F(RocFileBatchContext, SubmitOverCapacityOverMultipleSubmissions) ASSERT_THROW(_context->submit_operations(nullptr, 1), std::invalid_argument); } -TEST_F(RocFileBatchContext, SubmitSingleBadBuffer) +TEST_F(HipFileBatchContext, SubmitSingleBadBuffer) { EXPECT_CALL(*mock_driver_state, getFileAndBuffer).WillOnce(Throw(BufferNotRegistered())); ASSERT_THROW(_context->submit_operations(&io_params, 1), BufferNotRegistered); } -TEST_F(RocFileBatchContext, SubmitSingleBadFileHandle) +TEST_F(HipFileBatchContext, SubmitSingleBadFileHandle) { EXPECT_CALL(*mock_driver_state, getFileAndBuffer).WillOnce(Throw(FileNotRegistered())); ASSERT_THROW(_context->submit_operations(&io_params, 1), FileNotRegistered); } // BatchOperation is not mocked. -TEST_F(RocFileBatchContext, SubmitSingleBadParamBufferOffsetNegative) +TEST_F(HipFileBatchContext, SubmitSingleBadParamBufferOffsetNegative) { rocFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.devPtr_offset = -1; ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } -TEST_F(RocFileBatchContext, SubmitSingleBadParamBufferOffsetTooLarge) +TEST_F(HipFileBatchContext, SubmitSingleBadParamBufferOffsetTooLarge) { rocFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.devPtr_offset = default_mock_buffer_length; ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } -TEST_F(RocFileBatchContext, SubmitSingleBadParamIOSizeTooLarge) +TEST_F(HipFileBatchContext, SubmitSingleBadParamIOSizeTooLarge) { rocFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.size = static_cast(default_mock_buffer_length + 1); ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } -TEST_F(RocFileBatchContext, SubmitSingleBadParamFileOffsetNegative) +TEST_F(HipFileBatchContext, SubmitSingleBadParamFileOffsetNegative) { rocFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.file_offset = -1; ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } -TEST_F(RocFileBatchContext, SubmitSingleBadParamOpcodeInvalid) +TEST_F(HipFileBatchContext, SubmitSingleBadParamOpcodeInvalid) { rocFileIOParams_t bad_io_params = io_params; bad_io_params.opcode = invalidEnum(-1); ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } -TEST_F(RocFileBatchContext, SubmitSingleBadParamModeInvalid) +TEST_F(HipFileBatchContext, SubmitSingleBadParamModeInvalid) { rocFileIOParams_t bad_io_params = io_params; bad_io_params.mode = invalidEnum(-1); diff --git a/hipfile/test/amd_detail/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp index cbaa60b5..95daa56b 100644 --- a/hipfile/test/amd_detail/buffer.cpp +++ b/hipfile/test/amd_detail/buffer.cpp @@ -39,14 +39,14 @@ expect_buffer_registration(MHip &mhip, hipMemoryType memory_type) EXPECT_CALL(mhip, hipMemGetAddressRange).WillOnce(testing::Return(range)); } -struct RocFileBuffer : public RocFileOpened { - RocFileBuffer() : nonnull_ptr(reinterpret_cast(0x1)) +struct HipFileBuffer : public HipFileOpened { + HipFileBuffer() : nonnull_ptr(reinterpret_cast(0x1)) { } void *nonnull_ptr; }; -TEST_F(RocFileBuffer, register_internal_supported_hip_memory) +TEST_F(HipFileBuffer, register_internal_supported_hip_memory) { for (const auto memoryType : SupportedHipMemoryTypes) { StrictMock mhip; @@ -55,7 +55,7 @@ TEST_F(RocFileBuffer, register_internal_supported_hip_memory) } } -TEST_F(RocFileBuffer, register_supported_hip_memory) +TEST_F(HipFileBuffer, register_supported_hip_memory) { for (const auto memoryType : SupportedHipMemoryTypes) { StrictMock mhip; @@ -64,7 +64,7 @@ TEST_F(RocFileBuffer, register_supported_hip_memory) } } -TEST_F(RocFileBuffer, register_internal_unsupported_hip_memory) +TEST_F(HipFileBuffer, register_internal_unsupported_hip_memory) { for (const auto memoryType : UnsupportedHipMemoryTypes) { StrictMock mhip; @@ -75,7 +75,7 @@ TEST_F(RocFileBuffer, register_internal_unsupported_hip_memory) } } -TEST_F(RocFileBuffer, register_unsupported_hip_memory) +TEST_F(HipFileBuffer, register_unsupported_hip_memory) { for (const auto memoryType : UnsupportedHipMemoryTypes) { StrictMock mhip; @@ -86,14 +86,14 @@ TEST_F(RocFileBuffer, register_unsupported_hip_memory) } } -TEST_F(RocFileBuffer, register_internal_hip_pointer_get_attributes_error) +TEST_F(HipFileBuffer, register_internal_hip_pointer_get_attributes_error) { StrictMock mhip; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorUnknown))); ASSERT_THROW(Context::get()->registerBuffer(nonnull_ptr, 0, 0), Hip::RuntimeError); } -TEST_F(RocFileBuffer, register_hip_pointer_get_attributes_error) +TEST_F(HipFileBuffer, register_hip_pointer_get_attributes_error) { StrictMock mhip; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorUnknown))); @@ -105,7 +105,7 @@ TEST_F(RocFileBuffer, register_hip_pointer_get_attributes_error) ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileInvalidValue)); } -TEST_F(RocFileBuffer, register_internal_already_registered) +TEST_F(HipFileBuffer, register_internal_already_registered) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -113,7 +113,7 @@ TEST_F(RocFileBuffer, register_internal_already_registered) ASSERT_THROW(Context::get()->registerBuffer(nonnull_ptr, 0, 0), BufferAlreadyRegistered); } -TEST_F(RocFileBuffer, register_already_registered) +TEST_F(HipFileBuffer, register_already_registered) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -121,12 +121,12 @@ TEST_F(RocFileBuffer, register_already_registered) ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileMemoryAlreadyRegistered)); } -TEST_F(RocFileBuffer, registerNullPointerReturnsError) +TEST_F(HipFileBuffer, registerNullPointerReturnsError) { ASSERT_EQ(rocFileBufRegister(nullptr, 0x10000, 0), HipFileOpError(hipFileInvalidValue)); } -TEST_F(RocFileBuffer, registerOversizeRangeReturnsError) +TEST_F(HipFileBuffer, registerOversizeRangeReturnsError) { StrictMock mhip; HipMemAddressRange range{nonnull_ptr, 100}; @@ -138,7 +138,7 @@ TEST_F(RocFileBuffer, registerOversizeRangeReturnsError) HipFileOpError(hipFileHipPointerRangeError)); } -TEST_F(RocFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) +TEST_F(HipFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) { StrictMock mhip; EXPECT_CALL(mhip, hipMemGetAddressRange).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorNotFound))); @@ -148,7 +148,7 @@ TEST_F(RocFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 100, 0), HipFileOpError(hipFileInvalidValue)); } -TEST_F(RocFileBuffer, registerOverflowingRangeReturnsError) +TEST_F(HipFileBuffer, registerOverflowingRangeReturnsError) { StrictMock mhip; HipMemAddressRange range{nonnull_ptr, 100}; @@ -160,17 +160,17 @@ TEST_F(RocFileBuffer, registerOverflowingRangeReturnsError) HipFileOpError(hipFileHipPointerRangeError)); } -TEST_F(RocFileBuffer, deregister_internal_not_registered) +TEST_F(HipFileBuffer, deregister_internal_not_registered) { ASSERT_THROW(Context::get()->deregisterBuffer(nonnull_ptr), BufferNotRegistered); } -TEST_F(RocFileBuffer, deregister_not_registered) +TEST_F(HipFileBuffer, deregister_not_registered) { ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); } -TEST_F(RocFileBuffer, deregister_internal) +TEST_F(HipFileBuffer, deregister_internal) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -178,7 +178,7 @@ TEST_F(RocFileBuffer, deregister_internal) Context::get()->deregisterBuffer(nonnull_ptr); } -TEST_F(RocFileBuffer, deregister) +TEST_F(HipFileBuffer, deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -186,7 +186,7 @@ TEST_F(RocFileBuffer, deregister) ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); } -TEST_F(RocFileBuffer, deregister_internal_duplicate_deregister) +TEST_F(HipFileBuffer, deregister_internal_duplicate_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -195,7 +195,7 @@ TEST_F(RocFileBuffer, deregister_internal_duplicate_deregister) ASSERT_THROW(Context::get()->deregisterBuffer(nonnull_ptr), BufferNotRegistered); } -TEST_F(RocFileBuffer, deregister_duplicate_deregister) +TEST_F(HipFileBuffer, deregister_duplicate_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -204,7 +204,7 @@ TEST_F(RocFileBuffer, deregister_duplicate_deregister) ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); } -TEST_F(RocFileBuffer, deregister_internal_get_prevents_deregister) +TEST_F(HipFileBuffer, deregister_internal_get_prevents_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -216,7 +216,7 @@ TEST_F(RocFileBuffer, deregister_internal_get_prevents_deregister) Context::get()->deregisterBuffer(nonnull_ptr); } -TEST_F(RocFileBuffer, deregister_get_prevents_deregister) +TEST_F(HipFileBuffer, deregister_get_prevents_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -228,12 +228,12 @@ TEST_F(RocFileBuffer, deregister_get_prevents_deregister) ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); } -TEST_F(RocFileBuffer, get_not_registered) +TEST_F(HipFileBuffer, get_not_registered) { ASSERT_THROW(Context::get()->getBuffer(nonnull_ptr), BufferNotRegistered); } -TEST_F(RocFileBuffer, get_internal_after_register) +TEST_F(HipFileBuffer, get_internal_after_register) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -241,7 +241,7 @@ TEST_F(RocFileBuffer, get_internal_after_register) auto buffer = Context::get()->getBuffer(nonnull_ptr); } -TEST_F(RocFileBuffer, get_after_register) +TEST_F(HipFileBuffer, get_after_register) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -249,7 +249,7 @@ TEST_F(RocFileBuffer, get_after_register) auto buffer = Context::get()->getBuffer(nonnull_ptr); } -TEST_F(RocFileBuffer, get_internal_after_deregister) +TEST_F(HipFileBuffer, get_internal_after_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -258,7 +258,7 @@ TEST_F(RocFileBuffer, get_internal_after_deregister) ASSERT_THROW(Context::get()->getBuffer(nonnull_ptr), BufferNotRegistered); } -TEST_F(RocFileBuffer, get_after_deregister) +TEST_F(HipFileBuffer, get_after_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -267,7 +267,7 @@ TEST_F(RocFileBuffer, get_after_deregister) ASSERT_THROW(Context::get()->getBuffer(nonnull_ptr), BufferNotRegistered); } -TEST_F(RocFileBuffer, get_buffer_makes_temporary_buffer) +TEST_F(HipFileBuffer, get_buffer_makes_temporary_buffer) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -275,7 +275,7 @@ TEST_F(RocFileBuffer, get_buffer_makes_temporary_buffer) ASSERT_EQ(buffer.use_count(), 1); } -TEST_F(RocFileBuffer, get_buffer_returns_registered_buffer) +TEST_F(HipFileBuffer, get_buffer_returns_registered_buffer) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); @@ -284,7 +284,7 @@ TEST_F(RocFileBuffer, get_buffer_returns_registered_buffer) Context::get()->getBuffer(nonnull_ptr)); } -TEST_F(RocFileBuffer, get_buffer_throws_if_length_larger_than_registered_length) +TEST_F(HipFileBuffer, get_buffer_throws_if_length_larger_than_registered_length) { StrictMock mhip; size_t buffer_length = 0; @@ -294,7 +294,7 @@ TEST_F(RocFileBuffer, get_buffer_throws_if_length_larger_than_registered_length) std::invalid_argument); } -TEST_F(RocFileBuffer, get_buffer_throws_on_getPointerAttributes_error) +TEST_F(HipFileBuffer, get_buffer_throws_on_getPointerAttributes_error) { StrictMock mhip; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorUnknown))); diff --git a/hipfile/test/amd_detail/context.cpp b/hipfile/test/amd_detail/context.cpp index 90e1200b..af44655a 100644 --- a/hipfile/test/amd_detail/context.cpp +++ b/hipfile/test/amd_detail/context.cpp @@ -16,13 +16,13 @@ using namespace hipFile; // warnings HIPFILE_WARN_NO_GLOBAL_CTOR_OFF -TEST(RocFileContext, get_default_context) +TEST(HipFileContext, get_default_context) { Hip *hip = Context::get(); ASSERT_NE(hip, nullptr); } -TEST(RocFileContext, override_works_and_is_reverted_on_destruction) +TEST(HipFileContext, override_works_and_is_reverted_on_destruction) { Hip *orig_context = Context::get(); { @@ -35,7 +35,7 @@ TEST(RocFileContext, override_works_and_is_reverted_on_destruction) ASSERT_EQ(orig_context, hip_context); } -TEST(RocFileContext, default_is_set_when_override_called_before_get) +TEST(HipFileContext, default_is_set_when_override_called_before_get) { Hip *override_context; { @@ -48,7 +48,7 @@ TEST(RocFileContext, default_is_set_when_override_called_before_get) ASSERT_NE(context, nullptr); } -TEST(RocFileContext, context_throws_on_second_override) +TEST(HipFileContext, context_throws_on_second_override) { Hip hip; ContextOverride ho(&hip); diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index 00f778dd..fe664d53 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -25,11 +25,11 @@ using namespace testing; // warnings HIPFILE_WARN_NO_GLOBAL_CTOR_OFF -struct RocFileDriverAdmin : public RocFileUnopened {}; +struct HipFileDriverAdmin : public HipFileUnopened {}; // Ensure that rocFileOpen() and rocFileClose() increment and // decrement the reference count -TEST_F(RocFileDriverAdmin, OpenClose) +TEST_F(HipFileDriverAdmin, OpenClose) { const int64_t N = 10; @@ -50,7 +50,7 @@ TEST_F(RocFileDriverAdmin, OpenClose) // Ensure rocFileHandleRegister() initializes the driver // and DOES bump the reference count -TEST_F(RocFileDriverAdmin, HandleRegisterInitsDriver) +TEST_F(HipFileDriverAdmin, HandleRegisterInitsDriver) { StrictMock msys{}; StrictMock mlibmounthelper{}; @@ -71,7 +71,7 @@ TEST_F(RocFileDriverAdmin, HandleRegisterInitsDriver) // Ensure rocFileHandleRegister() handles a file descriptor // of zero (technically a legal POSIX value) and DOES bump // the reference count -TEST_F(RocFileDriverAdmin, HandleRegisterGoodFD) +TEST_F(HipFileDriverAdmin, HandleRegisterGoodFD) { StrictMock msys{}; StrictMock mlibmounthelper{}; @@ -94,7 +94,7 @@ TEST_F(RocFileDriverAdmin, HandleRegisterGoodFD) // Ensure rocFileHandleRegister() fails when passed a negative file // descriptor and does NOT bump the reference count -TEST_F(RocFileDriverAdmin, HandleRegisterBadFD) +TEST_F(HipFileDriverAdmin, HandleRegisterBadFD) { StrictMock msys{}; StrictMock mlibmounthelper{}; @@ -114,7 +114,7 @@ TEST_F(RocFileDriverAdmin, HandleRegisterBadFD) // Ensure rocFileHandleDeregister() fails when passed a NULL or // unregistered pointer and does NOT bump the driver reference count -TEST_F(RocFileDriverAdmin, HandleDeregisterDoesNotInitDriver) +TEST_F(HipFileDriverAdmin, HandleDeregisterDoesNotInitDriver) { StrictMock msys{}; StrictMock mlibmounthelper{}; @@ -135,7 +135,7 @@ TEST_F(RocFileDriverAdmin, HandleDeregisterDoesNotInitDriver) // Ensure that closing the driver will also close any open handles. This // is checked by trying to re-register a handle, which should fail if // the handle were still open. -TEST_F(RocFileDriverAdmin, CloseDeregistersFile) +TEST_F(HipFileDriverAdmin, CloseDeregistersFile) { StrictMock msys{}; StrictMock mlibmounthelper{}; @@ -160,7 +160,7 @@ TEST_F(RocFileDriverAdmin, CloseDeregistersFile) // Ensure that registering a buffer increments the driver reference // count -TEST_F(RocFileDriverAdmin, BufRegisterInitsDriver) +TEST_F(HipFileDriverAdmin, BufRegisterInitsDriver) { StrictMock mhip; @@ -173,7 +173,7 @@ TEST_F(RocFileDriverAdmin, BufRegisterInitsDriver) // Ensure that buffer deregistration does not increment the driver // reference count -TEST_F(RocFileDriverAdmin, BufDeregisterDoesNotInitDriver) +TEST_F(HipFileDriverAdmin, BufDeregisterDoesNotInitDriver) { ASSERT_EQ(hipFileUseCount(), 0); ASSERT_EQ(rocFileBufDeregister(nullptr), HipFileOpError(hipFileDriverNotInitialized)); @@ -183,7 +183,7 @@ TEST_F(RocFileDriverAdmin, BufDeregisterDoesNotInitDriver) // Ensure that closing the driver also closes open buffers. This is // checked by attempting to re-register a buffer, which should fail // if it's already registered. -TEST_F(RocFileDriverAdmin, CloseDeregistersBuffer) +TEST_F(HipFileDriverAdmin, CloseDeregistersBuffer) { StrictMock mhip; @@ -203,7 +203,7 @@ TEST_F(RocFileDriverAdmin, CloseDeregistersBuffer) // Ensure rocFileReadAsync(): // * Returns hipFileDriverNotInitialized when called w/o a driver init // * Does NOT initialize the driver and returns a reference count of 0 -TEST_F(RocFileDriverAdmin, ReadAsyncDoesNotInitDriver) +TEST_F(HipFileDriverAdmin, ReadAsyncDoesNotInitDriver) { ASSERT_EQ(rocFileReadAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), HipFileOpError(hipFileDriverNotInitialized)); @@ -213,7 +213,7 @@ TEST_F(RocFileDriverAdmin, ReadAsyncDoesNotInitDriver) // Ensure rocFileWriteAsync(): // * Returns hipFileDriverNotInitialized when called w/o a driver init // * Does NOT initialize the driver and returns a reference count of 0 -TEST_F(RocFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) +TEST_F(HipFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) { ASSERT_EQ(rocFileWriteAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), HipFileOpError(hipFileDriverNotInitialized)); @@ -224,7 +224,7 @@ TEST_F(RocFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) // * Returns hipFileDriverNotInitialized when called w/o a driver init // (the weird negative sign is a quirk of returning a ssize_t) // * Does NOT initialize the driver and returns a reference count of 0 -TEST_F(RocFileDriverAdmin, ReadDoesNotInitDriver) +TEST_F(HipFileDriverAdmin, ReadDoesNotInitDriver) { ASSERT_EQ(rocFileRead(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); ASSERT_EQ(hipFileUseCount(), 0); @@ -234,7 +234,7 @@ TEST_F(RocFileDriverAdmin, ReadDoesNotInitDriver) // * Returns hipFileDriverNotInitialized when called w/o a driver init // (the weird negative sign is a quirk of returning a ssize_t) // * Does NOT initialize the driver and returns a reference count of 0 -TEST_F(RocFileDriverAdmin, WriteDoesNotInitDriver) +TEST_F(HipFileDriverAdmin, WriteDoesNotInitDriver) { ASSERT_EQ(rocFileWrite(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); ASSERT_EQ(hipFileUseCount(), 0); diff --git a/hipfile/test/amd_detail/fallback.cpp b/hipfile/test/amd_detail/fallback.cpp index 632bfa84..e86da556 100644 --- a/hipfile/test/amd_detail/fallback.cpp +++ b/hipfile/test/amd_detail/fallback.cpp @@ -110,7 +110,7 @@ contains_expected_data(std::vector &buffer, hoff_t buffer_offset, std:: return true; } -struct FallbackIo : public RocFileOpened { +struct FallbackIo : public HipFileOpened { shared_ptr buffer; std::vector buffer_data; @@ -150,7 +150,7 @@ struct FallbackIo : public RocFileOpened { } }; -TEST(RocFileFallbackBackend, FallbackBackendIsBarelyWillingToHandleDeviceMemory) +TEST(HipFileFallbackBackend, FallbackBackendIsBarelyWillingToHandleDeviceMemory) { auto mfile{std::make_shared>()}; auto mbuffer{std::make_shared>()}; @@ -163,7 +163,7 @@ TEST(RocFileFallbackBackend, FallbackBackendIsBarelyWillingToHandleDeviceMemory) ASSERT_EQ(Fallback().score(mfile, mbuffer, io_size, file_offset, buffer_offset), 0); } -TEST(RocFileFallbackBackend, FallbackBackendRejectsUnsupportedHipMemoryTypes) +TEST(HipFileFallbackBackend, FallbackBackendRejectsUnsupportedHipMemoryTypes) { auto mfile{std::make_shared>()}; size_t io_size{2048}; diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index 6b4b31fe..9aa6af5b 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -48,12 +48,12 @@ expect_file_registration(MSys &msys, MLibMountHelper &mlibmounthelper, struct st EXPECT_CALL(mlibmounthelper, getMountInfo).WillOnce(Return(mountinfo)); } -struct RocFileHandle : public RocFileOpened { +struct HipFileHandle : public HipFileOpened { StrictMock msys; StrictMock mlibmounthelper; }; -TEST_F(RocFileHandle, register_handle_internal_linux_fd) +TEST_F(HipFileHandle, register_handle_internal_linux_fd) { int fd{0xBADF00D}; @@ -61,7 +61,7 @@ TEST_F(RocFileHandle, register_handle_internal_linux_fd) ASSERT_NE(Context::get()->registerFile(fd), nullptr); } -TEST_F(RocFileHandle, file_initialization) +TEST_F(HipFileHandle, file_initialization) { int fd{0x12345678}; int status_flags{0x789ABCDE}; @@ -86,7 +86,7 @@ TEST_F(RocFileHandle, file_initialization) file->getMountInfo().value().options.ext4.journaling_mode); } -TEST_F(RocFileHandle, register_handle_internal_linux_fd_already_registered) +TEST_F(HipFileHandle, register_handle_internal_linux_fd_already_registered) { int fd{0xBADF00D}; expect_file_registration(msys, mlibmounthelper); @@ -95,7 +95,7 @@ TEST_F(RocFileHandle, register_handle_internal_linux_fd_already_registered) ASSERT_THROW(Context::get()->registerFile(fd), FileAlreadyRegistered); } -TEST_F(RocFileHandle, register_handle_linux_fd) +TEST_F(HipFileHandle, register_handle_linux_fd) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -109,7 +109,7 @@ TEST_F(RocFileHandle, register_handle_linux_fd) } // If statx() fails during file registration return rocfileInternalError -TEST_F(RocFileHandle, RocfileHandleRegisterStatxError) +TEST_F(HipFileHandle, RocfileHandleRegisterStatxError) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -122,7 +122,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterStatxError) } // If the fcntl() fails during file registration return rocfileInternalError -TEST_F(RocFileHandle, RocfileHandleRegisterFcntlError) +TEST_F(HipFileHandle, RocfileHandleRegisterFcntlError) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -136,7 +136,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterFcntlError) } // If getting mount information fails during file registration return rocfileInternalError -TEST_F(RocFileHandle, RocfileHandleRegisterLibMountError) +TEST_F(HipFileHandle, RocfileHandleRegisterLibMountError) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -150,7 +150,7 @@ TEST_F(RocFileHandle, RocfileHandleRegisterLibMountError) ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); } -TEST_F(RocFileHandle, register_handle_linux_fd_already_registered) +TEST_F(HipFileHandle, register_handle_linux_fd_already_registered) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -165,7 +165,7 @@ TEST_F(RocFileHandle, register_handle_linux_fd_already_registered) ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileHandleAlreadyRegistered)); } -TEST_F(RocFileHandle, register_handle_windows_handle_not_supported) +TEST_F(HipFileHandle, register_handle_windows_handle_not_supported) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -176,7 +176,7 @@ TEST_F(RocFileHandle, register_handle_windows_handle_not_supported) ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); } -TEST_F(RocFileHandle, register_handle_userspace_fs_not_supported) +TEST_F(HipFileHandle, register_handle_userspace_fs_not_supported) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -187,19 +187,19 @@ TEST_F(RocFileHandle, register_handle_userspace_fs_not_supported) ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); } -TEST_F(RocFileHandle, deregister_handle_internal_throws_if_not_registered) +TEST_F(HipFileHandle, deregister_handle_internal_throws_if_not_registered) { ASSERT_THROW(Context::get()->deregisterFile(reinterpret_cast(0xdeadbeef)), FileNotRegistered); } -TEST_F(RocFileHandle, deregister_handle_returns_error_if_not_registered) +TEST_F(HipFileHandle, deregister_handle_returns_error_if_not_registered) { ASSERT_EQ(rocFileHandleDeregister(reinterpret_cast(0xdeadbeef)), HipFileOpError(hipFileHandleNotRegistered)); } -TEST_F(RocFileHandle, deregister_handle_internal) +TEST_F(HipFileHandle, deregister_handle_internal) { expect_file_registration(msys, mlibmounthelper); auto fh = Context::get()->registerFile(0xBADF00D); @@ -207,7 +207,7 @@ TEST_F(RocFileHandle, deregister_handle_internal) ASSERT_THROW(Context::get()->deregisterFile(fh), FileNotRegistered); } -TEST_F(RocFileHandle, deregister_handle) +TEST_F(HipFileHandle, deregister_handle) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; @@ -221,7 +221,7 @@ TEST_F(RocFileHandle, deregister_handle) ASSERT_EQ(rocFileHandleDeregister(fh), HipFileOpError(hipFileHandleNotRegistered)); } -TEST_F(RocFileHandle, deregister_handle_internal_fails_when_operations_are_oustanding) +TEST_F(HipFileHandle, deregister_handle_internal_fails_when_operations_are_oustanding) { expect_file_registration(msys, mlibmounthelper); auto fh = Context::get()->registerFile(0xBADF00D); @@ -232,7 +232,7 @@ TEST_F(RocFileHandle, deregister_handle_internal_fails_when_operations_are_ousta Context::get()->deregisterFile(fh); } -TEST_F(RocFileHandle, deregister_handle_fails_when_operations_are_oustanding) +TEST_F(HipFileHandle, deregister_handle_fails_when_operations_are_oustanding) { rocFileHandle_t fh{}; rocFileDescr_t rfd{}; diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/rocfile-test.h index 01cbf103..2d45f513 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/rocfile-test.h @@ -75,15 +75,15 @@ inline constexpr hipFileError_t HIPFILE_INVALID_VALUE{hipFileInvalidValue, hipSu // *********************************************************************** // Base class for tests that open the driver -struct RocFileOpened : public ::testing::Test { +struct HipFileOpened : public ::testing::Test { - RocFileOpened() + HipFileOpened() { assert(hipFileUseCount() == 0); assert(hipFileDriverOpen() == HIPFILE_SUCCESS); } - virtual ~RocFileOpened() override + virtual ~HipFileOpened() override { while (hipFileUseCount()) { assert(hipFileDriverClose() == HIPFILE_SUCCESS); @@ -93,14 +93,14 @@ struct RocFileOpened : public ::testing::Test { }; // Base class for tests that do NOT open the driver -struct RocFileUnopened : public ::testing::Test { +struct HipFileUnopened : public ::testing::Test { - RocFileUnopened() + HipFileUnopened() { assert(hipFileUseCount() == 0); } - virtual ~RocFileUnopened() override + virtual ~HipFileUnopened() override { while (hipFileUseCount()) { assert(hipFileDriverClose() == HIPFILE_SUCCESS); diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index b158964a..cae2aec3 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -52,14 +52,14 @@ using namespace testing; // warnings HIPFILE_WARN_NO_GLOBAL_CTOR_OFF -struct RocFileUnit : public RocFileUnopened { +struct HipFileUnit : public HipFileUnopened { StrictMock mock_state; void SetUp() override { } }; -TEST_F(RocFileUnit, TestRocFileBatchIOSetupSuccess) +TEST_F(HipFileUnit, TestHipFileBatchIOSetupSuccess) { rocFileBatchHandle_t b_handle = nullptr; rocFileBatchHandle_t expected_b_handle = reinterpret_cast(0x12345678); @@ -71,7 +71,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSetupSuccess) EXPECT_EQ(b_handle, expected_b_handle); } -TEST_F(RocFileUnit, TestRocFileBatchIOSetupBadArgument) +TEST_F(HipFileUnit, TestHipFileBatchIOSetupBadArgument) { rocFileBatchHandle_t b_handle = nullptr; @@ -82,13 +82,13 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSetupBadArgument) EXPECT_EQ(b_handle, nullptr); } -TEST_F(RocFileUnit, TestRocFileBatchIOSetupNullptrHandle) +TEST_F(HipFileUnit, TestHipFileBatchIOSetupNullptrHandle) { auto result = rocFileBatchIOSetUp(nullptr, 1); ASSERT_EQ(result, HIPFILE_INVALID_VALUE); } -TEST_F(RocFileUnit, TestRocFileBatchIOSubmitSuccess) +TEST_F(HipFileUnit, TestHipFileBatchIOSubmitSuccess) { rocFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); rocFileIOParams_t io_param; @@ -101,7 +101,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSubmitSuccess) ASSERT_EQ(result, HIPFILE_SUCCESS); } -TEST_F(RocFileUnit, TestRocFileBatchIOSubmitBadHandle) +TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadHandle) { rocFileBatchHandle_t b_handle = nullptr; rocFileIOParams_t io_param; @@ -115,7 +115,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSubmitBadHandle) ASSERT_EQ(result, expected_result); } -TEST_F(RocFileUnit, TestRocFileBatchIOSubmitBadArgument) +TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadArgument) { rocFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); rocFileIOParams_t io_param; @@ -129,7 +129,7 @@ TEST_F(RocFileUnit, TestRocFileBatchIOSubmitBadArgument) } /// @brief Test rocFileIO function -struct RocFileIoParam : public TestWithParam { +struct HipFileIoParam : public TestWithParam { rocFileHandle_t file_handle{}; void *bufptr{reinterpret_cast(0xDEC0DE)}; size_t buflen{4096}; @@ -137,7 +137,7 @@ struct RocFileIoParam : public TestWithParam { shared_ptr> mbackend{make_shared>()}; vector> mbackends{mbackend}; - RocFileIoParam() + HipFileIoParam() { { StrictMock msys; @@ -154,14 +154,14 @@ struct RocFileIoParam : public TestWithParam { } }; -TEST_P(RocFileIoParam, RocFileIoHandlesHipPointerGetAttributesError) +TEST_P(HipFileIoParam, HipFileIoHandlesHipPointerGetAttributesError) { StrictMock mhip; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorUnknown))); ASSERT_EQ(hipFileIo(GetParam(), file_handle, unreg_bufptr, 0, 0, 0, mbackends), -hipErrorUnknown); } -TEST_P(RocFileIoParam, RocFileIoHandlesUnsupportedHipMemoryType) +TEST_P(HipFileIoParam, HipFileIoHandlesUnsupportedHipMemoryType) { for (const auto memoryType : UnsupportedHipMemoryTypes) { StrictMock mhip; @@ -173,20 +173,20 @@ TEST_P(RocFileIoParam, RocFileIoHandlesUnsupportedHipMemoryType) } } -TEST_P(RocFileIoParam, RocFileIoHandlesInvalidRegisteredBufferLength) +TEST_P(HipFileIoParam, HipFileIoHandlesInvalidRegisteredBufferLength) { StrictMock mhip; ASSERT_EQ(hipFileIo(GetParam(), file_handle, bufptr, buflen + 1, 0, 0, mbackends), -static_cast(hipFileInvalidValue)); } -TEST_P(RocFileIoParam, RocFileIoHandlesInvalidFileHandle) +TEST_P(HipFileIoParam, HipFileIoHandlesInvalidFileHandle) { auto invalid_handle{reinterpret_cast(0xdeadbeef)}; ASSERT_EQ(hipFileIo(GetParam(), invalid_handle, bufptr, 0, 0, 0, mbackends), -hipFileHandleNotRegistered); } -TEST_P(RocFileIoParam, RocFileIoHandlesSysRuntimeError) +TEST_P(HipFileIoParam, HipFileIoHandlesSysRuntimeError) { EXPECT_CALL(*mbackend, score).WillOnce(Return(1)); EXPECT_CALL(*mbackend, io).WillOnce(Throw(Sys::RuntimeError(EBADFD))); @@ -195,23 +195,23 @@ TEST_P(RocFileIoParam, RocFileIoHandlesSysRuntimeError) ASSERT_EQ(errno, EBADFD); } -TEST_P(RocFileIoParam, RocFileIoHandlesHipRuntimeError) +TEST_P(HipFileIoParam, HipFileIoHandlesHipRuntimeError) { EXPECT_CALL(*mbackend, score).WillOnce(Return(1)); EXPECT_CALL(*mbackend, io).WillOnce(Throw(Hip::RuntimeError(hipErrorUnknown))); ASSERT_EQ(hipFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -hipErrorUnknown); } -TEST_P(RocFileIoParam, RocFileIoHandlesInvalidArgumentError) +TEST_P(HipFileIoParam, HipFileIoHandlesInvalidArgumentError) { EXPECT_CALL(*mbackend, score).WillOnce(Return(1)); EXPECT_CALL(*mbackend, io).WillOnce(Throw(std::invalid_argument(""))); ASSERT_EQ(hipFileIo(GetParam(), file_handle, bufptr, buflen, 0, 0, mbackends), -hipFileInvalidValue); } -INSTANTIATE_TEST_SUITE_P(RocFileIo, RocFileIoParam, Values(IoType::Read, IoType::Write)); +INSTANTIATE_TEST_SUITE_P(HipFileIo, HipFileIoParam, Values(IoType::Read, IoType::Write)); -struct RocFileIoBackendSelectionParam : public ::testing::TestWithParam { +struct HipFileIoBackendSelectionParam : public ::testing::TestWithParam { IoType io_type; rocFileHandle_t handle; @@ -227,7 +227,7 @@ struct RocFileIoBackendSelectionParam : public ::testing::TestWithParam std::shared_ptr> mbe3; StrictMock mds; - RocFileIoBackendSelectionParam() + HipFileIoBackendSelectionParam() : io_type{GetParam()}, handle{reinterpret_cast(0xBADF00D)}, buffer{reinterpret_cast(0xDEADBEEF)}, io_size{1024}, file_offset{32}, buffer_offset{64}, flags{0}, mfile{std::make_shared>()}, @@ -237,7 +237,7 @@ struct RocFileIoBackendSelectionParam : public ::testing::TestWithParam } }; -TEST_P(RocFileIoBackendSelectionParam, RocFileIoThrowsIfThereAreNoBackends) +TEST_P(HipFileIoBackendSelectionParam, HipFileIoThrowsIfThereAreNoBackends) { auto backends{std::vector>()}; @@ -259,7 +259,7 @@ TEST_P(RocFileIoBackendSelectionParam, RocFileIoThrowsIfThereAreNoBackends) } } -TEST_P(RocFileIoBackendSelectionParam, RocFileIoThrowsIfAllBackendsRejectTheIO) +TEST_P(HipFileIoBackendSelectionParam, HipFileIoThrowsIfAllBackendsRejectTheIO) { std::vector> backends{mbe1, mbe2, mbe3}; @@ -287,7 +287,7 @@ TEST_P(RocFileIoBackendSelectionParam, RocFileIoThrowsIfAllBackendsRejectTheIO) } } -TEST_P(RocFileIoBackendSelectionParam, RocFileIoIssuesIoToHighestScoringBackend) +TEST_P(HipFileIoBackendSelectionParam, HipFileIoIssuesIoToHighestScoringBackend) { std::vector> backends{mbe1, mbe2, mbe3}; @@ -319,7 +319,7 @@ TEST_P(RocFileIoBackendSelectionParam, RocFileIoIssuesIoToHighestScoringBackend) } } -INSTANTIATE_TEST_SUITE_P(RocFileIoBackendSelection, RocFileIoBackendSelectionParam, +INSTANTIATE_TEST_SUITE_P(HipFileIoBackendSelection, HipFileIoBackendSelectionParam, ::testing::Values(IoType::Read, IoType::Write)); HIPFILE_WARN_NO_GLOBAL_CTOR_ON diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index 2cd03f38..76d41e7e 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -35,8 +35,8 @@ rocFileFlagsPowerSet() ::testing::Values(0, HIPFILE_STREAM_PAGE_ALIGNED_INPUTS)); } -struct RocFileStream : public ::testing::Test { - RocFileStream() +struct HipFileStream : public ::testing::Test { + HipFileStream() { nonnull_stream = reinterpret_cast(1); } @@ -46,11 +46,11 @@ struct RocFileStream : public ::testing::Test { StreamMap stream_map; }; -struct RocFileStreamValidParams - : public RocFileStream, +struct HipFileStreamValidParams + : public HipFileStream, public ::testing::WithParamInterface> { protected: - RocFileStreamValidParams() : RocFileStream{} + HipFileStreamValidParams() : HipFileStream{} { auto params = GetParam(); flags = std::get<0>(params) | std::get<1>(params) | std::get<2>(params) | std::get<3>(params); @@ -58,52 +58,52 @@ struct RocFileStreamValidParams unsigned flags; }; -TEST_P(RocFileStreamValidParams, register_stream_valid_flags_internal) +TEST_P(HipFileStreamValidParams, register_stream_valid_flags_internal) { stream_map.registerStream(nonnull_stream, flags); auto stream = stream_map.getStream(nonnull_stream); ASSERT_EQ(stream->getHipStream(), nonnull_stream); } -INSTANTIATE_TEST_SUITE_P(StreamSuite, RocFileStreamValidParams, rocFileFlagsPowerSet()); +INSTANTIATE_TEST_SUITE_P(StreamSuite, HipFileStreamValidParams, rocFileFlagsPowerSet()); -TEST_F(RocFileStream, get_stream_with_unregistered_stream_works) +TEST_F(HipFileStream, get_stream_with_unregistered_stream_works) { auto stream = stream_map.getStream(nonnull_stream); ASSERT_EQ(nonnull_stream, stream->getHipStream()); } -TEST_F(RocFileStream, register_with_invalid_flags_throws) +TEST_F(HipFileStream, register_with_invalid_flags_throws) { ASSERT_THROW(stream_map.registerStream(nonnull_stream, HIPFILE_STREAM_FLAGS_MASK + 1), std::invalid_argument); } -TEST_F(RocFileStream, register_twice_throws) +TEST_F(HipFileStream, register_twice_throws) { stream_map.registerStream(nonnull_stream, 0); ASSERT_THROW(stream_map.registerStream(nonnull_stream, 0), std::invalid_argument); } -TEST_F(RocFileStream, deregister_with_registered_stream_works) +TEST_F(HipFileStream, deregister_with_registered_stream_works) { stream_map.registerStream(nonnull_stream, 0); stream_map.deregisterStream(nonnull_stream); } -TEST_F(RocFileStream, deregister_twice_throws) +TEST_F(HipFileStream, deregister_twice_throws) { stream_map.registerStream(nonnull_stream, 0); stream_map.deregisterStream(nonnull_stream); ASSERT_THROW(stream_map.deregisterStream(nonnull_stream), std::invalid_argument); } -TEST_F(RocFileStream, deregister_with_unregistered_stream_throws) +TEST_F(HipFileStream, deregister_with_unregistered_stream_throws) { ASSERT_THROW(stream_map.deregisterStream(nonnull_stream), std::invalid_argument); } -TEST(RocFileStreamDestructor, destructor_with_streams_in_use_logs) +TEST(HipFileStreamDestructor, destructor_with_streams_in_use_logs) { StrictMock mhip; StrictMock msys; @@ -116,8 +116,8 @@ TEST(RocFileStreamDestructor, destructor_with_streams_in_use_logs) } } -struct RocFileStreamExternal : public RocFileOpened { - RocFileStreamExternal() +struct HipFileStreamExternal : public HipFileOpened { + HipFileStreamExternal() { nonnull_stream = reinterpret_cast(1); } @@ -126,13 +126,13 @@ struct RocFileStreamExternal : public RocFileOpened { hipStream_t nonnull_stream; }; -TEST_F(RocFileStreamExternal, register_and_deregister_with_valid_stream_works) +TEST_F(HipFileStreamExternal, register_and_deregister_with_valid_stream_works) { ASSERT_EQ(rocFileStreamRegister(nonnull_stream, 0), HIPFILE_SUCCESS); ASSERT_EQ(rocFileStreamDeregister(nonnull_stream), HIPFILE_SUCCESS); } -TEST_F(RocFileStreamExternal, deregister_exception_returns_error) +TEST_F(HipFileStreamExternal, deregister_exception_returns_error) { ASSERT_EQ(rocFileStreamDeregister(nullptr), HipFileOpError(hipFileInvalidValue)); } From 1d3c9100bfefe3b10936dc5a37b559fa5c1a8e6a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 04:59:36 -0700 Subject: [PATCH 32/48] Rename opaque rocFile(Batch)Handle_t types --- hipfile/include/rocfile.h | 36 ++++++++-------------- hipfile/src/amd_detail/batch/batch.cpp | 8 ++--- hipfile/src/amd_detail/batch/batch.h | 8 ++--- hipfile/src/amd_detail/file.cpp | 12 ++++---- hipfile/src/amd_detail/file.h | 12 ++++---- hipfile/src/amd_detail/hipfile-private.h | 2 +- hipfile/src/amd_detail/hipfile.cpp | 2 +- hipfile/src/amd_detail/rocfile.cpp | 24 +++++++-------- hipfile/src/amd_detail/state.cpp | 16 +++++----- hipfile/src/amd_detail/state.h | 18 +++++------ hipfile/test/amd_detail/batch/batch.cpp | 22 ++++++------- hipfile/test/amd_detail/batch/batch_mt.cpp | 4 +-- hipfile/test/amd_detail/driver.cpp | 10 +++--- hipfile/test/amd_detail/handle.cpp | 22 ++++++------- hipfile/test/amd_detail/mfile.h | 8 ++--- hipfile/test/amd_detail/mstate.h | 14 ++++----- hipfile/test/amd_detail/rocfile.cpp | 20 ++++++------ hipfile/test/amd_detail/state_mt.cpp | 2 +- 18 files changed, 114 insertions(+), 126 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 3f8cd649..7eca4135 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -138,12 +138,6 @@ typedef struct rocFileDescr { const rocFileFSOps_t *fs_ops; //!< Userspace RDMA filesystem operations } rocFileDescr_t; -/*! - * Opaque file handle used by the GPU IO driver/library - * @ingroup file - */ -typedef void *rocFileHandle_t; - /*! * @brief Registers an open file for GPU IO * @ingroup file @@ -158,7 +152,7 @@ typedef void *rocFileHandle_t; * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr); +hipFileError_t rocFileHandleRegister(hipFileHandle_t *fh, rocFileDescr_t *descr); /*! * @brief Deregisters a file from GPU IO @@ -169,7 +163,7 @@ hipFileError_t rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr) * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileHandleDeregister(rocFileHandle_t fh); +hipFileError_t rocFileHandleDeregister(hipFileHandle_t fh); /*! * @brief Registers a GPU memory region to be used with GPU IO @@ -216,7 +210,7 @@ hipFileError_t rocFileBufDeregister(const void *buffer_base); * @return else: Negative value of the related hipFileOpError_t */ ROCFILE_API -ssize_t rocFileRead(rocFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, +ssize_t rocFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset); /*! @@ -234,7 +228,7 @@ ssize_t rocFileRead(rocFileHandle_t fh, void *buffer_base, size_t size, hoff_t f * @return else: Negative value of the related hipFileOpError_t */ ROCFILE_API -ssize_t rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, +ssize_t rocFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset); // *********************************************************************** @@ -286,7 +280,7 @@ typedef struct rocFileIOParams { size_t size; //!< Number of bytes to read or write } batch; //!< Parameters for the read/write batch request } u; //!< Wrapping union for batch IO parameters - rocFileHandle_t fh; //!< Registered rocFile handle for the target file + hipFileHandle_t fh; //!< Registered rocFile handle for the target file rocFileOpcode_t opcode; //!< Direction data is moving for the batch request void *cookie; //!< Optionally used to track IO operations (e.g. self-reference pointer) } rocFileIOParams_t; @@ -301,12 +295,6 @@ typedef struct rocFileIOEvents { size_t ret; //!< Number of bytes transferred or POSIX error code if negative } rocFileIOEvents_t; -/*! - * @brief Opaque batch operations handle - * @ingroup batch - */ -typedef void *rocFileBatchHandle_t; - /*! * @brief Prepare the system to perform a batch IO operation * @ingroup batch @@ -317,7 +305,7 @@ typedef void *rocFileBatchHandle_t; * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileBatchIOSetUp(rocFileBatchHandle_t *batch_idp, unsigned max_nr); +hipFileError_t rocFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr); /*! * @brief Enqueue a batch of IO requests for the GPU to complete asynchronously @@ -333,7 +321,7 @@ hipFileError_t rocFileBatchIOSetUp(rocFileBatchHandle_t *batch_idp, unsigned max * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileBatchIOSubmit(rocFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, +hipFileError_t rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, unsigned flags); /*! @@ -352,7 +340,7 @@ hipFileError_t rocFileBatchIOSubmit(rocFileBatchHandle_t batch_idp, unsigned nr, * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileBatchIOGetStatus(rocFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, +hipFileError_t rocFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, rocFileIOEvents_t *iocbp, struct timespec *timeout); /*! @@ -364,7 +352,7 @@ hipFileError_t rocFileBatchIOGetStatus(rocFileBatchHandle_t batch_idp, unsigned * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileBatchIOCancel(rocFileBatchHandle_t batch_idp); +hipFileError_t rocFileBatchIOCancel(hipFileBatchHandle_t batch_idp); /*! * @brief Destroys the batch IO handle and frees the associated resources @@ -375,7 +363,7 @@ hipFileError_t rocFileBatchIOCancel(rocFileBatchHandle_t batch_idp); * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp); +hipFileError_t rocFileBatchIODestroy(hipFileBatchHandle_t batch_idp); // *********************************************************************** // ASYNC API @@ -397,7 +385,7 @@ hipFileError_t rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp); * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileReadAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +hipFileError_t rocFileReadAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream); /*! @@ -416,7 +404,7 @@ hipFileError_t rocFileReadAsync(rocFileHandle_t fh, void *buffer_base, size_t *s * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileWriteAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +hipFileError_t rocFileWriteAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream); /*! diff --git a/hipfile/src/amd_detail/batch/batch.cpp b/hipfile/src/amd_detail/batch/batch.cpp index 407023d5..2939a4db 100644 --- a/hipfile/src/amd_detail/batch/batch.cpp +++ b/hipfile/src/amd_detail/batch/batch.cpp @@ -140,11 +140,11 @@ BatchContextMap::clear() active_contexts.clear(); } -rocFileBatchHandle_t +hipFileBatchHandle_t BatchContextMap::createContext(unsigned capacity) { auto context = std::shared_ptr{new BatchContext{capacity}}; - rocFileBatchHandle_t handle = context.get(); + hipFileBatchHandle_t handle = context.get(); // Should not need to worry about duplicate keys unless the application // somehow deallocates this handle... @@ -155,7 +155,7 @@ BatchContextMap::createContext(unsigned capacity) } void -BatchContextMap::destroyContext(rocFileBatchHandle_t handle) +BatchContextMap::destroyContext(hipFileBatchHandle_t handle) { std::unique_lock ulock{batch_mutex}; @@ -171,7 +171,7 @@ BatchContextMap::destroyContext(rocFileBatchHandle_t handle) } std::shared_ptr -BatchContextMap::get(rocFileBatchHandle_t handle) +BatchContextMap::get(hipFileBatchHandle_t handle) { // NOTE: This mutex only protects the map, so we'll // also need to protect the data diff --git a/hipfile/src/amd_detail/batch/batch.h b/hipfile/src/amd_detail/batch/batch.h index a7ef74f4..4644decd 100644 --- a/hipfile/src/amd_detail/batch/batch.h +++ b/hipfile/src/amd_detail/batch/batch.h @@ -103,20 +103,20 @@ class BatchContextMap { * @param capacity Maximum number of outstanding operations that this context can manage * @return An opaque handle used to reference this new batch context */ - rocFileBatchHandle_t createContext(unsigned capacity); + hipFileBatchHandle_t createContext(unsigned capacity); /*! * @brief Destroy a batch context and release all associated resources * @param handle The handle for the batch context to destroy */ - void destroyContext(rocFileBatchHandle_t handle); + void destroyContext(hipFileBatchHandle_t handle); /*! * @brief Get a batch context * @param handle The opaque handle associated with a batch context * @return A batch context */ - std::shared_ptr get(rocFileBatchHandle_t handle); + std::shared_ptr get(hipFileBatchHandle_t handle); /*! * @brief Clear the contents @@ -125,7 +125,7 @@ class BatchContextMap { private: /// batch context lookup table - std::unordered_map> active_contexts; + std::unordered_map> active_contexts; /// Mutex to protect the active context map mutable std::shared_mutex batch_mutex; diff --git a/hipfile/src/amd_detail/file.cpp b/hipfile/src/amd_detail/file.cpp index 61b2861c..e63d940d 100644 --- a/hipfile/src/amd_detail/file.cpp +++ b/hipfile/src/amd_detail/file.cpp @@ -61,10 +61,10 @@ UnregisteredFile::getMountInfo() const noexcept return m_mountinfo; } -rocFileHandle_t +hipFileHandle_t IFile::getHandle() const { - return reinterpret_cast(const_cast(this)); + return reinterpret_cast(const_cast(this)); } File::File(const UnregisteredFile &uf) @@ -97,7 +97,7 @@ File::getMountInfo() const } shared_ptr -FileMap::getFile(rocFileHandle_t fh) +FileMap::getFile(hipFileHandle_t fh) { auto itr = from_fh.find(fh); if (from_fh.end() == itr) { @@ -107,7 +107,7 @@ FileMap::getFile(rocFileHandle_t fh) return itr->second; } -rocFileHandle_t +hipFileHandle_t FileMap::registerFile(const UnregisteredFile &uf) { if (from_fd.end() != from_fd.find(uf.getFd())) { @@ -122,7 +122,7 @@ FileMap::registerFile(const UnregisteredFile &uf) } void -FileMap::deregisterFile(rocFileHandle_t fh) +FileMap::deregisterFile(hipFileHandle_t fh) { auto itr = from_fh.find(fh); @@ -149,7 +149,7 @@ FileMap::~FileMap() { try { // Create a list of registered files without causing the use_count to increase - vector file_handles; + vector file_handles; file_handles.reserve(from_fh.size()); transform(from_fh.begin(), from_fh.end(), std::back_inserter(file_handles), [](const auto &pair) { return pair.first; }); diff --git a/hipfile/src/amd_detail/file.h b/hipfile/src/amd_detail/file.h index 5908f891..8eb52440 100644 --- a/hipfile/src/amd_detail/file.h +++ b/hipfile/src/amd_detail/file.h @@ -79,7 +79,7 @@ class IFile { /// @brief Get the handle for this file /// @return The handle for this file - virtual rocFileHandle_t getHandle() const; + virtual hipFileHandle_t getHandle() const; virtual int getFd() const = 0; virtual const struct statx &getStatx() const noexcept = 0; @@ -134,25 +134,25 @@ class FileMap { /// @brief Registers a file. Files must be registered before they can be used with rocFile IO APIs /// @attention A unique_lock on HipFileMutex must be held /// @param uf An unregistered file - virtual rocFileHandle_t registerFile(const UnregisteredFile &uf); + virtual hipFileHandle_t registerFile(const UnregisteredFile &uf); /// @brief Deregisters the file associated with the provided file handle /// @attention A unique_lock on HipFileMutex must be held /// @param fh The handle of the file to deregister - virtual void deregisterFile(rocFileHandle_t fh); + virtual void deregisterFile(hipFileHandle_t fh); - /// @brief Look up a file given a rocFileHandle_t + /// @brief Look up a file given a hipFileHandle_t /// @attention A shared_lock on HipFileMutex must be held /// @param fh The file handle to lookup the file with /// @return If file handle is valid, return a shared pointer to the file, otherwise throw NotRegistered. - virtual std::shared_ptr getFile(rocFileHandle_t fh); + virtual std::shared_ptr getFile(hipFileHandle_t fh); virtual void clear(); private: /// File lookup tables. std::unordered_map> from_fd; - std::unordered_map> from_fh; + std::unordered_map> from_fh; }; } diff --git a/hipfile/src/amd_detail/hipfile-private.h b/hipfile/src/amd_detail/hipfile-private.h index 7807b2d4..b7db4e7a 100644 --- a/hipfile/src/amd_detail/hipfile-private.h +++ b/hipfile/src/amd_detail/hipfile-private.h @@ -25,6 +25,6 @@ struct Backend; HIPFILE_API void hipFileEnsureDriverInitPrivate(); -ssize_t hipFileIo(hipFile::IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, +ssize_t hipFileIo(hipFile::IoType type, hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset, const std::vector> &backends); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index fda43c40..89e1d332 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -20,7 +20,7 @@ using namespace std; hipFileError_t hipFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) try { - rocFileHandle_t *rocfile_fh = fh; + hipFileHandle_t *rocfile_fh = fh; hipFileError_t status; if (descr) { diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index b5550411..34fe0b97 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -44,7 +44,7 @@ catch (...) { } hipFileError_t -rocFileHandleRegister(rocFileHandle_t *fh, rocFileDescr_t *descr) +rocFileHandleRegister(hipFileHandle_t *fh, rocFileDescr_t *descr) try { if (fh == nullptr || descr == nullptr) { return {hipFileInvalidValue, hipSuccess}; @@ -70,7 +70,7 @@ catch (...) { } hipFileError_t -rocFileHandleDeregister(rocFileHandle_t fh) +rocFileHandleDeregister(hipFileHandle_t fh) try { if (fh == nullptr) { return {hipFileInvalidValue, hipSuccess}; @@ -150,7 +150,7 @@ getCachedBackends() } ssize_t -hipFileIo(IoType type, rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, +hipFileIo(IoType type, hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset, const vector> &backends) try { auto [file, buffer] = Context::get()->getFileAndBuffer(fh, buffer_base, size, 0); @@ -207,13 +207,13 @@ catch (...) { } ssize_t -rocFileRead(rocFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) +rocFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) { return hipFileIo(IoType::Read, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); } ssize_t -rocFileWrite(rocFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, +rocFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) { return hipFileIo(IoType::Write, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); @@ -311,7 +311,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOSetUp(rocFileBatchHandle_t *batch_idp, unsigned max_nr) +rocFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr) try { if (batch_idp == nullptr) { return {hipFileInvalidValue, hipSuccess}; @@ -329,7 +329,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOSubmit(rocFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, unsigned flags) +rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, unsigned flags) try { (void)flags; // Unused at this time. @@ -346,7 +346,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOGetStatus(rocFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, +rocFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, rocFileIOEvents_t *iocbp, struct timespec *timeout) try { (void)batch_idp; @@ -362,7 +362,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOCancel(rocFileBatchHandle_t batch_idp) +rocFileBatchIOCancel(hipFileBatchHandle_t batch_idp) try { (void)batch_idp; @@ -373,7 +373,7 @@ catch (...) { } hipFileError_t -rocFileBatchIODestroy(rocFileBatchHandle_t batch_idp) +rocFileBatchIODestroy(hipFileBatchHandle_t batch_idp) try { (void)batch_idp; @@ -384,7 +384,7 @@ catch (...) { } hipFileError_t -rocFileReadAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +rocFileReadAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream) try { if (Context::get()->getRefCount() == 0) { @@ -406,7 +406,7 @@ catch (...) { } hipFileError_t -rocFileWriteAsync(rocFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +rocFileWriteAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream) try { if (Context::get()->getRefCount() == 0) { diff --git a/hipfile/src/amd_detail/state.cpp b/hipfile/src/amd_detail/state.cpp index f41d9b6a..d9479ee2 100644 --- a/hipfile/src/amd_detail/state.cpp +++ b/hipfile/src/amd_detail/state.cpp @@ -44,20 +44,20 @@ DriverState::~DriverState() // Batch interface // -rocFileBatchHandle_t +hipFileBatchHandle_t DriverState::createBatchContext(unsigned capacity) { return batch_map->createContext(capacity); } void -DriverState::destroyBatchContext(rocFileBatchHandle_t handle) +DriverState::destroyBatchContext(hipFileBatchHandle_t handle) { batch_map->destroyContext(handle); } std::shared_ptr -DriverState::getBatchContext(rocFileBatchHandle_t handle) +DriverState::getBatchContext(hipFileBatchHandle_t handle) { return batch_map->get(handle); } @@ -118,7 +118,7 @@ DriverState::getBuffer(const void *buf, size_t length, int flags) // File interface // -rocFileHandle_t +hipFileHandle_t DriverState::registerFile(const UnregisteredFile &uf) { unique_lock ulock{state_mutex}; @@ -133,7 +133,7 @@ DriverState::registerFile(const UnregisteredFile &uf) } void -DriverState::deregisterFile(rocFileHandle_t fh) +DriverState::deregisterFile(hipFileHandle_t fh) { unique_lock ulock{state_mutex}; @@ -145,7 +145,7 @@ DriverState::deregisterFile(rocFileHandle_t fh) } shared_ptr -DriverState::getFile(rocFileHandle_t fh) +DriverState::getFile(hipFileHandle_t fh) { // NOTE: This mutex only protects the map, so we'll // also need to protect the data @@ -191,7 +191,7 @@ DriverState::getStream(hipStream_t hip_stream) // file_buffer_pair -DriverState::getFileAndBuffer(rocFileHandle_t fh, const void *buf, size_t length, int flags) +DriverState::getFileAndBuffer(hipFileHandle_t fh, const void *buf, size_t length, int flags) { // NOTE: This mutex only protects the map, so we'll // also need to protect the data @@ -209,7 +209,7 @@ DriverState::getFileAndBuffer(rocFileHandle_t fh, const void *buf, size_t length // file_buffer_stream_tuple -DriverState::getFileBufferAndStream(rocFileHandle_t fh, const void *buf, size_t length, int flags, +DriverState::getFileBufferAndStream(hipFileHandle_t fh, const void *buf, size_t length, int flags, hipStream_t hipStream) { shared_lock slock{state_mutex}; diff --git a/hipfile/src/amd_detail/state.h b/hipfile/src/amd_detail/state.h index f0e77d8c..15f6e577 100644 --- a/hipfile/src/amd_detail/state.h +++ b/hipfile/src/amd_detail/state.h @@ -71,16 +71,16 @@ class DriverState { /// @brief Create a new batch context /// @param [in] capacity Maximum number of outstanding operations that this context can manage /// @return An opaque handle used to reference this new batch context - virtual rocFileBatchHandle_t createBatchContext(unsigned capacity); + virtual hipFileBatchHandle_t createBatchContext(unsigned capacity); /// @brief Destroy a batch context and release all associated resources /// @param [in] handle The handle for the batch context to destroy - virtual void destroyBatchContext(rocFileBatchHandle_t handle); + virtual void destroyBatchContext(hipFileBatchHandle_t handle); /// @brief Get a batch context /// @param [in] handle The opaque handle associated with a batch context /// @return A batch context - virtual std::shared_ptr getBatchContext(rocFileBatchHandle_t handle); + virtual std::shared_ptr getBatchContext(hipFileBatchHandle_t handle); // // Buffer interface @@ -116,17 +116,17 @@ class DriverState { /// @brief Registers a file. Files must be registered before they can be used with rocFile IO APIs /// @param [in] uf An unregistered file /// @return A handle to be used when calling rocFile IO APIs - virtual rocFileHandle_t registerFile(const UnregisteredFile &uf); + virtual hipFileHandle_t registerFile(const UnregisteredFile &uf); /// @brief Deregisters the file associated with the provided file handle /// @param [in] fh The handle of the file to deregister - virtual void deregisterFile(rocFileHandle_t fh); + virtual void deregisterFile(hipFileHandle_t fh); - /// @brief Look up a file given a rocFileHandle_t + /// @brief Look up a file given a hipFileHandle_t /// @param [in] fh The file handle to lookup the file with /// @return If file handle is valid, return a shared pointer to the file, otherwise throw /// FileNotRegistered. - virtual std::shared_ptr getFile(rocFileHandle_t fh); + virtual std::shared_ptr getFile(hipFileHandle_t fh); // // Stream interface @@ -164,12 +164,12 @@ class DriverState { /// @param [in] buf Buffer pointer /// @param [in] length Buffer length /// @param [in] flags Buffer flags (unused) - virtual file_buffer_pair getFileAndBuffer(rocFileHandle_t fh, const void *buf, size_t length, int flags); + virtual file_buffer_pair getFileAndBuffer(hipFileHandle_t fh, const void *buf, size_t length, int flags); // // Buffer, file, and stream calls // - virtual file_buffer_stream_tuple getFileBufferAndStream(rocFileHandle_t fh, const void *buf, + virtual file_buffer_stream_tuple getFileBufferAndStream(hipFileHandle_t fh, const void *buf, size_t length, int flags, hipStream_t hipStream); // diff --git a/hipfile/test/amd_detail/batch/batch.cpp b/hipfile/test/amd_detail/batch/batch.cpp index 46b2a770..7b997877 100644 --- a/hipfile/test/amd_detail/batch/batch.cpp +++ b/hipfile/test/amd_detail/batch/batch.cpp @@ -37,7 +37,7 @@ struct HipFileBatch : public HipFileUnopened { std::unique_ptr io_params; std::shared_ptr> default_mock_buffer; std::shared_ptr> default_mock_file; - const rocFileHandle_t file_handle{reinterpret_cast(0xDEADBEEF)}; + const hipFileHandle_t file_handle{reinterpret_cast(0xDEADBEEF)}; void *const buffer_pointer{reinterpret_cast(0x0BADF00D)}; void SetUp() override @@ -87,7 +87,7 @@ TEST_F(HipFileBatch, CreateOperationBadBuffer) TEST_F(HipFileBatch, CreateOperationBadFileHandle) { EXPECT_CALL(*default_mock_file, getHandle) - .WillOnce(Return(reinterpret_cast(0xFACEFEED))); + .WillOnce(Return(reinterpret_cast(0xFACEFEED))); EXPECT_THROW(BatchOperation(std::move(io_params), default_mock_buffer, default_mock_file), std::invalid_argument); } @@ -152,15 +152,15 @@ TEST_F(HipFileBatch, CreateOperationBadMode) TEST_F(HipFileBatch, CreateContext) { - rocFileBatchHandle_t handle = batch_map.createContext(32); + hipFileBatchHandle_t handle = batch_map.createContext(32); ASSERT_NE(nullptr, handle); } TEST_F(HipFileBatch, CreateTwoContexts) { - rocFileBatchHandle_t handle1 = batch_map.createContext(1); - rocFileBatchHandle_t handle2 = batch_map.createContext(1); + hipFileBatchHandle_t handle1 = batch_map.createContext(1); + hipFileBatchHandle_t handle2 = batch_map.createContext(1); ASSERT_NE(handle1, handle2); } @@ -172,7 +172,7 @@ TEST_F(HipFileBatch, CreateContextZeroCapacity) TEST_F(HipFileBatch, CreateContextMaxCapacity) { - rocFileBatchHandle_t handle = batch_map.createContext(BatchContext::MAX_SIZE); + hipFileBatchHandle_t handle = batch_map.createContext(BatchContext::MAX_SIZE); ASSERT_NE(nullptr, handle); } @@ -184,14 +184,14 @@ TEST_F(HipFileBatch, CreateContextOverCapacity) TEST_F(HipFileBatch, DestroyContext) { - rocFileBatchHandle_t handle = batch_map.createContext(1); + hipFileBatchHandle_t handle = batch_map.createContext(1); batch_map.destroyContext(handle); } TEST_F(HipFileBatch, DestroyMissingContext) { - ASSERT_THROW(batch_map.destroyContext(reinterpret_cast(1)), InvalidBatchHandle); + ASSERT_THROW(batch_map.destroyContext(reinterpret_cast(1)), InvalidBatchHandle); } TEST_F(HipFileBatch, DestroyNullptrContext) @@ -201,7 +201,7 @@ TEST_F(HipFileBatch, DestroyNullptrContext) TEST_F(HipFileBatch, GetContext) { - rocFileBatchHandle_t handle = batch_map.createContext(1); + hipFileBatchHandle_t handle = batch_map.createContext(1); std::shared_ptr context = batch_map.get(handle); ASSERT_EQ(handle, context.get()); @@ -214,12 +214,12 @@ TEST_F(HipFileBatch, GetNullptrContext) TEST_F(HipFileBatch, GetInvalidContext) { - ASSERT_THROW(batch_map.get(reinterpret_cast(0xBAC00001)), InvalidBatchHandle); + ASSERT_THROW(batch_map.get(reinterpret_cast(0xBAC00001)), InvalidBatchHandle); } TEST_F(HipFileBatch, GetDestroyedContext) { - rocFileBatchHandle_t handle = batch_map.createContext(1); + hipFileBatchHandle_t handle = batch_map.createContext(1); batch_map.destroyContext(handle); ASSERT_THROW(batch_map.get(handle), InvalidBatchHandle); } diff --git a/hipfile/test/amd_detail/batch/batch_mt.cpp b/hipfile/test/amd_detail/batch/batch_mt.cpp index e121beef..ffc2ebf3 100644 --- a/hipfile/test/amd_detail/batch/batch_mt.cpp +++ b/hipfile/test/amd_detail/batch/batch_mt.cpp @@ -47,7 +47,7 @@ thread_function(int id) auto bcm = BatchContextMap{}; - vector handles; + vector handles; // Preload with data for (int i{0}; i < N_PRELOAD; i++) { @@ -80,7 +80,7 @@ thread_function(int id) uniform_int_distribution vec_dist{0, handles.size() - 1}; size_t idx = vec_dist(gen); - rocFileBatchHandle_t bh = handles[idx]; + hipFileBatchHandle_t bh = handles[idx]; bcm.destroyContext(bh); swap(handles[idx], handles.back()); diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index fe664d53..66c866e1 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -55,7 +55,7 @@ TEST_F(HipFileDriverAdmin, HandleRegisterInitsDriver) StrictMock msys{}; StrictMock mlibmounthelper{}; - rocFileHandle_t handle{}; + hipFileHandle_t handle{}; rocFileDescr_t descr{}; descr.handle.fd = 1234; @@ -76,7 +76,7 @@ TEST_F(HipFileDriverAdmin, HandleRegisterGoodFD) StrictMock msys{}; StrictMock mlibmounthelper{}; - rocFileHandle_t handle{}; + hipFileHandle_t handle{}; rocFileDescr_t descr{}; descr.handle.fd = 0; @@ -99,7 +99,7 @@ TEST_F(HipFileDriverAdmin, HandleRegisterBadFD) StrictMock msys{}; StrictMock mlibmounthelper{}; - rocFileHandle_t handle{}; + hipFileHandle_t handle{}; rocFileDescr_t descr{}; descr.handle.fd = -1; @@ -125,7 +125,7 @@ TEST_F(HipFileDriverAdmin, HandleDeregisterDoesNotInitDriver) ASSERT_EQ(hipFileUseCount(), 0); // Check unregistered handle - rocFileHandle_t handle{}; + hipFileHandle_t handle{}; ASSERT_EQ(hipFileUseCount(), 0); ASSERT_NE(rocFileHandleDeregister(handle), HIPFILE_SUCCESS); @@ -140,7 +140,7 @@ TEST_F(HipFileDriverAdmin, CloseDeregistersFile) StrictMock msys{}; StrictMock mlibmounthelper{}; - rocFileHandle_t handle{}; + hipFileHandle_t handle{}; rocFileDescr_t descr{}; descr.handle.fd = 1234; diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index 9aa6af5b..9c6f276c 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -97,7 +97,7 @@ TEST_F(HipFileHandle, register_handle_internal_linux_fd_already_registered) TEST_F(HipFileHandle, register_handle_linux_fd) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueFD; @@ -111,7 +111,7 @@ TEST_F(HipFileHandle, register_handle_linux_fd) // If statx() fails during file registration return rocfileInternalError TEST_F(HipFileHandle, RocfileHandleRegisterStatxError) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; @@ -124,7 +124,7 @@ TEST_F(HipFileHandle, RocfileHandleRegisterStatxError) // If the fcntl() fails during file registration return rocfileInternalError TEST_F(HipFileHandle, RocfileHandleRegisterFcntlError) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; @@ -138,7 +138,7 @@ TEST_F(HipFileHandle, RocfileHandleRegisterFcntlError) // If getting mount information fails during file registration return rocfileInternalError TEST_F(HipFileHandle, RocfileHandleRegisterLibMountError) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; @@ -152,7 +152,7 @@ TEST_F(HipFileHandle, RocfileHandleRegisterLibMountError) TEST_F(HipFileHandle, register_handle_linux_fd_already_registered) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueFD; @@ -167,7 +167,7 @@ TEST_F(HipFileHandle, register_handle_linux_fd_already_registered) TEST_F(HipFileHandle, register_handle_windows_handle_not_supported) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueWin32; @@ -178,7 +178,7 @@ TEST_F(HipFileHandle, register_handle_windows_handle_not_supported) TEST_F(HipFileHandle, register_handle_userspace_fs_not_supported) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeUserspaceFS; @@ -189,13 +189,13 @@ TEST_F(HipFileHandle, register_handle_userspace_fs_not_supported) TEST_F(HipFileHandle, deregister_handle_internal_throws_if_not_registered) { - ASSERT_THROW(Context::get()->deregisterFile(reinterpret_cast(0xdeadbeef)), + ASSERT_THROW(Context::get()->deregisterFile(reinterpret_cast(0xdeadbeef)), FileNotRegistered); } TEST_F(HipFileHandle, deregister_handle_returns_error_if_not_registered) { - ASSERT_EQ(rocFileHandleDeregister(reinterpret_cast(0xdeadbeef)), + ASSERT_EQ(rocFileHandleDeregister(reinterpret_cast(0xdeadbeef)), HipFileOpError(hipFileHandleNotRegistered)); } @@ -209,7 +209,7 @@ TEST_F(HipFileHandle, deregister_handle_internal) TEST_F(HipFileHandle, deregister_handle) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueFD; @@ -234,7 +234,7 @@ TEST_F(HipFileHandle, deregister_handle_internal_fails_when_operations_are_ousta TEST_F(HipFileHandle, deregister_handle_fails_when_operations_are_oustanding) { - rocFileHandle_t fh{}; + hipFileHandle_t fh{}; rocFileDescr_t rfd{}; rfd.type = rocFileHandleTypeOpaqueFD; diff --git a/hipfile/test/amd_detail/mfile.h b/hipfile/test/amd_detail/mfile.h index 9ee15405..c8461d9b 100644 --- a/hipfile/test/amd_detail/mfile.h +++ b/hipfile/test/amd_detail/mfile.h @@ -18,7 +18,7 @@ namespace hipFile { class MFile : public IFile { public: - MOCK_METHOD(rocFileHandle_t, getHandle, (), (const override)); + MOCK_METHOD(hipFileHandle_t, getHandle, (), (const override)); MOCK_METHOD(int, getFd, (), (const override)); MOCK_METHOD(const struct statx &, getStatx, (), (const, noexcept, override)); MOCK_METHOD(int, getStatusFlags, (), (const override)); @@ -30,9 +30,9 @@ class MFileMap : public FileMap { MFileMap() { } - MOCK_METHOD(rocFileHandle_t, registerFile, (const UnregisteredFile &uf), (override)); - MOCK_METHOD(void, deregisterFile, (rocFileHandle_t fh), (override)); - MOCK_METHOD(std::shared_ptr, getFile, (rocFileHandle_t), (override)); + MOCK_METHOD(hipFileHandle_t, registerFile, (const UnregisteredFile &uf), (override)); + MOCK_METHOD(void, deregisterFile, (hipFileHandle_t fh), (override)); + MOCK_METHOD(std::shared_ptr, getFile, (hipFileHandle_t), (override)); MOCK_METHOD(void, clear, (), (override)); }; diff --git a/hipfile/test/amd_detail/mstate.h b/hipfile/test/amd_detail/mstate.h index 7c62e719..63254022 100644 --- a/hipfile/test/amd_detail/mstate.h +++ b/hipfile/test/amd_detail/mstate.h @@ -27,18 +27,18 @@ class MDriverState : public DriverState { { } - MOCK_METHOD(rocFileBatchHandle_t, createBatchContext, (unsigned capacity), (override)); - MOCK_METHOD(void, destroyBatchContext, (rocFileBatchHandle_t handle), (override)); - MOCK_METHOD(std::shared_ptr, getBatchContext, (rocFileBatchHandle_t handle), (override)); + MOCK_METHOD(hipFileBatchHandle_t, createBatchContext, (unsigned capacity), (override)); + MOCK_METHOD(void, destroyBatchContext, (hipFileBatchHandle_t handle), (override)); + MOCK_METHOD(std::shared_ptr, getBatchContext, (hipFileBatchHandle_t handle), (override)); MOCK_METHOD(void, registerBuffer, (const void *buf, size_t length, int flags), (override)); MOCK_METHOD(void, deregisterBuffer, (const void *buf), (override)); MOCK_METHOD(std::shared_ptr, getBuffer, (const void *buf), (override)); MOCK_METHOD(std::shared_ptr, getBuffer, (const void *buf, size_t length, int flags), (override)); - MOCK_METHOD(rocFileHandle_t, registerFile, (const UnregisteredFile &uf), (override)); - MOCK_METHOD(void, deregisterFile, (rocFileHandle_t fh), (override)); - MOCK_METHOD(std::shared_ptr, getFile, (rocFileHandle_t fh), (override)); + MOCK_METHOD(hipFileHandle_t, registerFile, (const UnregisteredFile &uf), (override)); + MOCK_METHOD(void, deregisterFile, (hipFileHandle_t fh), (override)); + MOCK_METHOD(std::shared_ptr, getFile, (hipFileHandle_t fh), (override)); MOCK_METHOD(file_buffer_pair, getFileAndBuffer, - (rocFileHandle_t fh, const void *buf, size_t length, int flags), (override)); + (hipFileHandle_t fh, const void *buf, size_t length, int flags), (override)); MOCK_METHOD(void, incrRefCount, (), (override)); MOCK_METHOD(void, decrRefCount, (), (override)); MOCK_METHOD(int64_t, getRefCount, (), (override, const)); diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index cae2aec3..be6af8eb 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -61,8 +61,8 @@ struct HipFileUnit : public HipFileUnopened { TEST_F(HipFileUnit, TestHipFileBatchIOSetupSuccess) { - rocFileBatchHandle_t b_handle = nullptr; - rocFileBatchHandle_t expected_b_handle = reinterpret_cast(0x12345678); + hipFileBatchHandle_t b_handle = nullptr; + hipFileBatchHandle_t expected_b_handle = reinterpret_cast(0x12345678); EXPECT_CALL(mock_state, createBatchContext).WillOnce(Return(expected_b_handle)); @@ -73,7 +73,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSetupSuccess) TEST_F(HipFileUnit, TestHipFileBatchIOSetupBadArgument) { - rocFileBatchHandle_t b_handle = nullptr; + hipFileBatchHandle_t b_handle = nullptr; EXPECT_CALL(mock_state, createBatchContext).WillOnce(Throw(std::invalid_argument(""))); @@ -90,7 +90,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSetupNullptrHandle) TEST_F(HipFileUnit, TestHipFileBatchIOSubmitSuccess) { - rocFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); + hipFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); rocFileIOParams_t io_param; std::shared_ptr mock_b_context = std::make_shared(); @@ -103,7 +103,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitSuccess) TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadHandle) { - rocFileBatchHandle_t b_handle = nullptr; + hipFileBatchHandle_t b_handle = nullptr; rocFileIOParams_t io_param; std::shared_ptr mock_b_context = std::make_shared(); @@ -117,7 +117,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadHandle) TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadArgument) { - rocFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); + hipFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); rocFileIOParams_t io_param; std::shared_ptr mock_b_context = std::make_shared(); @@ -130,7 +130,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadArgument) /// @brief Test rocFileIO function struct HipFileIoParam : public TestWithParam { - rocFileHandle_t file_handle{}; + hipFileHandle_t file_handle{}; void *bufptr{reinterpret_cast(0xDEC0DE)}; size_t buflen{4096}; const void *unreg_bufptr{reinterpret_cast(0xFACEFEED)}; @@ -182,7 +182,7 @@ TEST_P(HipFileIoParam, HipFileIoHandlesInvalidRegisteredBufferLength) TEST_P(HipFileIoParam, HipFileIoHandlesInvalidFileHandle) { - auto invalid_handle{reinterpret_cast(0xdeadbeef)}; + auto invalid_handle{reinterpret_cast(0xdeadbeef)}; ASSERT_EQ(hipFileIo(GetParam(), invalid_handle, bufptr, 0, 0, 0, mbackends), -hipFileHandleNotRegistered); } @@ -214,7 +214,7 @@ INSTANTIATE_TEST_SUITE_P(HipFileIo, HipFileIoParam, Values(IoType::Read, IoType: struct HipFileIoBackendSelectionParam : public ::testing::TestWithParam { IoType io_type; - rocFileHandle_t handle; + hipFileHandle_t handle; void *buffer; size_t io_size; hoff_t file_offset; @@ -228,7 +228,7 @@ struct HipFileIoBackendSelectionParam : public ::testing::TestWithParam StrictMock mds; HipFileIoBackendSelectionParam() - : io_type{GetParam()}, handle{reinterpret_cast(0xBADF00D)}, + : io_type{GetParam()}, handle{reinterpret_cast(0xBADF00D)}, buffer{reinterpret_cast(0xDEADBEEF)}, io_size{1024}, file_offset{32}, buffer_offset{64}, flags{0}, mfile{std::make_shared>()}, mbuffer{std::make_shared>()}, mbe1{std::make_shared>()}, diff --git a/hipfile/test/amd_detail/state_mt.cpp b/hipfile/test/amd_detail/state_mt.cpp index 87614ab3..4c9d644d 100644 --- a/hipfile/test/amd_detail/state_mt.cpp +++ b/hipfile/test/amd_detail/state_mt.cpp @@ -75,7 +75,7 @@ thread_function(int id) auto *ds = Context::get(); - vector> files; + vector> files; vector buffers; vector hip_streams; From 388a78705d77c3289d20da93f149682c14694da3 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 05:02:43 -0700 Subject: [PATCH 33/48] Remove unused rocFile RDMA stuff --- hipfile/include/rocfile.h | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 7eca4135..ab1688e0 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -60,26 +60,6 @@ typedef struct rocFileDriverProps { unsigned max_batch_io_timeout_msecs; //!< Timeout (in msec) for a batch operation to complete } rocFileDriverProps_t; -// *********************************************************************** -// RDMA API -// *********************************************************************** - -/*! - * @brief Userspace RDMA configuration - * @ingroup rdma - */ -typedef struct rocFileRDMAInfo { - int version; //!< Version of the RDMA API to use - int desc_len; //!< Length of the description string - const char *desc_str; //!< Describes the configuration of the RDMA operation -} rocFileRDMAInfo_t; - -/// Flag for if the RDMA operation is registered -#define ROCFILE_RDMA_REGISTER 1 - -/// Flag for if the RDMA operation has relaxed ordering -#define ROCFILE_RDMA_RELAXED_ORDERING (1 << 1) - // *********************************************************************** // FILE HANDLE API // *********************************************************************** @@ -104,11 +84,11 @@ typedef struct rocFileFSOps { /*! * Read from the remote filesystem. If NULL, use the Linux VFS. */ - ssize_t (*read)(void *handle, char *, size_t, hoff_t, rocFileRDMAInfo_t *); + ssize_t (*read)(void *handle, char *, size_t, hoff_t, hipFileRDMAInfo_t *); /*! * Write to the remote filesystem. If NULL, use the Linux VFS. */ - ssize_t (*write)(void *handle, const char *, size_t, hoff_t, rocFileRDMAInfo_t *); + ssize_t (*write)(void *handle, const char *, size_t, hoff_t, hipFileRDMAInfo_t *); } rocFileFSOps_t; /*! From c9ba82820d767c1bc6f44afc175de1c74437979b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 05:10:49 -0700 Subject: [PATCH 34/48] Yank rocFileDriverProps_t --- hipfile/include/rocfile.h | 39 ---------------------- hipfile/src/amd_detail/hipfile-rocfile.cpp | 21 ------------ hipfile/src/amd_detail/hipfile-rocfile.h | 2 -- 3 files changed, 62 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index ab1688e0..bfe3c92d 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -21,45 +21,6 @@ extern "C" { #endif -// *********************************************************************** -// GPU IO DRIVER API -// *********************************************************************** - -/* See this section in hipfile.h for a discussion about the - * following enums. - */ - -/*! - * @brief GPU IO configuration - * @ingroup driver - */ -typedef struct rocFileDriverProps { - /*! - * @brief GPU IO Driver Configuration - */ - struct { - unsigned major_version; //!< Major version of the GPU IO driver - unsigned minor_version; //!< Minor version of the GPU IO driver - - uint64_t poll_thresh_size; //!< Maximum IO size (in KiB) for which polling is used when poll mode is - //!< enabled - uint64_t max_direct_io_size; //!< Maximum IO size (in KiB) used by the GPU IO driver - - unsigned driver_status_flags; //!< Bitfield that maps to rocFileDriverStatusFlags_t - unsigned driver_control_flags; //!< Bitfield that maps to rocFileDriverControlFlags_t - } nvfs; - - unsigned feature_flags; //!< Bitfield that maps to rocFileFeatureFlags_t - - uint64_t - max_device_cache_size; //!< Maximum amount of GPU memory (in KiB) that can be used for bounce buffers - uint64_t per_buffer_cache_size; //!< Amount of GPU memory (in KiB) allocated for each bounce buffer - uint64_t max_device_pinned_mem_size; //!< Maximum amount of GPU memory (in KiB) that can be pinned - - unsigned max_batch_io_count; //!< Maximum number of batch operations that can be submitted at once - unsigned max_batch_io_timeout_msecs; //!< Timeout (in msec) for a batch operation to complete -} rocFileDriverProps_t; - // *********************************************************************** // FILE HANDLE API // *********************************************************************** diff --git a/hipfile/src/amd_detail/hipfile-rocfile.cpp b/hipfile/src/amd_detail/hipfile-rocfile.cpp index 7444f98c..0cf9382f 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.cpp +++ b/hipfile/src/amd_detail/hipfile-rocfile.cpp @@ -22,27 +22,6 @@ toRocFileFileHandleType(hipFileFileHandleType_t hf_type) } } -hipFileDriverProps_t -toHipFileDriverProps(const rocFileDriverProps_t &rf_props) -{ - hipFileDriverProps_t hf_props; - - hf_props.nvfs.major_version = rf_props.nvfs.major_version; - hf_props.nvfs.minor_version = rf_props.nvfs.minor_version; - hf_props.nvfs.poll_thresh_size = rf_props.nvfs.poll_thresh_size; - hf_props.nvfs.max_direct_io_size = rf_props.nvfs.max_direct_io_size; - hf_props.nvfs.driver_status_flags = rf_props.nvfs.driver_status_flags; - hf_props.nvfs.driver_control_flags = rf_props.nvfs.driver_control_flags; - hf_props.feature_flags = rf_props.feature_flags; - hf_props.max_device_cache_size = rf_props.max_device_cache_size; - hf_props.per_buffer_cache_size = rf_props.per_buffer_cache_size; - hf_props.max_device_pinned_mem_size = rf_props.max_device_pinned_mem_size; - hf_props.max_batch_io_count = rf_props.max_batch_io_count; - hf_props.max_batch_io_timeout_msecs = rf_props.max_batch_io_timeout_msecs; - - return hf_props; -} - rocFileDescr_t toRocFileDescr(const hipFileDescr_t &fd) { diff --git a/hipfile/src/amd_detail/hipfile-rocfile.h b/hipfile/src/amd_detail/hipfile-rocfile.h index 951c813f..785e0ec7 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.h +++ b/hipfile/src/amd_detail/hipfile-rocfile.h @@ -11,8 +11,6 @@ // rocFile to hipFile //////////////////////////////////////////////////////// -hipFileDriverProps_t toHipFileDriverProps(const rocFileDriverProps_t &rf_props); - hipFileStatus_t toHipFileStatus(rocFileStatus_t rf_status); hipFileIOEvents_t toHipFileIOEvents(const rocFileIOEvents_t &rf_io_event); From c60c5ae3030bb0caa582cb2546242446f38a2625 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 05:26:00 -0700 Subject: [PATCH 35/48] Yank rocFile file handle types --- hipfile/include/rocfile.h | 56 +--------------------- hipfile/src/amd_detail/hipfile-rocfile.cpp | 42 ---------------- hipfile/src/amd_detail/hipfile-rocfile.h | 4 -- hipfile/src/amd_detail/hipfile.cpp | 14 +----- hipfile/src/amd_detail/rocfile.cpp | 8 ++-- hipfile/test/amd_detail/driver.cpp | 16 +++---- hipfile/test/amd_detail/handle.cpp | 36 +++++++------- 7 files changed, 32 insertions(+), 144 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index bfe3c92d..797d9222 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -25,60 +25,6 @@ extern "C" { // FILE HANDLE API // *********************************************************************** -/*! - * @brief IO operations for RDMA filesystems - * @ingroup file - */ -typedef struct rocFileFSOps { - /*! - * Type of remote FS used. If NULL, use fstat to discover. - */ - const char *(*fs_type)(void *handle); - /*! - * Get a list of host RDMA addresses. If NULL, use any address. - */ - int (*getRDMADeviceList)(void *handle, struct sockaddr **hostaddrs); - /*! - * Get the assigned priority of a RDMA device. If -1, there is no preference. - */ - int (*getRDMADevicePriority)(void *handle, char *, size_t, hoff_t, struct sockaddr *hostaddr); - /*! - * Read from the remote filesystem. If NULL, use the Linux VFS. - */ - ssize_t (*read)(void *handle, char *, size_t, hoff_t, hipFileRDMAInfo_t *); - /*! - * Write to the remote filesystem. If NULL, use the Linux VFS. - */ - ssize_t (*write)(void *handle, const char *, size_t, hoff_t, hipFileRDMAInfo_t *); -} rocFileFSOps_t; - -/*! - * @brief Type of file handle being used - * @ingroup file - */ -typedef enum rocFileFileHandleType { - rocFileHandleTypeOpaqueFD = 1, //!< POSIX file descriptor - rocFileHandleTypeOpaqueWin32 = 2, //!< Windows HANDLE file handle - rocFileHandleTypeUserspaceFS = 3, //!< Userspace RDMA filesystem -} rocFileFileHandleType_t; - -/*! - * @brief Top-level structure for performing GPU IO - * @ingroup file - * - * rocFileHandleTypeOpaqueFD -> handle.fd non-negative, fs_ops ignored - * rocFileHandleTypeOpaqueWin32 -> handle.hFile non-NULL, fs_ops ignored - * rocFileHandleTypeUserspaceFS -> handle.fd non-negative, fs_ops non-NULL - */ -typedef struct rocFileDescr { - rocFileFileHandleType_t type; //!< Type of file handle being used - union { - int fd; //!< POSIX file descriptor - void *hFile; //!< Win32 HANDLE file handle - } handle; //!< Union containing the OS-specific file handle - const rocFileFSOps_t *fs_ops; //!< Userspace RDMA filesystem operations -} rocFileDescr_t; - /*! * @brief Registers an open file for GPU IO * @ingroup file @@ -93,7 +39,7 @@ typedef struct rocFileDescr { * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileHandleRegister(hipFileHandle_t *fh, rocFileDescr_t *descr); +hipFileError_t rocFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr); /*! * @brief Deregisters a file from GPU IO diff --git a/hipfile/src/amd_detail/hipfile-rocfile.cpp b/hipfile/src/amd_detail/hipfile-rocfile.cpp index 0cf9382f..3f25613d 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.cpp +++ b/hipfile/src/amd_detail/hipfile-rocfile.cpp @@ -7,48 +7,6 @@ #include -rocFileFileHandleType_t -toRocFileFileHandleType(hipFileFileHandleType_t hf_type) -{ - switch (hf_type) { - case hipFileHandleTypeOpaqueFD: - return rocFileHandleTypeOpaqueFD; - case hipFileHandleTypeOpaqueWin32: - return rocFileHandleTypeOpaqueWin32; - case hipFileHandleTypeUserspaceFS: - return rocFileHandleTypeUserspaceFS; - default: - throw std::invalid_argument("Invalid hipFileFileHandleType_t value"); - } -} - -rocFileDescr_t -toRocFileDescr(const hipFileDescr_t &fd) -{ - rocFileDescr_t rfd; - - rfd.fs_ops = reinterpret_cast(fd.fs_ops); - - switch (fd.type) { - case hipFileHandleTypeOpaqueFD: - rfd.type = rocFileHandleTypeOpaqueFD; - rfd.handle.fd = fd.handle.fd; - break; - case hipFileHandleTypeOpaqueWin32: - rfd.type = rocFileHandleTypeOpaqueWin32; - rfd.handle.hFile = fd.handle.hFile; - break; - case hipFileHandleTypeUserspaceFS: - rfd.type = rocFileHandleTypeUserspaceFS; - rfd.handle.fd = fd.handle.fd; - break; - default: - throw std::invalid_argument("Invalid hipFileFileHandleType_t value"); - } - - return rfd; -} - rocFileBatchMode toRocFileBatchMode(hipFileBatchMode_t hf_batch_mode) { diff --git a/hipfile/src/amd_detail/hipfile-rocfile.h b/hipfile/src/amd_detail/hipfile-rocfile.h index 785e0ec7..4ca092f4 100644 --- a/hipfile/src/amd_detail/hipfile-rocfile.h +++ b/hipfile/src/amd_detail/hipfile-rocfile.h @@ -17,10 +17,6 @@ hipFileIOEvents_t toHipFileIOEvents(const rocFileIOEvents_t &rf_io_event); // hipFile to rocFile //////////////////////////////////////////////////////// -rocFileDescr_t toRocFileDescr(const hipFileDescr_t &fd); - -rocFileFileHandleType_t toRocFileFileHandleType(hipFileFileHandleType_t hf_type); - rocFileIOParams_t toRocFileIOParams(const hipFileIOParams_t &hf_io_params); rocFileOpcode_t toRocFileOpcode(hipFileOpcode_t hf_opcode); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index 89e1d332..aae81775 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -20,19 +20,7 @@ using namespace std; hipFileError_t hipFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) try { - hipFileHandle_t *rocfile_fh = fh; - hipFileError_t status; - - if (descr) { - auto rocfile_descr = toRocFileDescr(*descr); - status = rocFileHandleRegister(rocfile_fh, &rocfile_descr); - descr->fs_ops = reinterpret_cast(rocfile_descr.fs_ops); - } - else { - status = rocFileHandleRegister(rocfile_fh, nullptr); - } - - return status; + return rocFileHandleRegister(fh, descr); } catch (...) { return {hipFileInternalError, hipSuccess}; diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 34fe0b97..fd15a7c9 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -44,20 +44,20 @@ catch (...) { } hipFileError_t -rocFileHandleRegister(hipFileHandle_t *fh, rocFileDescr_t *descr) +rocFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) try { if (fh == nullptr || descr == nullptr) { return {hipFileInvalidValue, hipSuccess}; } switch (descr->type) { - case rocFileHandleTypeOpaqueFD: { + case hipFileHandleTypeOpaqueFD: { UnregisteredFile uf{descr->handle.fd}; *fh = Context::get()->registerFile(uf); return {hipFileSuccess, hipSuccess}; } - case rocFileHandleTypeOpaqueWin32: - case rocFileHandleTypeUserspaceFS: + case hipFileHandleTypeOpaqueWin32: + case hipFileHandleTypeUserspaceFS: default: return {hipFileIONotSupported, hipSuccess}; } diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index 66c866e1..e6e2a6c8 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -56,10 +56,10 @@ TEST_F(HipFileDriverAdmin, HandleRegisterInitsDriver) StrictMock mlibmounthelper{}; hipFileHandle_t handle{}; - rocFileDescr_t descr{}; + hipFileDescr_t descr{}; descr.handle.fd = 1234; - descr.type = rocFileHandleTypeOpaqueFD; + descr.type = hipFileHandleTypeOpaqueFD; descr.fs_ops = nullptr; ASSERT_EQ(hipFileUseCount(), 0); @@ -77,10 +77,10 @@ TEST_F(HipFileDriverAdmin, HandleRegisterGoodFD) StrictMock mlibmounthelper{}; hipFileHandle_t handle{}; - rocFileDescr_t descr{}; + hipFileDescr_t descr{}; descr.handle.fd = 0; - descr.type = rocFileHandleTypeOpaqueFD; + descr.type = hipFileHandleTypeOpaqueFD; descr.fs_ops = nullptr; expect_file_registration(msys, mlibmounthelper); @@ -100,10 +100,10 @@ TEST_F(HipFileDriverAdmin, HandleRegisterBadFD) StrictMock mlibmounthelper{}; hipFileHandle_t handle{}; - rocFileDescr_t descr{}; + hipFileDescr_t descr{}; descr.handle.fd = -1; - descr.type = rocFileHandleTypeOpaqueFD; + descr.type = hipFileHandleTypeOpaqueFD; EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); @@ -141,10 +141,10 @@ TEST_F(HipFileDriverAdmin, CloseDeregistersFile) StrictMock mlibmounthelper{}; hipFileHandle_t handle{}; - rocFileDescr_t descr{}; + hipFileDescr_t descr{}; descr.handle.fd = 1234; - descr.type = rocFileHandleTypeOpaqueFD; + descr.type = hipFileHandleTypeOpaqueFD; descr.fs_ops = nullptr; ASSERT_EQ(hipFileUseCount(), 0); diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index 9c6f276c..eb238583 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -98,9 +98,9 @@ TEST_F(HipFileHandle, register_handle_internal_linux_fd_already_registered) TEST_F(HipFileHandle, register_handle_linux_fd) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; + hipFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueFD; + rfd.type = hipFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); @@ -112,8 +112,8 @@ TEST_F(HipFileHandle, register_handle_linux_fd) TEST_F(HipFileHandle, RocfileHandleRegisterStatxError) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueFD; + hipFileDescr_t rfd{}; + rfd.type = hipFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); @@ -125,8 +125,8 @@ TEST_F(HipFileHandle, RocfileHandleRegisterStatxError) TEST_F(HipFileHandle, RocfileHandleRegisterFcntlError) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueFD; + hipFileDescr_t rfd{}; + rfd.type = hipFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; EXPECT_CALL(msys, statx); @@ -139,8 +139,8 @@ TEST_F(HipFileHandle, RocfileHandleRegisterFcntlError) TEST_F(HipFileHandle, RocfileHandleRegisterLibMountError) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueFD; + hipFileDescr_t rfd{}; + rfd.type = hipFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; EXPECT_CALL(msys, statx); @@ -153,9 +153,9 @@ TEST_F(HipFileHandle, RocfileHandleRegisterLibMountError) TEST_F(HipFileHandle, register_handle_linux_fd_already_registered) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; + hipFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueFD; + rfd.type = hipFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); @@ -168,9 +168,9 @@ TEST_F(HipFileHandle, register_handle_linux_fd_already_registered) TEST_F(HipFileHandle, register_handle_windows_handle_not_supported) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; + hipFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueWin32; + rfd.type = hipFileHandleTypeOpaqueWin32; rfd.handle.fd = 0xBADF00D; ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); @@ -179,9 +179,9 @@ TEST_F(HipFileHandle, register_handle_windows_handle_not_supported) TEST_F(HipFileHandle, register_handle_userspace_fs_not_supported) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; + hipFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeUserspaceFS; + rfd.type = hipFileHandleTypeUserspaceFS; rfd.handle.fd = 0xBADF00D; ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); @@ -210,9 +210,9 @@ TEST_F(HipFileHandle, deregister_handle_internal) TEST_F(HipFileHandle, deregister_handle) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; + hipFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueFD; + rfd.type = hipFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); @@ -235,9 +235,9 @@ TEST_F(HipFileHandle, deregister_handle_internal_fails_when_operations_are_ousta TEST_F(HipFileHandle, deregister_handle_fails_when_operations_are_oustanding) { hipFileHandle_t fh{}; - rocFileDescr_t rfd{}; + hipFileDescr_t rfd{}; - rfd.type = rocFileHandleTypeOpaqueFD; + rfd.type = hipFileHandleTypeOpaqueFD; rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); From 7c81e7c6d77a7a9d7d96825e3a49fe6883f46160 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 06:17:43 -0700 Subject: [PATCH 36/48] Get rid of the rest of the rocFile types --- hipfile/include/rocfile.h | 64 +---------------- hipfile/src/amd_detail/CMakeLists.txt | 1 - hipfile/src/amd_detail/batch/batch.cpp | 10 +-- hipfile/src/amd_detail/batch/batch.h | 8 +-- hipfile/src/amd_detail/hipfile-rocfile.cpp | 84 ---------------------- hipfile/src/amd_detail/hipfile-rocfile.h | 24 ------- hipfile/src/amd_detail/hipfile.cpp | 9 ++- hipfile/src/amd_detail/rocfile.cpp | 4 +- hipfile/test/amd_detail/batch/batch.cpp | 38 +++++----- hipfile/test/amd_detail/mbatch.h | 2 +- hipfile/test/amd_detail/rocfile.cpp | 6 +- hipfile/test/system/driver.cpp | 4 ++ 12 files changed, 44 insertions(+), 210 deletions(-) delete mode 100644 hipfile/src/amd_detail/hipfile-rocfile.cpp delete mode 100644 hipfile/src/amd_detail/hipfile-rocfile.h diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 797d9222..5e44d0d8 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -122,66 +122,6 @@ ssize_t rocFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, h // BATCH API // *********************************************************************** -/*! - * @brief The direction of data movement in a batch IO request - * @ingroup batch - */ -typedef enum rocFileOpcode { - rocFileBatchRead = 0, //!< Batch IO read operation - rocFileBatchWrite = 1, //!< Batch IO write operation -} rocFileOpcode_t; - -/*! - * @brief The status of a batch IO operation - * @ingroup batch - */ -typedef enum rocFileStatus { - rocFileWaiting = 1 << 0, //!< Batch IO request pending acceptance - rocFilePending = 1 << 1, //!< Batch IO request accepted and queued - rocFileInvalid = 1 << 2, //!< Batch IO request was rejected for being invalid or could not be queued - rocFileCanceled = 1 << 3, //!< Batch IO request was canceled - rocFileComplete = 1 << 4, //!< Batch IO request completed - rocFileTimeout = 1 << 5, //!< Batch IO request timed out - rocFileFailed = 1 << 6, //!< Batch IO request failed -} rocFileStatus_t; - -/*! - * @brief Mode of a batch IO operation - * @ingroup batch - */ -typedef enum rocFileBatchMode { - rocFileBatch = 1, //!< Normal batch IO operation -} rocFileBatchMode_t; - -/*! - * @brief Input parameters for a batch IO request - * @ingroup batch - */ -typedef struct rocFileIOParams { - rocFileBatchMode_t mode; //!< Mode of the batch IO request - union { - struct { - void *devPtr_base; //!< Base address of the GPU buffer where data should be read/written - int64_t file_offset; //!< Offset into the file that should be read/written - int64_t devPtr_offset; //!< Offset of the GPU buffer that should be read/written - size_t size; //!< Number of bytes to read or write - } batch; //!< Parameters for the read/write batch request - } u; //!< Wrapping union for batch IO parameters - hipFileHandle_t fh; //!< Registered rocFile handle for the target file - rocFileOpcode_t opcode; //!< Direction data is moving for the batch request - void *cookie; //!< Optionally used to track IO operations (e.g. self-reference pointer) -} rocFileIOParams_t; - -/*! - * @brief Status of a batch IO operation - * @ingroup batch - */ -typedef struct rocFileIOEvents { - void *cookie; //!< Optionally used to track IO operations (e.g. pointer to corresponding rocFileIOParams) - rocFileStatus_t status; //!< Status of the batch IO operation - size_t ret; //!< Number of bytes transferred or POSIX error code if negative -} rocFileIOEvents_t; - /*! * @brief Prepare the system to perform a batch IO operation * @ingroup batch @@ -208,7 +148,7 @@ hipFileError_t rocFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max * @return A rocFile error */ ROCFILE_API -hipFileError_t rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, +hipFileError_t rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, hipFileIOParams_t *iocbp, unsigned flags); /*! @@ -228,7 +168,7 @@ hipFileError_t rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, */ ROCFILE_API hipFileError_t rocFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, - rocFileIOEvents_t *iocbp, struct timespec *timeout); + hipFileIOEvents_t *iocbp, struct timespec *timeout); /*! * @brief Cancels all pending batch IO operations diff --git a/hipfile/src/amd_detail/CMakeLists.txt b/hipfile/src/amd_detail/CMakeLists.txt index 5de9a008..af850dd4 100644 --- a/hipfile/src/amd_detail/CMakeLists.txt +++ b/hipfile/src/amd_detail/CMakeLists.txt @@ -17,7 +17,6 @@ set(HIPFILE_SOURCES hip.cpp hipfile.cpp hipfile-private.cpp - hipfile-rocfile.cpp mountinfo.cpp rocfile.cpp state.cpp diff --git a/hipfile/src/amd_detail/batch/batch.cpp b/hipfile/src/amd_detail/batch/batch.cpp index 2939a4db..2ad44d49 100644 --- a/hipfile/src/amd_detail/batch/batch.cpp +++ b/hipfile/src/amd_detail/batch/batch.cpp @@ -22,7 +22,7 @@ namespace hipFile { -BatchOperation::BatchOperation(std::unique_ptr params, +BatchOperation::BatchOperation(std::unique_ptr params, std::shared_ptr _buffer, std::shared_ptr _file) : io_params{std::move(params)}, buffer{_buffer}, file{_file} { @@ -67,7 +67,7 @@ BatchOperation::BatchOperation(std::unique_ptr params, } // Check OpCode - if (io_params->opcode != rocFileBatchRead && io_params->opcode != rocFileBatchWrite) { + if (io_params->opcode != hipFileBatchRead && io_params->opcode != hipFileBatchWrite) { std::stringstream msg; msg << "Bad opcode specified. Value: " << io_params->opcode; msg << ". Cookie: " << io_params->cookie; @@ -75,7 +75,7 @@ BatchOperation::BatchOperation(std::unique_ptr params, } // Check Batch Mode - if (io_params->mode != rocFileBatch) { + if (io_params->mode != hipFileBatch) { std::stringstream msg; msg << "Invalid Batch mode specified. Value: " << io_params->mode; msg << ". Cookie: " << io_params->cookie; @@ -100,7 +100,7 @@ BatchContext::get_capacity() const noexcept } void -BatchContext::submit_operations(const rocFileIOParams_t *params, unsigned num_params) +BatchContext::submit_operations(const hipFileIOParams_t *params, unsigned num_params) { std::unique_lock _ulock{context_mutex}; @@ -119,7 +119,7 @@ BatchContext::submit_operations(const rocFileIOParams_t *params, unsigned num_pa // rather than waiting to lock the DriverState lock for each lookup. for (unsigned i = 0; i < num_params; i++) { // Make a copy of the params so another thread cannot modify the operation. - auto param_copy = std::make_unique(params[i]); + auto param_copy = std::make_unique(params[i]); // flags currently unused. Ambiguous if flags in rocFileBatchIOSubmit is for buffer or // file flags. auto [_file, _buffer] = Context::get()->getFileAndBuffer( diff --git a/hipfile/src/amd_detail/batch/batch.h b/hipfile/src/amd_detail/batch/batch.h index 4644decd..f8372a17 100644 --- a/hipfile/src/amd_detail/batch/batch.h +++ b/hipfile/src/amd_detail/batch/batch.h @@ -35,13 +35,13 @@ class BatchOperation { /// @param [in] params IO parameters /// @param [in] buffer Buffer corresponding to params->u.batch.devPtr_base /// @param [in] file File corresponding params->fh - BatchOperation(std::unique_ptr params, std::shared_ptr buffer, + BatchOperation(std::unique_ptr params, std::shared_ptr buffer, std::shared_ptr file); private: /// @brief A copy of the params provided by the application. /// @internal Keep this listed at the top of BatchOperation. - const std::unique_ptr io_params; + const std::unique_ptr io_params; /// @brief A reference to the specified Buffer. const std::shared_ptr buffer; @@ -56,7 +56,7 @@ class IBatchContext { virtual ~IBatchContext() = default; virtual unsigned get_capacity() const noexcept = 0; - virtual void submit_operations(const rocFileIOParams_t *params, unsigned num_params) = 0; + virtual void submit_operations(const hipFileIOParams_t *params, unsigned num_params) = 0; }; class BatchContext : public IBatchContext { @@ -76,7 +76,7 @@ class BatchContext : public IBatchContext { /// @note This is an All or None operation. If one submitted operation is not valid, no operations /// will be submitted. /// - void submit_operations(const rocFileIOParams_t *params, const unsigned num_params) override; + void submit_operations(const hipFileIOParams_t *params, const unsigned num_params) override; private: const unsigned capacity; diff --git a/hipfile/src/amd_detail/hipfile-rocfile.cpp b/hipfile/src/amd_detail/hipfile-rocfile.cpp deleted file mode 100644 index 3f25613d..00000000 --- a/hipfile/src/amd_detail/hipfile-rocfile.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ - -#include "hipfile-rocfile.h" - -#include - -rocFileBatchMode -toRocFileBatchMode(hipFileBatchMode_t hf_batch_mode) -{ - switch (hf_batch_mode) { - case hipFileBatch: - return rocFileBatch; - default: - throw std::invalid_argument("Invalid hipFileBatchMode_t value"); - } -} - -rocFileOpcode_t -toRocFileOpcode(hipFileOpcode_t hf_opcode) -{ - switch (hf_opcode) { - case hipFileBatchRead: - return rocFileBatchRead; - case hipFileBatchWrite: - return rocFileBatchWrite; - default: - throw std::invalid_argument("Invalid hipFileOpcode_t value"); - } -} - -rocFileIOParams_t -toRocFileIOParams(const hipFileIOParams_t &hf_io_params) -{ - rocFileIOParams_t rf_io_params; - - rf_io_params.mode = toRocFileBatchMode(hf_io_params.mode); - rf_io_params.u.batch.devPtr_base = hf_io_params.u.batch.devPtr_base; - rf_io_params.u.batch.file_offset = hf_io_params.u.batch.file_offset; - rf_io_params.u.batch.devPtr_offset = hf_io_params.u.batch.devPtr_offset; - rf_io_params.u.batch.size = hf_io_params.u.batch.size; - rf_io_params.fh = hf_io_params.fh; - rf_io_params.opcode = toRocFileOpcode(hf_io_params.opcode); - rf_io_params.cookie = hf_io_params.cookie; - - return rf_io_params; -} - -hipFileStatus_t -toHipFileStatus(rocFileStatus_t rf_status) -{ - switch (rf_status) { - case rocFileWaiting: - return hipFileWaiting; - case rocFilePending: - return hipFilePending; - case rocFileInvalid: - return hipFileInvalid; - case rocFileCanceled: - return hipFileCanceled; - case rocFileComplete: - return hipFileComplete; - case rocFileTimeout: - return hipFileTimeout; - case rocFileFailed: - return hipFileFailed; - default: - throw std::invalid_argument("Invalid rocFileStatus_t value"); - } -} - -hipFileIOEvents_t -toHipFileIOEvents(const rocFileIOEvents_t &rf_io_event) -{ - hipFileIOEvents_t hf_io_event; - - hf_io_event.cookie = rf_io_event.cookie; - hf_io_event.status = toHipFileStatus(rf_io_event.status); - hf_io_event.ret = rf_io_event.ret; - - return hf_io_event; -} diff --git a/hipfile/src/amd_detail/hipfile-rocfile.h b/hipfile/src/amd_detail/hipfile-rocfile.h deleted file mode 100644 index 4ca092f4..00000000 --- a/hipfile/src/amd_detail/hipfile-rocfile.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ - -// Conversions between hipFile and rocFile types - -#pragma once - -#include "hipfile.h" - -// rocFile to hipFile //////////////////////////////////////////////////////// - -hipFileStatus_t toHipFileStatus(rocFileStatus_t rf_status); - -hipFileIOEvents_t toHipFileIOEvents(const rocFileIOEvents_t &rf_io_event); - -// hipFile to rocFile //////////////////////////////////////////////////////// - -rocFileIOParams_t toRocFileIOParams(const hipFileIOParams_t &hf_io_params); - -rocFileOpcode_t toRocFileOpcode(hipFileOpcode_t hf_opcode); - -rocFileBatchMode toRocFileBatchMode(hipFileBatchMode_t hf_batch_mode); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index aae81775..4c09a726 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -5,7 +5,6 @@ #include "hipfile.h" #include "hipfile-private.h" -#include "hipfile-rocfile.h" #include #include @@ -95,10 +94,10 @@ try { hipFileError_t status; if (iocbp) { - vector io_params(nr); + vector io_params(nr); for (unsigned i = 0; i < nr; i++) { - io_params[i] = toRocFileIOParams(iocbp[i]); + io_params[i] = iocbp[i]; } status = rocFileBatchIOSubmit(rf_batch_idp, nr, io_params.data(), flags); @@ -121,13 +120,13 @@ try { hipFileError_t status; if (iocbp) { - vector io_events(*nr); + vector io_events(*nr); status = rocFileBatchIOGetStatus(rf_batch_idp, min_nr, nr, io_events.data(), timeout); if (status.err == hipFileSuccess) { for (unsigned i = 0; i < *nr; i++) { - iocbp[i] = toHipFileIOEvents(io_events[i]); + iocbp[i] = io_events[i]; } } } diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index fd15a7c9..12519dd9 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -329,7 +329,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, rocFileIOParams_t *iocbp, unsigned flags) +rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, hipFileIOParams_t *iocbp, unsigned flags) try { (void)flags; // Unused at this time. @@ -347,7 +347,7 @@ catch (...) { hipFileError_t rocFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, - rocFileIOEvents_t *iocbp, struct timespec *timeout) + hipFileIOEvents_t *iocbp, struct timespec *timeout) try { (void)batch_idp; (void)min_nr; diff --git a/hipfile/test/amd_detail/batch/batch.cpp b/hipfile/test/amd_detail/batch/batch.cpp index 7b997877..0e5039ea 100644 --- a/hipfile/test/amd_detail/batch/batch.cpp +++ b/hipfile/test/amd_detail/batch/batch.cpp @@ -34,7 +34,7 @@ HIPFILE_WARN_NO_GLOBAL_CTOR_OFF struct HipFileBatch : public HipFileUnopened { BatchContextMap batch_map = BatchContextMap{}; - std::unique_ptr io_params; + std::unique_ptr io_params; std::shared_ptr> default_mock_buffer; std::shared_ptr> default_mock_file; const hipFileHandle_t file_handle{reinterpret_cast(0xDEADBEEF)}; @@ -49,12 +49,12 @@ struct HipFileBatch : public HipFileUnopened { default_mock_file = std::make_shared>(); EXPECT_CALL(*default_mock_file, getHandle).WillRepeatedly(Return(file_handle)); - io_params = std::make_unique(); + io_params = std::make_unique(); io_params->u.batch.devPtr_base = const_cast(buffer_pointer); io_params->u.batch.size = 1; io_params->fh = file_handle; - io_params->mode = rocFileBatch; - io_params->opcode = rocFileBatchRead; + io_params->mode = hipFileBatch; + io_params->opcode = hipFileBatchRead; } HipFileBatch() @@ -65,14 +65,14 @@ struct HipFileBatch : public HipFileUnopened { TEST_F(HipFileBatch, CreateOperationRead) { - io_params->opcode = rocFileBatchRead; + io_params->opcode = hipFileBatchRead; BatchOperation op = BatchOperation{std::move(io_params), default_mock_buffer, default_mock_file}; } TEST_F(HipFileBatch, CreateOperationWrite) { - io_params->opcode = rocFileBatchWrite; + io_params->opcode = hipFileBatchWrite; BatchOperation op = BatchOperation{std::move(io_params), default_mock_buffer, default_mock_file}; } @@ -136,7 +136,7 @@ TEST_F(HipFileBatch, CreateOperationBadFileOffsetIsNegative) TEST_F(HipFileBatch, CreateOperationBadOpcode) { - io_params->opcode = invalidEnum(-1); + io_params->opcode = invalidEnum(-1); EXPECT_THROW(BatchOperation(std::move(io_params), default_mock_buffer, default_mock_file), std::invalid_argument); @@ -144,7 +144,7 @@ TEST_F(HipFileBatch, CreateOperationBadOpcode) TEST_F(HipFileBatch, CreateOperationBadMode) { - io_params->mode = invalidEnum(-1); + io_params->mode = invalidEnum(-1); EXPECT_THROW(BatchOperation(std::move(io_params), default_mock_buffer, default_mock_file), std::invalid_argument); @@ -230,7 +230,7 @@ struct HipFileBatchContext : public HipFileUnopened { unsigned _context_capacity = 2; std::unique_ptr> mock_driver_state; - rocFileIOParams_t io_params{}; + hipFileIOParams_t io_params{}; std::shared_ptr> default_mock_buffer; int default_mock_buffer_length = 1; std::shared_ptr> default_mock_file; @@ -249,8 +249,8 @@ struct HipFileBatchContext : public HipFileUnopened { io_params.u.batch.devPtr_base = default_mock_buffer->getBuffer(); io_params.u.batch.size = 1; io_params.fh = default_mock_file->getHandle(); - io_params.mode = rocFileBatch; - io_params.opcode = rocFileBatchRead; + io_params.mode = hipFileBatch; + io_params.opcode = hipFileBatchRead; mock_driver_state = std::make_unique>(); _context = batch_map.get(batch_map.createContext(_context_capacity)); @@ -308,43 +308,43 @@ TEST_F(HipFileBatchContext, SubmitSingleBadFileHandle) // BatchOperation is not mocked. TEST_F(HipFileBatchContext, SubmitSingleBadParamBufferOffsetNegative) { - rocFileIOParams_t bad_io_params = io_params; + hipFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.devPtr_offset = -1; ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } TEST_F(HipFileBatchContext, SubmitSingleBadParamBufferOffsetTooLarge) { - rocFileIOParams_t bad_io_params = io_params; + hipFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.devPtr_offset = default_mock_buffer_length; ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } TEST_F(HipFileBatchContext, SubmitSingleBadParamIOSizeTooLarge) { - rocFileIOParams_t bad_io_params = io_params; + hipFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.size = static_cast(default_mock_buffer_length + 1); ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } TEST_F(HipFileBatchContext, SubmitSingleBadParamFileOffsetNegative) { - rocFileIOParams_t bad_io_params = io_params; + hipFileIOParams_t bad_io_params = io_params; bad_io_params.u.batch.file_offset = -1; ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } TEST_F(HipFileBatchContext, SubmitSingleBadParamOpcodeInvalid) { - rocFileIOParams_t bad_io_params = io_params; - bad_io_params.opcode = invalidEnum(-1); + hipFileIOParams_t bad_io_params = io_params; + bad_io_params.opcode = invalidEnum(-1); ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } TEST_F(HipFileBatchContext, SubmitSingleBadParamModeInvalid) { - rocFileIOParams_t bad_io_params = io_params; - bad_io_params.mode = invalidEnum(-1); + hipFileIOParams_t bad_io_params = io_params; + bad_io_params.mode = invalidEnum(-1); ASSERT_THROW(_context->submit_operations(&bad_io_params, 1), std::invalid_argument); } diff --git a/hipfile/test/amd_detail/mbatch.h b/hipfile/test/amd_detail/mbatch.h index cf34c206..c59ba908 100644 --- a/hipfile/test/amd_detail/mbatch.h +++ b/hipfile/test/amd_detail/mbatch.h @@ -18,7 +18,7 @@ namespace hipFile { class MBatchContext : public IBatchContext { public: MOCK_METHOD(unsigned, get_capacity, (), (const, noexcept, override)); - MOCK_METHOD(void, submit_operations, (const rocFileIOParams_t *params, const unsigned num_params), + MOCK_METHOD(void, submit_operations, (const hipFileIOParams_t *params, const unsigned num_params), (override)); }; diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index be6af8eb..d01b7ea8 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -91,7 +91,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSetupNullptrHandle) TEST_F(HipFileUnit, TestHipFileBatchIOSubmitSuccess) { hipFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); - rocFileIOParams_t io_param; + hipFileIOParams_t io_param; std::shared_ptr mock_b_context = std::make_shared(); EXPECT_CALL(mock_state, getBatchContext).WillOnce(Return(mock_b_context)); @@ -104,7 +104,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitSuccess) TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadHandle) { hipFileBatchHandle_t b_handle = nullptr; - rocFileIOParams_t io_param; + hipFileIOParams_t io_param; std::shared_ptr mock_b_context = std::make_shared(); EXPECT_CALL(mock_state, getBatchContext).WillOnce(Throw(InvalidBatchHandle())); @@ -118,7 +118,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadHandle) TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadArgument) { hipFileBatchHandle_t b_handle = reinterpret_cast(0x12345678); - rocFileIOParams_t io_param; + hipFileIOParams_t io_param; std::shared_ptr mock_b_context = std::make_shared(); EXPECT_CALL(mock_state, getBatchContext).WillOnce(Return(mock_b_context)); diff --git a/hipfile/test/system/driver.cpp b/hipfile/test/system/driver.cpp index 54a91604..d46b1e23 100644 --- a/hipfile/test/system/driver.cpp +++ b/hipfile/test/system/driver.cpp @@ -209,7 +209,11 @@ TEST_F(DriverNoInit, hipFileBatchIOSubmit) hipFileBatchHandle_t handle{}; hipFileIOParams_t param{}; +#ifdef __HIP_PLATFORM_AMD__ + ASSERT_EQ(hipFileBatchIOSubmit(handle, 1, ¶m, 0), HipFileOpError(hipFileInvalidValue)); +#else ASSERT_EQ(hipFileBatchIOSubmit(handle, 1, ¶m, 0), HipFileOpError(hipFileInternalError)); +#endif } TEST_F(DriverNoInit, hipFileBatchIOGetStatusNullArgs) From 438ed00855de4a3c16c3c34cd8c65057060beaa9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 06:47:29 -0700 Subject: [PATCH 37/48] Moved async API to 100% hipFile --- hipfile/include/rocfile.h | 66 ------------------------------ hipfile/src/amd_detail/hipfile.cpp | 52 ----------------------- hipfile/src/amd_detail/rocfile.cpp | 16 +++++--- hipfile/test/amd_detail/driver.cpp | 31 +++++++------- hipfile/test/amd_detail/stream.cpp | 6 +-- 5 files changed, 29 insertions(+), 142 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 5e44d0d8..88bd20bf 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -192,72 +192,6 @@ hipFileError_t rocFileBatchIOCancel(hipFileBatchHandle_t batch_idp); ROCFILE_API hipFileError_t rocFileBatchIODestroy(hipFileBatchHandle_t batch_idp); -// *********************************************************************** -// ASYNC API -// *********************************************************************** - -/*! - * @brief Perform an asynchronous read from a stream - * @ingroup async - * - * @param [in] fh Opaque file handle for GPU IO operations - * @param [in] buffer_base Base address of the GPU buffer - * @param [in] size_p Number of bytes that should be read - * @param [in] file_offset_p Offset into the file that should be read from - * @param [in] buffer_offset_p Offset of the GPU buffer that that the data should be written to - * @param [out] bytes_read_p Number of bytes read - * @param [in] stream The hipStream to enqueue this async IO request. - * If NULL, this request will be synchronous. - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileReadAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, - hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream); - -/*! - * @brief Perform an asynchronous write to a stream - * @ingroup async - * - * @param [in] fh Opaque file handle for GPU IO operations - * @param [in] buffer_base Base address of the GPU buffer - * @param [in] size_p Number of bytes that should be written - * @param [in] file_offset_p Offset into the file that should be written to - * @param [in] buffer_offset_p Offset of the GPU buffer that that the data should be read from - * @param [out] bytes_written_p Number of bytes written - * @param [in] stream The hipStream to enqueue this async IO request. - * If NULL, this request will be synchronous. - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileWriteAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, - hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream); - -/*! - * @brief Register a stream to be used by for asynchronous GPU IO - * @ingroup async - * - * @param [in] stream The stream used for for async IO requests - * @param [in] flags Flags that can optimize stream processing if parameters - * are known/are aligned at time of request submission - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileStreamRegister(hipStream_t stream, unsigned flags); - -/*! - * @brief Deregister a stream and free the associated resources - * @ingroup async - * - * @param [in] stream The stream used for async IO requests - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileStreamDeregister(hipStream_t stream); - #ifdef __cplusplus } #endif diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index 4c09a726..d33f865a 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -154,55 +154,3 @@ hipFileBatchIODestroy(hipFileBatchHandle_t batch_idp) { (void)rocFileBatchIODestroy(batch_idp); } - -hipFileError_t -hipFileReadAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, - hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream) -try { - auto result = - rocFileReadAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_read_p, stream); - if (result.err == hipFileDriverNotInitialized) { - // Match cuFile behaviour - hipFileEnsureDriverInitPrivate(); - result.err = hipFileInvalidValue; - } - return result; -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileWriteAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, - hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream) -try { - auto result = - rocFileWriteAsync(fh, buffer_base, size_p, file_offset_p, buffer_offset_p, bytes_written_p, stream); - if (result.err == hipFileDriverNotInitialized) { - // Match cuFile behaviour - hipFileEnsureDriverInitPrivate(); - result.err = hipFileInvalidValue; - } - return result; -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileStreamRegister(hipStream_t stream, unsigned flags) -try { - return rocFileStreamRegister(stream, flags); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileStreamDeregister(hipStream_t stream) -try { - return rocFileStreamDeregister(stream); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 12519dd9..a43c5a47 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -384,11 +384,13 @@ catch (...) { } hipFileError_t -rocFileReadAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +hipFileReadAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_read_p, hipStream_t stream) try { if (Context::get()->getRefCount() == 0) { - return {hipFileDriverNotInitialized, hipSuccess}; + // Match cuFile behaviour + hipFileEnsureDriverInitPrivate(); + return {hipFileInvalidValue, hipSuccess}; } (void)fh; @@ -406,11 +408,13 @@ catch (...) { } hipFileError_t -rocFileWriteAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, +hipFileWriteAsync(hipFileHandle_t fh, void *buffer_base, size_t *size_p, hoff_t *file_offset_p, hoff_t *buffer_offset_p, ssize_t *bytes_written_p, hipStream_t stream) try { if (Context::get()->getRefCount() == 0) { - return {hipFileDriverNotInitialized, hipSuccess}; + // Match cuFile behaviour + hipFileEnsureDriverInitPrivate(); + return {hipFileInvalidValue, hipSuccess}; } (void)fh; @@ -428,7 +432,7 @@ catch (...) { } hipFileError_t -rocFileStreamRegister(hipStream_t stream, unsigned flags) +hipFileStreamRegister(hipStream_t stream, unsigned flags) try { Context::get()->registerStream(stream, flags); return {hipFileSuccess, hipSuccess}; @@ -441,7 +445,7 @@ catch (...) { } hipFileError_t -rocFileStreamDeregister(hipStream_t stream) +hipFileStreamDeregister(hipStream_t stream) try { Context::get()->deregisterStream(stream); return {hipFileSuccess, hipSuccess}; diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index e6e2a6c8..7baae2a6 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -200,31 +200,32 @@ TEST_F(HipFileDriverAdmin, CloseDeregistersBuffer) ASSERT_EQ(hipFileUseCount(), 1); } -// Ensure rocFileReadAsync(): -// * Returns hipFileDriverNotInitialized when called w/o a driver init -// * Does NOT initialize the driver and returns a reference count of 0 -TEST_F(HipFileDriverAdmin, ReadAsyncDoesNotInitDriver) +// Ensure hipFileReadAsync(): +// * Returns hipFileInvalidValue when called w/o a driver init +// * Initializes the driver and returns a reference count of 1 (like cuFile) +TEST_F(HipFileDriverAdmin, ReadAsyncInitsDriver) { - ASSERT_EQ(rocFileReadAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), - HipFileOpError(hipFileDriverNotInitialized)); - ASSERT_EQ(hipFileUseCount(), 0); + ASSERT_EQ(hipFileReadAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), + HipFileOpError(hipFileInvalidValue)); + ASSERT_EQ(hipFileUseCount(), 1); } -// Ensure rocFileWriteAsync(): -// * Returns hipFileDriverNotInitialized when called w/o a driver init -// * Does NOT initialize the driver and returns a reference count of 0 -TEST_F(HipFileDriverAdmin, WriteAsyncDoesNotInitDriverDriver) +// Ensure hipFileWriteAsync(): +// * Returns hipFileInvalidValue when called w/o a driver init +// * Initializes the driver and returns a reference count of 1 (like cuFile) +TEST_F(HipFileDriverAdmin, WriteAsyncInitsDriver) { - ASSERT_EQ(rocFileWriteAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), - HipFileOpError(hipFileDriverNotInitialized)); - ASSERT_EQ(hipFileUseCount(), 0); + // Error value matches cuFile + ASSERT_EQ(hipFileWriteAsync(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), + HipFileOpError(hipFileInvalidValue)); + ASSERT_EQ(hipFileUseCount(), 1); } // Ensure rocFileRead(): // * Returns hipFileDriverNotInitialized when called w/o a driver init // (the weird negative sign is a quirk of returning a ssize_t) // * Does NOT initialize the driver and returns a reference count of 0 -TEST_F(HipFileDriverAdmin, ReadDoesNotInitDriver) +TEST_F(HipFileDriverAdmin, ReadDoesNotInitsDriver) { ASSERT_EQ(rocFileRead(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); ASSERT_EQ(hipFileUseCount(), 0); diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index 76d41e7e..17c68923 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -128,13 +128,13 @@ struct HipFileStreamExternal : public HipFileOpened { TEST_F(HipFileStreamExternal, register_and_deregister_with_valid_stream_works) { - ASSERT_EQ(rocFileStreamRegister(nonnull_stream, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileStreamDeregister(nonnull_stream), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileStreamRegister(nonnull_stream, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileStreamDeregister(nonnull_stream), HIPFILE_SUCCESS); } TEST_F(HipFileStreamExternal, deregister_exception_returns_error) { - ASSERT_EQ(rocFileStreamDeregister(nullptr), HipFileOpError(hipFileInvalidValue)); + ASSERT_EQ(hipFileStreamDeregister(nullptr), HipFileOpError(hipFileInvalidValue)); } HIPFILE_WARN_NO_GLOBAL_CTOR_ON From 057b0661c9e518da591242e9b0952aae305100c6 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 07:05:50 -0700 Subject: [PATCH 38/48] Move rest of batch API to hipFile --- hipfile/include/rocfile.h | 74 ------------------------- hipfile/src/amd_detail/batch/batch.cpp | 2 +- hipfile/src/amd_detail/hipfile.cpp | 77 -------------------------- hipfile/src/amd_detail/rocfile.cpp | 14 ++--- hipfile/test/amd_detail/rocfile.cpp | 12 ++-- 5 files changed, 14 insertions(+), 165 deletions(-) diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h index 88bd20bf..d8487393 100644 --- a/hipfile/include/rocfile.h +++ b/hipfile/include/rocfile.h @@ -118,80 +118,6 @@ ROCFILE_API ssize_t rocFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset); -// *********************************************************************** -// BATCH API -// *********************************************************************** - -/*! - * @brief Prepare the system to perform a batch IO operation - * @ingroup batch - * - * @param [out] batch_idp Opaque handle for batch operations - * @param [in] max_nr Maximum number of requests that can be submitted to this batch handle - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr); - -/*! - * @brief Enqueue a batch of IO requests for the GPU to complete asynchronously - * @ingroup batch - * - * @param [in] batch_idp Opaque handle for batch operations - * @param [in] nr Number of batch IO requests to submit - * @param [in] iocbp An array of `nr` batch IO requests to submit to the GPU. - * Data will be read into or written from the buffer specified in - * each request. - * @param [in] flags Control Flags for the batch IO. Currently unused. - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, hipFileIOParams_t *iocbp, - unsigned flags); - -/*! - * @brief Poll for the status of completed batch IO operations - * @ingroup batch - * - * @param [in] batch_idp Opaque handle for batch operations. - * @param [in] min_nr Minimum number of batch operation statuses that should be returned. - * If `timeout` is exceeded, fewer statuses may be returned. - * @param [in,out] nr Maximum number of batch operation statuses that can be returned. - * This is parameter is modified to return the number of statuses returned in `iocbp`. - * - * @param [out] iocbp An array containing up to `nr` statuses from the overall batch operation - * @param [in] timeout Maximum amount of time this function should poll for status updates - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, - hipFileIOEvents_t *iocbp, struct timespec *timeout); - -/*! - * @brief Cancels all pending batch IO operations - * @ingroup batch - * - * @param [in] batch_idp Opaque handle for batch operations - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileBatchIOCancel(hipFileBatchHandle_t batch_idp); - -/*! - * @brief Destroys the batch IO handle and frees the associated resources - * @ingroup batch - * - * @param [in] batch_idp Opaque handle for batch operations - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileBatchIODestroy(hipFileBatchHandle_t batch_idp); - #ifdef __cplusplus } #endif diff --git a/hipfile/src/amd_detail/batch/batch.cpp b/hipfile/src/amd_detail/batch/batch.cpp index 2ad44d49..7ff7c14f 100644 --- a/hipfile/src/amd_detail/batch/batch.cpp +++ b/hipfile/src/amd_detail/batch/batch.cpp @@ -120,7 +120,7 @@ BatchContext::submit_operations(const hipFileIOParams_t *params, unsigned num_pa for (unsigned i = 0; i < num_params; i++) { // Make a copy of the params so another thread cannot modify the operation. auto param_copy = std::make_unique(params[i]); - // flags currently unused. Ambiguous if flags in rocFileBatchIOSubmit is for buffer or + // flags currently unused. Ambiguous if flags in hipFileBatchIOSubmit is for buffer or // file flags. auto [_file, _buffer] = Context::get()->getFileAndBuffer( param_copy->fh, param_copy->u.batch.devPtr_base, param_copy->u.batch.size, 0); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index d33f865a..40f9b110 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -77,80 +77,3 @@ hipFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t fi } return result; } - -hipFileError_t -hipFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr) -try { - return rocFileBatchIOSetUp(batch_idp, max_nr); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, hipFileIOParams_t *iocbp, unsigned flags) -try { - auto rf_batch_idp = batch_idp; - hipFileError_t status; - - if (iocbp) { - vector io_params(nr); - - for (unsigned i = 0; i < nr; i++) { - io_params[i] = iocbp[i]; - } - - status = rocFileBatchIOSubmit(rf_batch_idp, nr, io_params.data(), flags); - } - else { - status = rocFileBatchIOSubmit(rf_batch_idp, nr, nullptr, flags); - } - - return status; -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, - hipFileIOEvents_t *iocbp, struct timespec *timeout) -try { - auto rf_batch_idp = batch_idp; - hipFileError_t status; - - if (iocbp) { - vector io_events(*nr); - - status = rocFileBatchIOGetStatus(rf_batch_idp, min_nr, nr, io_events.data(), timeout); - - if (status.err == hipFileSuccess) { - for (unsigned i = 0; i < *nr; i++) { - iocbp[i] = io_events[i]; - } - } - } - else { - status = rocFileBatchIOGetStatus(rf_batch_idp, min_nr, nr, nullptr, timeout); - } - - return status; -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileBatchIOCancel(hipFileBatchHandle_t batch_idp) -try { - return rocFileBatchIOCancel(batch_idp); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -void -hipFileBatchIODestroy(hipFileBatchHandle_t batch_idp) -{ - (void)rocFileBatchIODestroy(batch_idp); -} diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index a43c5a47..7a8db0d0 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -311,7 +311,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr) +hipFileBatchIOSetUp(hipFileBatchHandle_t *batch_idp, unsigned max_nr) try { if (batch_idp == nullptr) { return {hipFileInvalidValue, hipSuccess}; @@ -329,7 +329,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, hipFileIOParams_t *iocbp, unsigned flags) +hipFileBatchIOSubmit(hipFileBatchHandle_t batch_idp, unsigned nr, hipFileIOParams_t *iocbp, unsigned flags) try { (void)flags; // Unused at this time. @@ -346,7 +346,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, +hipFileBatchIOGetStatus(hipFileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, hipFileIOEvents_t *iocbp, struct timespec *timeout) try { (void)batch_idp; @@ -362,7 +362,7 @@ catch (...) { } hipFileError_t -rocFileBatchIOCancel(hipFileBatchHandle_t batch_idp) +hipFileBatchIOCancel(hipFileBatchHandle_t batch_idp) try { (void)batch_idp; @@ -372,15 +372,15 @@ catch (...) { return handle_exception(); } -hipFileError_t -rocFileBatchIODestroy(hipFileBatchHandle_t batch_idp) +void +hipFileBatchIODestroy(hipFileBatchHandle_t batch_idp) try { (void)batch_idp; throw std::runtime_error("Not Implemented"); } catch (...) { - return handle_exception(); + return; } hipFileError_t diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index d01b7ea8..171f6923 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -66,7 +66,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSetupSuccess) EXPECT_CALL(mock_state, createBatchContext).WillOnce(Return(expected_b_handle)); - auto result = rocFileBatchIOSetUp(&b_handle, 1); + auto result = hipFileBatchIOSetUp(&b_handle, 1); EXPECT_EQ(result, HIPFILE_SUCCESS); EXPECT_EQ(b_handle, expected_b_handle); } @@ -77,14 +77,14 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSetupBadArgument) EXPECT_CALL(mock_state, createBatchContext).WillOnce(Throw(std::invalid_argument(""))); - auto result = rocFileBatchIOSetUp(&b_handle, 0); + auto result = hipFileBatchIOSetUp(&b_handle, 0); EXPECT_EQ(result, HIPFILE_INVALID_VALUE); EXPECT_EQ(b_handle, nullptr); } TEST_F(HipFileUnit, TestHipFileBatchIOSetupNullptrHandle) { - auto result = rocFileBatchIOSetUp(nullptr, 1); + auto result = hipFileBatchIOSetUp(nullptr, 1); ASSERT_EQ(result, HIPFILE_INVALID_VALUE); } @@ -97,7 +97,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitSuccess) EXPECT_CALL(mock_state, getBatchContext).WillOnce(Return(mock_b_context)); EXPECT_CALL(*mock_b_context, submit_operations); - auto result = rocFileBatchIOSubmit(b_handle, 1, &io_param, 0); + auto result = hipFileBatchIOSubmit(b_handle, 1, &io_param, 0); ASSERT_EQ(result, HIPFILE_SUCCESS); } @@ -110,7 +110,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadHandle) EXPECT_CALL(mock_state, getBatchContext).WillOnce(Throw(InvalidBatchHandle())); EXPECT_CALL(*mock_b_context, submit_operations).Times(0); - auto result = rocFileBatchIOSubmit(b_handle, 1, &io_param, 0); + auto result = hipFileBatchIOSubmit(b_handle, 1, &io_param, 0); hipFileError_t expected_result = {hipFileInvalidValue, hipSuccess}; ASSERT_EQ(result, expected_result); } @@ -124,7 +124,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadArgument) EXPECT_CALL(mock_state, getBatchContext).WillOnce(Return(mock_b_context)); EXPECT_CALL(*mock_b_context, submit_operations).WillOnce(Throw(std::invalid_argument(""))); - auto result = rocFileBatchIOSubmit(b_handle, 1, &io_param, 0); + auto result = hipFileBatchIOSubmit(b_handle, 1, &io_param, 0); ASSERT_EQ(result, HIPFILE_INVALID_VALUE); } From b77305e9df87cbf5385e488a494619b363c7d7c3 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:01:42 -0700 Subject: [PATCH 39/48] Retires the last of the rocFile code --- hipfile/include/hipfile.h | 2 - hipfile/include/rocfile.h | 123 --------------------- hipfile/src/amd_detail/CMakeLists.txt | 1 - hipfile/src/amd_detail/buffer.h | 2 +- hipfile/src/amd_detail/context.cpp | 2 +- hipfile/src/amd_detail/file.h | 2 +- hipfile/src/amd_detail/hipfile.cpp | 79 ------------- hipfile/src/amd_detail/rocfile.cpp | 53 +++++---- hipfile/src/amd_detail/state.cpp | 2 +- hipfile/src/amd_detail/state.h | 8 +- hipfile/test/amd_detail/async.cpp | 4 +- hipfile/test/amd_detail/batch/batch_mt.cpp | 2 +- hipfile/test/amd_detail/buffer.cpp | 46 ++++---- hipfile/test/amd_detail/driver.cpp | 52 +++++---- hipfile/test/amd_detail/handle.cpp | 39 ++++--- hipfile/test/amd_detail/rocfile.cpp | 18 +-- hipfile/test/amd_detail/state_mt.cpp | 2 +- hipfile/test/amd_detail/stream.cpp | 4 +- 18 files changed, 121 insertions(+), 320 deletions(-) delete mode 100644 hipfile/include/rocfile.h delete mode 100644 hipfile/src/amd_detail/hipfile.cpp diff --git a/hipfile/include/hipfile.h b/hipfile/include/hipfile.h index 3a14d47f..065c3380 100644 --- a/hipfile/include/hipfile.h +++ b/hipfile/include/hipfile.h @@ -1110,5 +1110,3 @@ hipFileError_t hipFileSetParameterString(hipFileStringConfigParameter_t param, c #ifdef __cplusplus } #endif - -#include diff --git a/hipfile/include/rocfile.h b/hipfile/include/rocfile.h deleted file mode 100644 index d8487393..00000000 --- a/hipfile/include/rocfile.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ - -#pragma once - -#include -#include -#include -#include -#include - -#if defined(__GNUC__) -#define ROCFILE_API __attribute__((visibility("default"))) -#else -#define ROCFILE_API -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// *********************************************************************** -// FILE HANDLE API -// *********************************************************************** - -/*! - * @brief Registers an open file for GPU IO - * @ingroup file - * - * @note If the library has not already been initialized, the first call to - * `rocFileHandleRegister()` will initialize the library and increment - * the reference count (if it succeeds). - * - * @param [out] fh Opaque file handle for GPU IO operations - * @param [in] descr Parameters for opening the file - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr); - -/*! - * @brief Deregisters a file from GPU IO - * @ingroup file - * - * @param [in] fh Opaque file handle for GPU IO operations - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileHandleDeregister(hipFileHandle_t fh); - -/*! - * @brief Registers a GPU memory region to be used with GPU IO - * @ingroup file - * - * The memory region should be allocated by the user before being passed to the API call - * - * @note If the library has not already been initialized, the first call to - * `rocFileBufRegister()` will initialize the library and increment - * the reference count. - * - * @param [in] buffer_base Base address of the GPU buffer - * @param [in] length Size of the allocated buffer in bytes - * @param [in] flags Control flags for this buffer - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileBufRegister(const void *buffer_base, size_t length, int flags); - -/*! - * @brief Deregisters a GPU memory region from being used with GPU IO - * @ingroup file - * - * @param [in] buffer_base Base address of the GPU buffer - * - * @return A rocFile error - */ -ROCFILE_API -hipFileError_t rocFileBufDeregister(const void *buffer_base); - -/*! - * @brief Synchronously read data from a file into a GPU buffer - * @ingroup file - * - * @param [in] fh Opaque file handle for GPU IO operations - * @param [in] buffer_base Base address of the GPU buffer - * @param [in] size Number of bytes that should be read - * @param [in] file_offset Offset into the file that should be read from - * @param [in] buffer_offset Offset of the GPU buffer that that the data should be written to - * - * @return if >= 0: Number of bytes read - * @return if -1: System error (check `errno` for the specific error) - * @return else: Negative value of the related hipFileOpError_t - */ -ROCFILE_API -ssize_t rocFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, - hoff_t buffer_offset); - -/*! - * @brief Synchronously write data from a GPU buffer to a file - * @ingroup file - * - * @param [in] fh Opaque file handle for GPU IO operations - * @param [in] buffer_base Base address of the GPU buffer - * @param [in] size Number of bytes that should be written - * @param [in] file_offset Offset into the file that should be written to - * @param [in] buffer_offset Offset of the GPU buffer that the data should be read from - * - * @return if >= 0: Number of bytes written - * @return if -1: System error (check `errno` for the specific error) - * @return else: Negative value of the related hipFileOpError_t - */ -ROCFILE_API -ssize_t rocFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, - hoff_t buffer_offset); - -#ifdef __cplusplus -} -#endif diff --git a/hipfile/src/amd_detail/CMakeLists.txt b/hipfile/src/amd_detail/CMakeLists.txt index af850dd4..fd99748c 100644 --- a/hipfile/src/amd_detail/CMakeLists.txt +++ b/hipfile/src/amd_detail/CMakeLists.txt @@ -15,7 +15,6 @@ set(HIPFILE_SOURCES context.cpp file.cpp hip.cpp - hipfile.cpp hipfile-private.cpp mountinfo.cpp rocfile.cpp diff --git a/hipfile/src/amd_detail/buffer.h b/hipfile/src/amd_detail/buffer.h index 02a219ed..5a05f751 100644 --- a/hipfile/src/amd_detail/buffer.h +++ b/hipfile/src/amd_detail/buffer.h @@ -136,7 +136,7 @@ class BufferMap { virtual void clear(); private: - /// Buffer lookup table. Protected by rocfile.cpp's StateMutex + /// Buffer lookup table. Protected by hipfile.cpp's StateMutex std::unordered_map> from_ptr; }; diff --git a/hipfile/src/amd_detail/context.cpp b/hipfile/src/amd_detail/context.cpp index 746e0cd7..4e909938 100644 --- a/hipfile/src/amd_detail/context.cpp +++ b/hipfile/src/amd_detail/context.cpp @@ -20,7 +20,7 @@ HipFileInit::HipFileInit() HIPFILE_WARN_NO_GLOBAL_CTOR_OFF HIPFILE_WARN_NO_EXIT_DTOR_OFF -static HipFileInit *rocfile_init = Context::get(); +static HipFileInit *hipfile_init = Context::get(); HIPFILE_WARN_NO_EXIT_DTOR_ON HIPFILE_WARN_NO_GLOBAL_CTOR_ON diff --git a/hipfile/src/amd_detail/file.h b/hipfile/src/amd_detail/file.h index 8eb52440..1302e2c5 100644 --- a/hipfile/src/amd_detail/file.h +++ b/hipfile/src/amd_detail/file.h @@ -131,7 +131,7 @@ class FileMap { public: virtual ~FileMap(); - /// @brief Registers a file. Files must be registered before they can be used with rocFile IO APIs + /// @brief Registers a file. Files must be registered before they can be used with hipFile IO APIs /// @attention A unique_lock on HipFileMutex must be held /// @param uf An unregistered file virtual hipFileHandle_t registerFile(const UnregisteredFile &uf); diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp deleted file mode 100644 index 40f9b110..00000000 --- a/hipfile/src/amd_detail/hipfile.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved. - * - * SPDX-License-Identifier: MIT - */ - -#include "hipfile.h" -#include "hipfile-private.h" - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -hipFileError_t -hipFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) -try { - return rocFileHandleRegister(fh, descr); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -void -hipFileHandleDeregister(hipFileHandle_t fh) -{ - (void)rocFileHandleDeregister(fh); -} - -hipFileError_t -hipFileBufRegister(const void *buffer_base, size_t length, int flags) -try { - return rocFileBufRegister(buffer_base, length, flags); -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -hipFileError_t -hipFileBufDeregister(const void *buffer_base) -try { - auto error = rocFileBufDeregister(buffer_base); - if (error.err == hipFileDriverNotInitialized) { - error.err = hipFileDriverClosing; - } - return error; -} -catch (...) { - return {hipFileInternalError, hipSuccess}; -} - -ssize_t -hipFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) -{ - auto result = rocFileRead(fh, buffer_base, size, file_offset, buffer_offset); - if (result == -hipFileDriverNotInitialized) { - // Match cuFile behaviour - errno = EINVAL; - result = -1; - } - return result; -} - -ssize_t -hipFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, - hoff_t buffer_offset) -{ - auto result = rocFileWrite(fh, buffer_base, size, file_offset, buffer_offset); - if (result == -hipFileDriverNotInitialized) { - // Match cuFile behaviour - errno = EINVAL; - result = -1; - } - return result; -} diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/rocfile.cpp index 7a8db0d0..f6d037ea 100644 --- a/hipfile/src/amd_detail/rocfile.cpp +++ b/hipfile/src/amd_detail/rocfile.cpp @@ -44,7 +44,7 @@ catch (...) { } hipFileError_t -rocFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) +hipFileHandleRegister(hipFileHandle_t *fh, hipFileDescr_t *descr) try { if (fh == nullptr || descr == nullptr) { return {hipFileInvalidValue, hipSuccess}; @@ -69,31 +69,22 @@ catch (...) { return handle_exception(); } -hipFileError_t -rocFileHandleDeregister(hipFileHandle_t fh) +void +hipFileHandleDeregister(hipFileHandle_t fh) try { if (fh == nullptr) { - return {hipFileInvalidValue, hipSuccess}; + return; } Context::get()->deregisterFile(fh); - return {hipFileSuccess, hipSuccess}; -} -catch (const DriverNotInitialized &) { - return {hipFileDriverNotInitialized, hipSuccess}; -} -catch (const FileOperationsOutstanding &) { - return {hipFileInternalError, hipSuccess}; -} -catch (const FileNotRegistered &) { - return {hipFileHandleNotRegistered, hipSuccess}; + return; } catch (...) { - return handle_exception(); + return; } hipFileError_t -rocFileBufRegister(const void *buffer_base, size_t length, int flags) +hipFileBufRegister(const void *buffer_base, size_t length, int flags) try { Context::get()->registerBuffer(buffer_base, length, flags); return {hipFileSuccess, hipSuccess}; @@ -121,13 +112,15 @@ catch (...) { } hipFileError_t -rocFileBufDeregister(const void *buffer_base) +hipFileBufDeregister(const void *buffer_base) try { Context::get()->deregisterBuffer(buffer_base); return {hipFileSuccess, hipSuccess}; } catch (const DriverNotInitialized &) { - return {hipFileDriverNotInitialized, hipSuccess}; + // Mimic cuFile and return hipFileDriverClosing instead + // of hipFileDrivernotInitialized + return {hipFileDriverClosing, hipSuccess}; } catch (const BufferNotRegistered &) { return {hipFileMemoryNotRegistered, hipSuccess}; @@ -207,16 +200,32 @@ catch (...) { } ssize_t -rocFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) +hipFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) { - return hipFileIo(IoType::Read, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); + auto result = + hipFileIo(IoType::Read, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); + + if (result == -hipFileDriverNotInitialized) { + // Match cuFile behaviour + errno = EINVAL; + result = -1; + } + return result; } ssize_t -rocFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, +hipFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset) { - return hipFileIo(IoType::Write, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); + auto result = + hipFileIo(IoType::Write, fh, buffer_base, size, file_offset, buffer_offset, getCachedBackends()); + + if (result == -hipFileDriverNotInitialized) { + // Match cuFile behaviour + errno = EINVAL; + result = -1; + } + return result; } hipFileError_t diff --git a/hipfile/src/amd_detail/state.cpp b/hipfile/src/amd_detail/state.cpp index d9479ee2..f4452624 100644 --- a/hipfile/src/amd_detail/state.cpp +++ b/hipfile/src/amd_detail/state.cpp @@ -187,7 +187,7 @@ DriverState::getStream(hipStream_t hip_stream) // Buffer and file calls // // These are for reducing the number of lock calls and are implemented -// as needed for the rocFile code +// as needed for the hipFile code // file_buffer_pair diff --git a/hipfile/src/amd_detail/state.h b/hipfile/src/amd_detail/state.h index 15f6e577..803ae695 100644 --- a/hipfile/src/amd_detail/state.h +++ b/hipfile/src/amd_detail/state.h @@ -44,7 +44,7 @@ struct file_buffer_stream_tuple { std::shared_ptr stream; }; -// rocFile "state" +// hipFile "state" // // Important for: // @@ -113,9 +113,9 @@ class DriverState { // File interface // - /// @brief Registers a file. Files must be registered before they can be used with rocFile IO APIs + /// @brief Registers a file. Files must be registered before they can be used with hipFile IO APIs /// @param [in] uf An unregistered file - /// @return A handle to be used when calling rocFile IO APIs + /// @return A handle to be used when calling hipFile IO APIs virtual hipFileHandle_t registerFile(const UnregisteredFile &uf); /// @brief Deregisters the file associated with the provided file handle @@ -150,7 +150,7 @@ class DriverState { // Buffer and file calls // // These are for reducing the number of lock calls and are implemented - // as needed for the rocFile code + // as needed for the hipFile code // /// @brief Look up a file and registered buffer diff --git a/hipfile/test/amd_detail/async.cpp b/hipfile/test/amd_detail/async.cpp index 8d93b76c..9a0c18bc 100644 --- a/hipfile/test/amd_detail/async.cpp +++ b/hipfile/test/amd_detail/async.cpp @@ -73,7 +73,7 @@ struct HipFileAsyncMonitor : HipFileAsyncOp { }; static auto -rocfileFlagsPowerSet() +hipfileFlagsPowerSet() { return Combine(Values(0, HIPFILE_STREAM_FIXED_BUF_OFFSET), Values(0, HIPFILE_STREAM_FIXED_FILE_OFFSET), Values(0, HIPFILE_STREAM_FIXED_FILE_SIZE), Values(0, HIPFILE_STREAM_PAGE_ALIGNED_INPUTS)); @@ -131,7 +131,7 @@ TEST_P(HipFileAsyncOpStreamParams, asyncOp_construction_has_correct_variants) EXPECT_NO_THROW(std::get(op->size)); } } -INSTANTIATE_TEST_SUITE_P(StreamSuite, HipFileAsyncOpStreamParams, rocfileFlagsPowerSet()); +INSTANTIATE_TEST_SUITE_P(StreamSuite, HipFileAsyncOpStreamParams, hipfileFlagsPowerSet()); TEST_F(HipFileAsyncOp, AsyncOpFallback_new_uses_pinned_host_memory) { diff --git a/hipfile/test/amd_detail/batch/batch_mt.cpp b/hipfile/test/amd_detail/batch/batch_mt.cpp index ffc2ebf3..c50d4381 100644 --- a/hipfile/test/amd_detail/batch/batch_mt.cpp +++ b/hipfile/test/amd_detail/batch/batch_mt.cpp @@ -3,7 +3,7 @@ * SPDX-License-Identifier: MIT */ -// Multithreading stress test for rocFile's batch context map +// Multithreading stress test for hipFile's batch context map // // Just run the program. It takes no special arguments. // diff --git a/hipfile/test/amd_detail/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp index 95daa56b..7c1e8bf7 100644 --- a/hipfile/test/amd_detail/buffer.cpp +++ b/hipfile/test/amd_detail/buffer.cpp @@ -60,7 +60,7 @@ TEST_F(HipFileBuffer, register_supported_hip_memory) for (const auto memoryType : SupportedHipMemoryTypes) { StrictMock mhip; expect_buffer_registration(mhip, memoryType); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); } } @@ -82,7 +82,7 @@ TEST_F(HipFileBuffer, register_unsupported_hip_memory) hipPointerAttribute_t attrs{}; attrs.type = memoryType; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileHipMemoryTypeInvalid)); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileHipMemoryTypeInvalid)); } } @@ -97,19 +97,19 @@ TEST_F(HipFileBuffer, register_hip_pointer_get_attributes_error) { StrictMock mhip; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Throw(Hip::RuntimeError(hipErrorUnknown))); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileHipError(hipErrorUnknown)); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HipFileHipError(hipErrorUnknown)); // hipErrorInvalidValue is handled differently to match the behaviour of cufile EXPECT_CALL(mhip, hipPointerGetAttributes) .WillOnce(testing::Throw(Hip::RuntimeError(hipErrorInvalidValue))); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileInvalidValue)); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileInvalidValue)); } TEST_F(HipFileBuffer, register_internal_already_registered) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); ASSERT_THROW(Context::get()->registerBuffer(nonnull_ptr, 0, 0), BufferAlreadyRegistered); } @@ -117,13 +117,13 @@ TEST_F(HipFileBuffer, register_already_registered) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileMemoryAlreadyRegistered)); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HipFileOpError(hipFileMemoryAlreadyRegistered)); } TEST_F(HipFileBuffer, registerNullPointerReturnsError) { - ASSERT_EQ(rocFileBufRegister(nullptr, 0x10000, 0), HipFileOpError(hipFileInvalidValue)); + ASSERT_EQ(hipFileBufRegister(nullptr, 0x10000, 0), HipFileOpError(hipFileInvalidValue)); } TEST_F(HipFileBuffer, registerOversizeRangeReturnsError) @@ -134,7 +134,7 @@ TEST_F(HipFileBuffer, registerOversizeRangeReturnsError) hipPointerAttribute_t attrs{}; attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 101, 0), + ASSERT_EQ(hipFileBufRegister(reinterpret_cast(0x1), 101, 0), HipFileOpError(hipFileHipPointerRangeError)); } @@ -145,7 +145,7 @@ TEST_F(HipFileBuffer, registerHipMemGetAddressRangeThrowReturnsError) hipPointerAttribute_t attrs{}; attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 100, 0), HipFileOpError(hipFileInvalidValue)); + ASSERT_EQ(hipFileBufRegister(reinterpret_cast(0x1), 100, 0), HipFileOpError(hipFileInvalidValue)); } TEST_F(HipFileBuffer, registerOverflowingRangeReturnsError) @@ -156,7 +156,7 @@ TEST_F(HipFileBuffer, registerOverflowingRangeReturnsError) hipPointerAttribute_t attrs{}; attrs.type = hipMemoryTypeDevice; EXPECT_CALL(mhip, hipPointerGetAttributes).WillOnce(testing::Return(attrs)); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0xFFFF0000), 0x10000, 0), + ASSERT_EQ(hipFileBufRegister(reinterpret_cast(0xFFFF0000), 0x10000, 0), HipFileOpError(hipFileHipPointerRangeError)); } @@ -167,7 +167,7 @@ TEST_F(HipFileBuffer, deregister_internal_not_registered) TEST_F(HipFileBuffer, deregister_not_registered) { - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); + ASSERT_EQ(hipFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); } TEST_F(HipFileBuffer, deregister_internal) @@ -182,8 +182,8 @@ TEST_F(HipFileBuffer, deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); } TEST_F(HipFileBuffer, deregister_internal_duplicate_deregister) @@ -199,9 +199,9 @@ TEST_F(HipFileBuffer, deregister_duplicate_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileMemoryNotRegistered)); } TEST_F(HipFileBuffer, deregister_internal_get_prevents_deregister) @@ -220,12 +220,12 @@ TEST_F(HipFileBuffer, deregister_get_prevents_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); { auto buffer = Context::get()->getBuffer(nonnull_ptr); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileInternalError)); + ASSERT_EQ(hipFileBufDeregister(nonnull_ptr), HipFileOpError(hipFileInternalError)); } - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); } TEST_F(HipFileBuffer, get_not_registered) @@ -245,7 +245,7 @@ TEST_F(HipFileBuffer, get_after_register) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); auto buffer = Context::get()->getBuffer(nonnull_ptr); } @@ -262,8 +262,8 @@ TEST_F(HipFileBuffer, get_after_deregister) { StrictMock mhip; expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(nonnull_ptr, 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufDeregister(nonnull_ptr), HIPFILE_SUCCESS); ASSERT_THROW(Context::get()->getBuffer(nonnull_ptr), BufferNotRegistered); } diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index 7baae2a6..260796f9 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -27,7 +27,7 @@ HIPFILE_WARN_NO_GLOBAL_CTOR_OFF struct HipFileDriverAdmin : public HipFileUnopened {}; -// Ensure that rocFileOpen() and rocFileClose() increment and +// Ensure that hipFileOpen() and hipFileClose() increment and // decrement the reference count TEST_F(HipFileDriverAdmin, OpenClose) { @@ -48,7 +48,7 @@ TEST_F(HipFileDriverAdmin, OpenClose) ASSERT_EQ(hipFileUseCount(), 0); } -// Ensure rocFileHandleRegister() initializes the driver +// Ensure hipFileHandleRegister() initializes the driver // and DOES bump the reference count TEST_F(HipFileDriverAdmin, HandleRegisterInitsDriver) { @@ -64,11 +64,11 @@ TEST_F(HipFileDriverAdmin, HandleRegisterInitsDriver) ASSERT_EQ(hipFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 1); } -// Ensure rocFileHandleRegister() handles a file descriptor +// Ensure hipFileHandleRegister() handles a file descriptor // of zero (technically a legal POSIX value) and DOES bump // the reference count TEST_F(HipFileDriverAdmin, HandleRegisterGoodFD) @@ -86,13 +86,13 @@ TEST_F(HipFileDriverAdmin, HandleRegisterGoodFD) expect_file_registration(msys, mlibmounthelper); ASSERT_EQ(hipFileUseCount(), 0); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 1); - ASSERT_EQ(rocFileHandleDeregister(handle), HIPFILE_SUCCESS); + hipFileHandleDeregister(handle); ASSERT_EQ(hipFileUseCount(), 1); } -// Ensure rocFileHandleRegister() fails when passed a negative file +// Ensure hipFileHandleRegister() fails when passed a negative file // descriptor and does NOT bump the reference count TEST_F(HipFileDriverAdmin, HandleRegisterBadFD) { @@ -108,12 +108,12 @@ TEST_F(HipFileDriverAdmin, HandleRegisterBadFD) EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); ASSERT_EQ(hipFileUseCount(), 0); - ASSERT_NE(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); + ASSERT_NE(hipFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 0); } -// Ensure rocFileHandleDeregister() fails when passed a NULL or -// unregistered pointer and does NOT bump the driver reference count +// Ensure hipFileHandleDeregister() does NOT bump the driver reference +// count when passed a NULL or unregistered pointer TEST_F(HipFileDriverAdmin, HandleDeregisterDoesNotInitDriver) { StrictMock msys{}; @@ -121,14 +121,14 @@ TEST_F(HipFileDriverAdmin, HandleDeregisterDoesNotInitDriver) // Check NULL ASSERT_EQ(hipFileUseCount(), 0); - ASSERT_NE(rocFileHandleDeregister(nullptr), HIPFILE_SUCCESS); + hipFileHandleDeregister(nullptr); ASSERT_EQ(hipFileUseCount(), 0); // Check unregistered handle hipFileHandle_t handle{}; ASSERT_EQ(hipFileUseCount(), 0); - ASSERT_NE(rocFileHandleDeregister(handle), HIPFILE_SUCCESS); + hipFileHandleDeregister(handle); ASSERT_EQ(hipFileUseCount(), 0); } @@ -149,12 +149,12 @@ TEST_F(HipFileDriverAdmin, CloseDeregistersFile) ASSERT_EQ(hipFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 1); ASSERT_EQ(hipFileDriverClose(), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 0); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileHandleRegister(&handle, &descr), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 1); } @@ -167,16 +167,16 @@ TEST_F(HipFileDriverAdmin, BufRegisterInitsDriver) expect_buffer_registration(mhip, hipMemoryTypeDevice); ASSERT_EQ(hipFileUseCount(), 0); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 1); } // Ensure that buffer deregistration does not increment the driver -// reference count +// reference count (the odd error mimics cuFile) TEST_F(HipFileDriverAdmin, BufDeregisterDoesNotInitDriver) { ASSERT_EQ(hipFileUseCount(), 0); - ASSERT_EQ(rocFileBufDeregister(nullptr), HipFileOpError(hipFileDriverNotInitialized)); + ASSERT_EQ(hipFileBufDeregister(nullptr), HipFileOpError(hipFileDriverClosing)); ASSERT_EQ(hipFileUseCount(), 0); } @@ -189,14 +189,14 @@ TEST_F(HipFileDriverAdmin, CloseDeregistersBuffer) ASSERT_EQ(hipFileUseCount(), 0); expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 1); ASSERT_EQ(hipFileDriverClose(), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 0); expect_buffer_registration(mhip, hipMemoryTypeDevice); - ASSERT_EQ(rocFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileBufRegister(reinterpret_cast(0x1), 0, 0), HIPFILE_SUCCESS); ASSERT_EQ(hipFileUseCount(), 1); } @@ -221,23 +221,21 @@ TEST_F(HipFileDriverAdmin, WriteAsyncInitsDriver) ASSERT_EQ(hipFileUseCount(), 1); } -// Ensure rocFileRead(): -// * Returns hipFileDriverNotInitialized when called w/o a driver init -// (the weird negative sign is a quirk of returning a ssize_t) +// Ensure hipFileRead(): +// * Returns -1 (like cuFile) when called w/o a driver init // * Does NOT initialize the driver and returns a reference count of 0 TEST_F(HipFileDriverAdmin, ReadDoesNotInitsDriver) { - ASSERT_EQ(rocFileRead(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); + ASSERT_EQ(hipFileRead(nullptr, nullptr, 0, 0, 0), -1); ASSERT_EQ(hipFileUseCount(), 0); } -// Ensure rocFileWrite(): -// * Returns hipFileDriverNotInitialized when called w/o a driver init -// (the weird negative sign is a quirk of returning a ssize_t) +// Ensure hipFileWrite(): +// * Returns -1 (like cuFile) when called w/o a driver init // * Does NOT initialize the driver and returns a reference count of 0 TEST_F(HipFileDriverAdmin, WriteDoesNotInitDriver) { - ASSERT_EQ(rocFileWrite(nullptr, nullptr, 0, 0, 0), -hipFileDriverNotInitialized); + ASSERT_EQ(hipFileWrite(nullptr, nullptr, 0, 0, 0), -1); ASSERT_EQ(hipFileUseCount(), 0); } diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index eb238583..545fc2bb 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -104,11 +104,11 @@ TEST_F(HipFileHandle, register_handle_linux_fd) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); ASSERT_NE(fh, nullptr); } -// If statx() fails during file registration return rocfileInternalError +// If statx() fails during file registration return hipfileInternalError TEST_F(HipFileHandle, RocfileHandleRegisterStatxError) { hipFileHandle_t fh{}; @@ -118,10 +118,10 @@ TEST_F(HipFileHandle, RocfileHandleRegisterStatxError) EXPECT_CALL(msys, statx).WillOnce(Throw(Sys::RuntimeError(EBADF))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); } -// If the fcntl() fails during file registration return rocfileInternalError +// If the fcntl() fails during file registration return hipfileInternalError TEST_F(HipFileHandle, RocfileHandleRegisterFcntlError) { hipFileHandle_t fh{}; @@ -132,10 +132,10 @@ TEST_F(HipFileHandle, RocfileHandleRegisterFcntlError) EXPECT_CALL(msys, statx); EXPECT_CALL(msys, fcntl).WillOnce(Throw(Sys::RuntimeError(EBADF))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); } -// If getting mount information fails during file registration return rocfileInternalError +// If getting mount information fails during file registration return hipfileInternalError TEST_F(HipFileHandle, RocfileHandleRegisterLibMountError) { hipFileHandle_t fh{}; @@ -147,7 +147,7 @@ TEST_F(HipFileHandle, RocfileHandleRegisterLibMountError) EXPECT_CALL(msys, fcntl); EXPECT_CALL(mlibmounthelper, getMountInfo).WillOnce(Throw(std::runtime_error("error from test"))); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileInternalError)); } TEST_F(HipFileHandle, register_handle_linux_fd_already_registered) @@ -159,10 +159,10 @@ TEST_F(HipFileHandle, register_handle_linux_fd_already_registered) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); ASSERT_NE(fh, nullptr); expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileHandleAlreadyRegistered)); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileHandleAlreadyRegistered)); } TEST_F(HipFileHandle, register_handle_windows_handle_not_supported) @@ -173,7 +173,7 @@ TEST_F(HipFileHandle, register_handle_windows_handle_not_supported) rfd.type = hipFileHandleTypeOpaqueWin32; rfd.handle.fd = 0xBADF00D; - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); } TEST_F(HipFileHandle, register_handle_userspace_fs_not_supported) @@ -184,7 +184,7 @@ TEST_F(HipFileHandle, register_handle_userspace_fs_not_supported) rfd.type = hipFileHandleTypeUserspaceFS; rfd.handle.fd = 0xBADF00D; - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HipFileOpError(hipFileIONotSupported)); } TEST_F(HipFileHandle, deregister_handle_internal_throws_if_not_registered) @@ -193,10 +193,9 @@ TEST_F(HipFileHandle, deregister_handle_internal_throws_if_not_registered) FileNotRegistered); } -TEST_F(HipFileHandle, deregister_handle_returns_error_if_not_registered) +TEST_F(HipFileHandle, deregister_handle_doesnt_throw_if_not_registered) { - ASSERT_EQ(rocFileHandleDeregister(reinterpret_cast(0xdeadbeef)), - HipFileOpError(hipFileHandleNotRegistered)); + hipFileHandleDeregister(reinterpret_cast(0xdeadbeef)); } TEST_F(HipFileHandle, deregister_handle_internal) @@ -216,9 +215,9 @@ TEST_F(HipFileHandle, deregister_handle) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileHandleDeregister(fh), HIPFILE_SUCCESS); - ASSERT_EQ(rocFileHandleDeregister(fh), HipFileOpError(hipFileHandleNotRegistered)); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); + hipFileHandleDeregister(fh); + hipFileHandleDeregister(fh); } TEST_F(HipFileHandle, deregister_handle_internal_fails_when_operations_are_oustanding) @@ -241,12 +240,12 @@ TEST_F(HipFileHandle, deregister_handle_fails_when_operations_are_oustanding) rfd.handle.fd = 0xBADF00D; expect_file_registration(msys, mlibmounthelper); - ASSERT_EQ(rocFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); + ASSERT_EQ(hipFileHandleRegister(&fh, &rfd), HIPFILE_SUCCESS); { auto file = Context::get()->getFile(fh); - ASSERT_EQ(rocFileHandleDeregister(fh), HipFileOpError(hipFileInternalError)); + hipFileHandleDeregister(fh); } - ASSERT_EQ(rocFileHandleDeregister(fh), HIPFILE_SUCCESS); + hipFileHandleDeregister(fh); } HIPFILE_WARN_NO_GLOBAL_CTOR_ON diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/rocfile.cpp index 171f6923..1225265b 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/rocfile.cpp @@ -4,8 +4,8 @@ */ /* - * These tests are integration-level tests against the rocFile API. - * They should test that the various rocFile modules are compatible with + * These tests are integration-level tests against the hipFile API. + * They should test that the various hipFile modules are compatible with * one another. Running IO is not intended to be guaranteed to run here. * * All tests in this file are expected to pass on a CPU-only node. @@ -128,7 +128,7 @@ TEST_F(HipFileUnit, TestHipFileBatchIOSubmitBadArgument) ASSERT_EQ(result, HIPFILE_INVALID_VALUE); } -/// @brief Test rocFileIO function +/// @brief Test hipFileIO function struct HipFileIoParam : public TestWithParam { hipFileHandle_t file_handle{}; void *bufptr{reinterpret_cast(0xDEC0DE)}; @@ -247,11 +247,11 @@ TEST_P(HipFileIoBackendSelectionParam, HipFileIoThrowsIfThereAreNoBackends) switch (io_type) { case IoType::Read: - ASSERT_EQ(rocFileRead(handle, buffer, io_size, file_offset, buffer_offset), + ASSERT_EQ(hipFileRead(handle, buffer, io_size, file_offset, buffer_offset), -hipFileInternalError); break; case IoType::Write: - ASSERT_EQ(rocFileWrite(handle, buffer, io_size, file_offset, buffer_offset), + ASSERT_EQ(hipFileWrite(handle, buffer, io_size, file_offset, buffer_offset), -hipFileInternalError); break; default: @@ -275,11 +275,11 @@ TEST_P(HipFileIoBackendSelectionParam, HipFileIoThrowsIfAllBackendsRejectTheIO) switch (io_type) { case IoType::Read: - ASSERT_EQ(rocFileRead(handle, buffer, io_size, file_offset, buffer_offset), + ASSERT_EQ(hipFileRead(handle, buffer, io_size, file_offset, buffer_offset), -hipFileInternalError); break; case IoType::Write: - ASSERT_EQ(rocFileWrite(handle, buffer, io_size, file_offset, buffer_offset), + ASSERT_EQ(hipFileWrite(handle, buffer, io_size, file_offset, buffer_offset), -hipFileInternalError); break; default: @@ -306,13 +306,13 @@ TEST_P(HipFileIoBackendSelectionParam, HipFileIoIssuesIoToHighestScoringBackend) EXPECT_CALL(*mbe2, io(Eq(IoType::Read), Eq(mfile), Eq(mbuffer), io_size, file_offset, buffer_offset)) .WillOnce(Return(io_size)); - ASSERT_EQ(rocFileRead(handle, buffer, io_size, file_offset, buffer_offset), io_size); + ASSERT_EQ(hipFileRead(handle, buffer, io_size, file_offset, buffer_offset), io_size); break; case IoType::Write: EXPECT_CALL(*mbe2, io(Eq(IoType::Write), Eq(mfile), Eq(mbuffer), io_size, file_offset, buffer_offset)) .WillOnce(Return(io_size)); - ASSERT_EQ(rocFileWrite(handle, buffer, io_size, file_offset, buffer_offset), io_size); + ASSERT_EQ(hipFileWrite(handle, buffer, io_size, file_offset, buffer_offset), io_size); break; default: FAIL() << "Unhandled IO Type"; diff --git a/hipfile/test/amd_detail/state_mt.cpp b/hipfile/test/amd_detail/state_mt.cpp index 4c9d644d..e24e4e66 100644 --- a/hipfile/test/amd_detail/state_mt.cpp +++ b/hipfile/test/amd_detail/state_mt.cpp @@ -3,7 +3,7 @@ * SPDX-License-Identifier: MIT */ -// Multithreading stress test for rocFile's global state +// Multithreading stress test for hipFile's global state // // Just run the program. It takes no special arguments. diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index 17c68923..c31f7e58 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -27,7 +27,7 @@ using ::testing::StrictMock; HIPFILE_WARN_NO_GLOBAL_CTOR_OFF static auto -rocFileFlagsPowerSet() +hipFileFlagsPowerSet() { return ::testing::Combine(::testing::Values(0, HIPFILE_STREAM_FIXED_BUF_OFFSET), ::testing::Values(0, HIPFILE_STREAM_FIXED_FILE_OFFSET), @@ -65,7 +65,7 @@ TEST_P(HipFileStreamValidParams, register_stream_valid_flags_internal) ASSERT_EQ(stream->getHipStream(), nonnull_stream); } -INSTANTIATE_TEST_SUITE_P(StreamSuite, HipFileStreamValidParams, rocFileFlagsPowerSet()); +INSTANTIATE_TEST_SUITE_P(StreamSuite, HipFileStreamValidParams, hipFileFlagsPowerSet()); TEST_F(HipFileStream, get_stream_with_unregistered_stream_works) { From 51f0aacfec524541814238041026fc54161303c9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:05:20 -0700 Subject: [PATCH 40/48] Rename rocfile.cpp --> hipfile.cpp --- hipfile/src/amd_detail/CMakeLists.txt | 2 +- hipfile/src/amd_detail/{rocfile.cpp => hipfile.cpp} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename hipfile/src/amd_detail/{rocfile.cpp => hipfile.cpp} (100%) diff --git a/hipfile/src/amd_detail/CMakeLists.txt b/hipfile/src/amd_detail/CMakeLists.txt index fd99748c..03c67855 100644 --- a/hipfile/src/amd_detail/CMakeLists.txt +++ b/hipfile/src/amd_detail/CMakeLists.txt @@ -15,9 +15,9 @@ set(HIPFILE_SOURCES context.cpp file.cpp hip.cpp + hipfile.cpp hipfile-private.cpp mountinfo.cpp - rocfile.cpp state.cpp stream.cpp sys.cpp diff --git a/hipfile/src/amd_detail/rocfile.cpp b/hipfile/src/amd_detail/hipfile.cpp similarity index 100% rename from hipfile/src/amd_detail/rocfile.cpp rename to hipfile/src/amd_detail/hipfile.cpp From b49d030e751cda38a9d04d10e91044bd67aa5cf8 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:12:05 -0700 Subject: [PATCH 41/48] Rename rocfile tests to internal --- INSTALL.md | 4 ++-- hipfile/test/amd_detail/CMakeLists.txt | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f78dfd63..bca12e90 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -57,9 +57,9 @@ Sanitizer options `ctest .` will run all tests. -You can filter on test labels using the `-L` option. We currently have `hipfile` and `rocfile` labels for each library and `unit`, `system`, and `stress` labels for the different test types. Multiple `-L` options form an *and*. A `|` can be used for an *or*. +You can filter on test labels using the `-L` option. We currently have `hipfile` and `internal` labels for the public API and its internals, respectively, and `unit`, `system`, and `stress` labels for the different test types. Multiple `-L` options form an *and*. A `|` can be used for an *or*. -`ctest . -L rocfile -L unit` runs all unit tests in the rocFile library. +`ctest . -L internal -L unit` runs all the internal library unit tests. `ctest . -L 'system|unit'` runs all system or unit tests. You can filter on test names using the `-R` option. This option supports wildcards. diff --git a/hipfile/test/amd_detail/CMakeLists.txt b/hipfile/test/amd_detail/CMakeLists.txt index 8b5d153d..cccb81ce 100644 --- a/hipfile/test/amd_detail/CMakeLists.txt +++ b/hipfile/test/amd_detail/CMakeLists.txt @@ -32,22 +32,22 @@ set(TEST_SYSINCLS ) ais_add_executable( - NAME rocfile_tests + NAME internal_tests DEPS hipfile_shared SRCS ${TEST_SOURCE_FILES} ${SHARED_SOURCE_FILES} SYSINCLS ${TEST_SYSINCLS} ) -target_compile_options(rocfile_tests PRIVATE "-UNDEBUG") +target_compile_options(internal_tests PRIVATE "-UNDEBUG") # Add gtest -target_link_libraries(rocfile_tests PRIVATE GTest::gmock) -target_link_libraries(rocfile_tests PRIVATE GTest::gtest) -target_link_libraries(rocfile_tests PRIVATE GTest::gtest_main) +target_link_libraries(internal_tests PRIVATE GTest::gmock) +target_link_libraries(internal_tests PRIVATE GTest::gtest) +target_link_libraries(internal_tests PRIVATE GTest::gtest_main) ais_gtest_discover_tests( - rocfile_tests - PROPERTIES "LABELS;unit;LABELS;rocfile" - TEST_LIST rocfile_unit_tests + internal_tests + PROPERTIES "LABELS;unit;LABELS;internal" + TEST_LIST internal_unit_tests ) # The following tests are concurrency testers. They run for a short @@ -66,7 +66,7 @@ add_test( NAME state_mt_test COMMAND gdb --batch --quiet -ex run -ex "thread apply all bt full" --return-child-result --args $ ) -set_tests_properties(state_mt_test PROPERTIES LABELS "stress;rocfile") +set_tests_properties(state_mt_test PROPERTIES LABELS "stress;internal") ais_add_executable( NAME batch_mt @@ -78,4 +78,4 @@ add_test( NAME batch_mt_test COMMAND gdb --batch --quiet -ex run -ex "thread apply all bt full" --return-child-result --args $ ) -set_tests_properties(batch_mt_test PROPERTIES LABELS "stress;rocfile") +set_tests_properties(batch_mt_test PROPERTIES LABELS "stress;internal") From 8fdce794c0e960c1cc88cbee626a2ad677c204dd Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:22:32 -0700 Subject: [PATCH 42/48] Rename a few test files --- hipfile/test/amd_detail/CMakeLists.txt | 2 +- hipfile/test/amd_detail/batch/batch.cpp | 2 +- hipfile/test/amd_detail/buffer.cpp | 2 +- hipfile/test/amd_detail/driver.cpp | 2 +- hipfile/test/amd_detail/fallback.cpp | 2 +- hipfile/test/amd_detail/fastpath.cpp | 2 +- hipfile/test/amd_detail/handle.cpp | 2 +- hipfile/test/amd_detail/{rocfile.cpp => hipfile-api.cpp} | 2 +- hipfile/test/amd_detail/{rocfile-test.h => hipfile-test.h} | 1 - hipfile/test/amd_detail/stream.cpp | 2 +- 10 files changed, 9 insertions(+), 10 deletions(-) rename hipfile/test/amd_detail/{rocfile.cpp => hipfile-api.cpp} (99%) rename hipfile/test/amd_detail/{rocfile-test.h => hipfile-test.h} (99%) diff --git a/hipfile/test/amd_detail/CMakeLists.txt b/hipfile/test/amd_detail/CMakeLists.txt index cccb81ce..a651ffa8 100644 --- a/hipfile/test/amd_detail/CMakeLists.txt +++ b/hipfile/test/amd_detail/CMakeLists.txt @@ -17,10 +17,10 @@ set(TEST_SOURCE_FILES driver.cpp handle.cpp hip.cpp + hipfile-api.cpp fallback.cpp fastpath.cpp mountinfo.cpp - rocfile.cpp stream.cpp ) diff --git a/hipfile/test/amd_detail/batch/batch.cpp b/hipfile/test/amd_detail/batch/batch.cpp index 0e5039ea..1c1c0044 100644 --- a/hipfile/test/amd_detail/batch/batch.cpp +++ b/hipfile/test/amd_detail/batch/batch.cpp @@ -7,12 +7,12 @@ #include "buffer.h" #include "file.h" #include "hipfile.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "invalid-enum.h" #include "mbuffer.h" #include "mfile.h" #include "mstate.h" -#include "rocfile-test.h" #include "state.h" #include diff --git a/hipfile/test/amd_detail/buffer.cpp b/hipfile/test/amd_detail/buffer.cpp index 7c1e8bf7..0eb34880 100644 --- a/hipfile/test/amd_detail/buffer.cpp +++ b/hipfile/test/amd_detail/buffer.cpp @@ -7,9 +7,9 @@ #include "context.h" #include "hip.h" #include "hipfile.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "mhip.h" -#include "rocfile-test.h" #include "state.h" #include diff --git a/hipfile/test/amd_detail/driver.cpp b/hipfile/test/amd_detail/driver.cpp index 260796f9..636fb79c 100644 --- a/hipfile/test/amd_detail/driver.cpp +++ b/hipfile/test/amd_detail/driver.cpp @@ -4,11 +4,11 @@ */ #include "hipfile.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "mhip.h" #include "mmountinfo.h" #include "msys.h" -#include "rocfile-test.h" #include "sys.h" #include diff --git a/hipfile/test/amd_detail/fallback.cpp b/hipfile/test/amd_detail/fallback.cpp index e86da556..560a3faa 100644 --- a/hipfile/test/amd_detail/fallback.cpp +++ b/hipfile/test/amd_detail/fallback.cpp @@ -9,6 +9,7 @@ #include "context.h" #include "hip.h" #include "hipfile.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "io.h" #include "mbuffer.h" @@ -16,7 +17,6 @@ #include "mhip.h" #include "mmountinfo.h" #include "msys.h" -#include "rocfile-test.h" #include "state.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/fastpath.cpp b/hipfile/test/amd_detail/fastpath.cpp index 83d6ae21..9a3ca95d 100644 --- a/hipfile/test/amd_detail/fastpath.cpp +++ b/hipfile/test/amd_detail/fastpath.cpp @@ -5,12 +5,12 @@ #include "backend/fastpath.h" #include "hip.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "io.h" #include "mbuffer.h" #include "mfile.h" #include "mhip.h" -#include "rocfile-test.h" #include #include diff --git a/hipfile/test/amd_detail/handle.cpp b/hipfile/test/amd_detail/handle.cpp index 545fc2bb..a4ca5a73 100644 --- a/hipfile/test/amd_detail/handle.cpp +++ b/hipfile/test/amd_detail/handle.cpp @@ -6,11 +6,11 @@ #include "context.h" #include "file.h" #include "hipfile.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "msys.h" #include "mmountinfo.h" #include "mountinfo.h" -#include "rocfile-test.h" #include "state.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/rocfile.cpp b/hipfile/test/amd_detail/hipfile-api.cpp similarity index 99% rename from hipfile/test/amd_detail/rocfile.cpp rename to hipfile/test/amd_detail/hipfile-api.cpp index 1225265b..3b96e896 100644 --- a/hipfile/test/amd_detail/rocfile.cpp +++ b/hipfile/test/amd_detail/hipfile-api.cpp @@ -16,6 +16,7 @@ #include "hip.h" #include "hipfile.h" #include "hipfile-private.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "io.h" #include "mbackend.h" @@ -26,7 +27,6 @@ #include "mmountinfo.h" #include "mstate.h" #include "msys.h" -#include "rocfile-test.h" #include "state.h" #include "sys.h" diff --git a/hipfile/test/amd_detail/rocfile-test.h b/hipfile/test/amd_detail/hipfile-test.h similarity index 99% rename from hipfile/test/amd_detail/rocfile-test.h rename to hipfile/test/amd_detail/hipfile-test.h index 2d45f513..b6a72cf8 100644 --- a/hipfile/test/amd_detail/rocfile-test.h +++ b/hipfile/test/amd_detail/hipfile-test.h @@ -12,7 +12,6 @@ #include "mhip.h" #include "mmountinfo.h" #include "msys.h" -#include "rocfile-test.h" #include #include diff --git a/hipfile/test/amd_detail/stream.cpp b/hipfile/test/amd_detail/stream.cpp index c31f7e58..42959b7f 100644 --- a/hipfile/test/amd_detail/stream.cpp +++ b/hipfile/test/amd_detail/stream.cpp @@ -4,10 +4,10 @@ */ #include "hipfile.h" +#include "hipfile-test.h" #include "hipfile-warnings.h" #include "mhip.h" #include "msys.h" -#include "rocfile-test.h" #include "stream.h" #include From 3e395eb93db6c5ea15920434390c609efd959a73 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:25:35 -0700 Subject: [PATCH 43/48] Updated the changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d21d283f..8bb18d18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,11 @@ ### Changed ### Removed +* The rocFile library has been completelly removed and the code is now a part of hipFile. * The hipify patch was removed. You can get hipify with hipFile support at https://github.com/derobins/HIPIFY/tree/hipFile. ### Limitations -* The batch API calls are not supported w/ a rocFile backend -* The async API calls are not supported w/ a rocFile backend +* The batch API calls are not supported w/ an AMD backend +* The async API calls are not supported w/ an AMD backend ### Known issues From 5db6799d1f074810cab7be8d7e8fe26cdea3a7bb Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:27:22 -0700 Subject: [PATCH 44/48] Update fastpath comment --- hipfile/src/amd_detail/backend/fastpath.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hipfile/src/amd_detail/backend/fastpath.cpp b/hipfile/src/amd_detail/backend/fastpath.cpp index 24e2c0a4..96fe4128 100644 --- a/hipfile/src/amd_detail/backend/fastpath.cpp +++ b/hipfile/src/amd_detail/backend/fastpath.cpp @@ -33,14 +33,14 @@ using namespace std; * - The buffer type is hipMemoryTypeDevice * * When using the fastpath the IO flows through the following - * - rocFile HIP wrapper (userspace) + * - hipFile HIP wrapper (userspace) * - repository: hipFile - * - file: rocfile/hip.cpp + * - file: hipfile/src/amd_detail/hip.cpp * - methods: Hip::hipAmdFileRead(...), Hip::hipAmdFileWrite(...) * - throws * - std::system_error if status is non-zero (set by kfd) * - Hip::runtime_error if hip runtime does not return hipSuccess or - * if rocFile was unable to find hipAmdFileRead/hipAmdFileWrite + * if hipFile was unable to find hipAmdFileRead/hipAmdFileWrite * - HIP Runtime (userspace) * - repository: rocm-systems * - file: projects/clr/hipamd/src/hip_storage.cpp From 8633bcf50422a7bca0cf16a5a600ee8ba7d9932d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:30:20 -0700 Subject: [PATCH 45/48] Remove rocfile from code coverage script --- util/llvm-coverage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/llvm-coverage.sh b/util/llvm-coverage.sh index f7fed53d..f5c1d2e6 100755 --- a/util/llvm-coverage.sh +++ b/util/llvm-coverage.sh @@ -48,5 +48,5 @@ if [ ! -s "$COV_FILES" ]; then fi llvm-profdata merge -output="$BUILD_DIR"/coverage.profdata --input-files="$COV_FILES" -llvm-cov report "$COLOR_ARG" -instr-profile="$BUILD_DIR"/coverage.profdata -object="$BUILD_DIR"/rocfile/src/librocfile.so -object="$BUILD_DIR"/hipfile/src/amd_detail/libhipfile.so >"$BUILD_DIR"/coverage-report.txt -llvm-cov show "$COLOR_ARG" -instr-profile="$BUILD_DIR"/coverage.profdata -object="$BUILD_DIR"/rocfile/src/librocfile.so -object="$BUILD_DIR"/hipfile/src/amd_detail/libhipfile.so >"$BUILD_DIR"/coverage-lines.txt +llvm-cov report "$COLOR_ARG" -instr-profile="$BUILD_DIR"/coverage.profdata -object="$BUILD_DIR"/hipfile/src/amd_detail/libhipfile.so >"$BUILD_DIR"/coverage-report.txt +llvm-cov show "$COLOR_ARG" -instr-profile="$BUILD_DIR"/coverage.profdata -object="$BUILD_DIR"/hipfile/src/amd_detail/libhipfile.so >"$BUILD_DIR"/coverage-lines.txt From 723a0fdee2b13b53b6d9e747c477aaa2ca61d7c9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:37:32 -0700 Subject: [PATCH 46/48] Misc cleanup --- .github/workflows/build-ais.yml | 18 +++++++++--------- CHANGELOG.md | 2 +- CMakeLists.txt | 6 ++---- CONTRIBUTING.md | 2 +- INSTALL.md | 10 +++++----- README.md | 4 ++-- SECURITY.md | 4 ++-- STYLEGUIDE.md | 2 +- cmake/AISInstall.cmake | 2 +- hipfile/docs/errors.rst | 2 +- 10 files changed, 25 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build-ais.yml b/.github/workflows/build-ais.yml index 62b7fff1..508d5f40 100644 --- a/.github/workflows/build-ais.yml +++ b/.github/workflows/build-ais.yml @@ -55,7 +55,7 @@ jobs: cp -R /mnt/ais /ais mkdir /ais/build ' - - name: Generate build files for hipFile and rocFile targeting the AMD platform (amdclang++) + - name: Generate build files for hipFile targeting the AMD platform (amdclang++) run: | docker exec \ -t \ @@ -70,7 +70,7 @@ jobs: -DBUILD_CODE_COVERAGE=ON \ .. ' - - name: Build hipFile and rocFile for the AMD platform (amdclang++) + - name: Build hipFile for the AMD platform (amdclang++) run: | docker exec \ -t \ @@ -79,7 +79,7 @@ jobs: /bin/bash -c ' cmake --build . --parallel ' - - name: Test hipFile and rocFile for the AMD platform (amdclang++) + - name: Test hipFile for the AMD platform (amdclang++) run: | docker exec \ -t \ @@ -157,7 +157,7 @@ jobs: cp -R /mnt/ais /ais mkdir /ais/build ' - - name: Generate build files for hipFile and rocFile targeting the AMD platform (${{ matrix.alternate_compilers }}) + - name: Generate build files for hipFile targeting the AMD platform (${{ matrix.alternate_compilers }}) run: | docker exec \ -t \ @@ -171,7 +171,7 @@ jobs: -DBUILD_AIS_DOCS=ON \ .. ' - - name: Build hipFile and rocFile for the AMD platform (${{ matrix.alternate_compilers }}) + - name: Build hipFile for the AMD platform (${{ matrix.alternate_compilers }}) run: | docker exec \ -t \ @@ -226,7 +226,7 @@ jobs: cp -R /mnt/ais /ais mkdir /ais/build ' - - name: Generate build files for hipFile and rocFile targeting the AMD platform (amdclang++) + - name: Generate build files for hipFile targeting the AMD platform (amdclang++) run: | docker exec \ -t \ @@ -240,7 +240,7 @@ jobs: -DBUILD_AIS_DOCS=ON \ .. ' - - name: Build hipFile and rocFile for the AMD platform (amdclang++) + - name: Build hipFile for the AMD platform (amdclang++) run: | docker exec \ -t \ @@ -249,7 +249,7 @@ jobs: /bin/bash -c ' cmake --build . --parallel ' - - name: Run hipFile and rocFile system tests for the AMD platform (amdclang++) + - name: Run hipFile system tests for the AMD platform (amdclang++) run: | docker exec \ -t \ @@ -258,7 +258,7 @@ jobs: /bin/bash -c ' ctest -V -L "system" --parallel ' - - name: Stress tests for hipFile and rocFile targeting the AMD platform (amdclang++) + - name: Stress tests for hipFile targeting the AMD platform (amdclang++) run: | docker exec \ -t \ diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bb18d18..00953a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Changelog for hipFile/rocFile +# Changelog for hipFile ## UNRELEASED - hipFile 0.2.0 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index 401c5dc8..070cefdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,6 @@ endif() # Set the library version in a variable so we can use # it in *.in files and avoid version mismatch. -# -# The versions number of rocFile and hipFile are identical set(AIS_LIBRARY_MAJOR 0) set(AIS_LIBRARY_MINOR 2) set(AIS_LIBRARY_PATCH 0) @@ -128,7 +126,7 @@ include(AISAddLibraries) #----------------------------------------------------------------------------- # Code coverage (via llvm-cov) # -# To use with the hipFile/rocFile libraries: +# To use with the hipFile library: # - Build with BUILD_CODE_COVERAGE set to ON # - Run `ctest .` # @@ -173,7 +171,7 @@ option(BUILD_AISCP "Build aiscp example program" ON) #------ # docs #------ -option(BUILD_AIS_DOCS "Build the rocFile/hipFile docs (requires Doxygen)" OFF) +option(BUILD_AIS_DOCS "Build the hipFile docs (requires Doxygen)" OFF) #----------------------------------------------------------------------------- # Find important packages for building the software diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9675b19a..ccfcfbed 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to hipFile/rocFile +# Contributing to hipFile Thank you for contributing! This guide outlines the development workflow, contribution standards, and best practices when working on hipFile. diff --git a/INSTALL.md b/INSTALL.md index bca12e90..278e0810 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,6 +1,6 @@ -# Install guide for hipFile / rocFile +# Install guide for hipFile -## Building hipFile and rocFile +## Building hipFile > [!NOTE] > hipFile is alpha software that has undergone testing on limited hardware. It may not work on your system at this time. @@ -64,11 +64,11 @@ You can filter on test labels using the `-L` option. We currently have `hipfile` You can filter on test names using the `-R` option. This option supports wildcards. -`ctest . -R RocFileBuffer.get_buffer_makes_temporary_buffer` runs the specified test. -`ctest . -R 'RocFileBuffer*'` runs all tests that start with RocFileBuffer. +`ctest . -R HipFileBuffer.get_buffer_makes_temporary_buffer` runs the specified test. +`ctest . -R 'HipFileBuffer*'` runs all tests that start with HipFileBuffer. ### Install and package -The hipFile and rocFile libraries can be installed with CMake. The default +The hipFile library can be installed with CMake. The default install prefix is still the CMake default of `/usr/local`. `cmake --install .` diff --git a/README.md b/README.md index acabae08..2e155d61 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# hipFile / rocFile +# hipFile > [!CAUTION] > This release is an *early-access* software technology preview. Running production workloads is *not* recommended. @@ -9,7 +9,7 @@ AMD Infinity Storage library that supports IO directly to the GPU -## Building hipFile and rocFile +## Building hipFile See the INSTALL.md file in the project root for a list of supported hardware and compilers as well as build and install instructions. diff --git a/SECURITY.md b/SECURITY.md index 04351502..01ca213b 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,8 +1,8 @@ # Security Policy ## Reporting a vulnerability -If you have discovered a security vulnerability in the hipFile or rocFile -libraries, please do NOT report it publicly using a GitHub issue. Instead, +If you have discovered a security vulnerability in the hipFile library, +please do NOT report it publicly using a GitHub issue. Instead, you should report the issue via the AMD Product Security website: https://www.amd.com/en/resources/product-security.html diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 6cd2212d..62766944 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -1,4 +1,4 @@ -# hipFile/rocFile Style Guide +# hipFile Style Guide ## File and Directory Structure ### Organization diff --git a/cmake/AISInstall.cmake b/cmake/AISInstall.cmake index d7118a7d..97779ae3 100644 --- a/cmake/AISInstall.cmake +++ b/cmake/AISInstall.cmake @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: MIT -# Install hipFile and rocFile +# Install hipFile # From the rocm-cmake repo include(ROCMInstallTargets) diff --git a/hipfile/docs/errors.rst b/hipfile/docs/errors.rst index 655ef812..67e6f6e5 100644 --- a/hipfile/docs/errors.rst +++ b/hipfile/docs/errors.rst @@ -12,7 +12,7 @@ values indicate an error. :: - typedef struct __ROCFILE_NODISCARD hipFileError { + typedef struct __HIPFILE_NODISCARD hipFileError { hipFileOpError_t err; //!< Errors related to hipFile or the GPU IO driver hipError_t hip_drv_err; //!< Errors related to the GPU driver } hipFileError_t; From aaacc1724656c48b75bd4c53d565a334b3713348 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:54:17 -0700 Subject: [PATCH 47/48] IWYU changes after rework --- hipfile/src/amd_detail/backend/asyncop-fallback.h | 1 + hipfile/src/amd_detail/backend/fallback.h | 1 + hipfile/src/amd_detail/backend/fastpath.cpp | 1 + hipfile/src/amd_detail/backend/fastpath.h | 1 + hipfile/src/amd_detail/hipfile.cpp | 3 +++ 5 files changed, 7 insertions(+) diff --git a/hipfile/src/amd_detail/backend/asyncop-fallback.h b/hipfile/src/amd_detail/backend/asyncop-fallback.h index 43958aef..64953fe9 100644 --- a/hipfile/src/amd_detail/backend/asyncop-fallback.h +++ b/hipfile/src/amd_detail/backend/asyncop-fallback.h @@ -5,6 +5,7 @@ #pragma once #include "async.h" +#include "hipfile.h" #include #include diff --git a/hipfile/src/amd_detail/backend/fallback.h b/hipfile/src/amd_detail/backend/fallback.h index e9f5b161..b8554f0b 100644 --- a/hipfile/src/amd_detail/backend/fallback.h +++ b/hipfile/src/amd_detail/backend/fallback.h @@ -6,6 +6,7 @@ #pragma once #include "backend.h" +#include "hipfile.h" #include #include diff --git a/hipfile/src/amd_detail/backend/fastpath.cpp b/hipfile/src/amd_detail/backend/fastpath.cpp index 96fe4128..250fa657 100644 --- a/hipfile/src/amd_detail/backend/fastpath.cpp +++ b/hipfile/src/amd_detail/backend/fastpath.cpp @@ -8,6 +8,7 @@ #include "fastpath.h" #include "file.h" #include "hip.h" +#include "hipfile.h" #include "io.h" #include diff --git a/hipfile/src/amd_detail/backend/fastpath.h b/hipfile/src/amd_detail/backend/fastpath.h index 85132dc9..61f0915e 100644 --- a/hipfile/src/amd_detail/backend/fastpath.h +++ b/hipfile/src/amd_detail/backend/fastpath.h @@ -6,6 +6,7 @@ #pragma once #include "backend.h" +#include "hipfile.h" #include #include diff --git a/hipfile/src/amd_detail/hipfile.cpp b/hipfile/src/amd_detail/hipfile.cpp index f6d037ea..8af5ab6b 100644 --- a/hipfile/src/amd_detail/hipfile.cpp +++ b/hipfile/src/amd_detail/hipfile.cpp @@ -17,9 +17,12 @@ #include "sys.h" #include +#include +#include #include #include #include +#include #include using namespace hipFile; From cc640aeaba2c1efd3c32bfce022ac1e6eda72c32 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 26 Nov 2025 08:56:49 -0700 Subject: [PATCH 48/48] Codespell change --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00953a45..da761b5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Changed ### Removed -* The rocFile library has been completelly removed and the code is now a part of hipFile. +* The rocFile library has been completely removed and the code is now a part of hipFile. * The hipify patch was removed. You can get hipify with hipFile support at https://github.com/derobins/HIPIFY/tree/hipFile. ### Limitations