dev-libs/hiprt: new package, add 2.5.20250428

Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42717
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sv. Lockal 2025-06-23 21:09:55 +00:00 committed by Sam James
parent 011ed4e583
commit d3e730b5c6
No known key found for this signature in database
GPG Key ID: 738409F520DF9190
8 changed files with 298 additions and 0 deletions

1
dev-libs/hiprt/Manifest Normal file
View File

@ -0,0 +1 @@
DIST hiprt-2.5.20250428.tar.gz 33372970 BLAKE2B ae184bab5dc44d165f92e925ce9743e77be17af1a1afdf6586fd216ffe8d896f388ca855df3ba35ddc9c072a68015be389d8057a9b68f3c1b44fd511f0b56a01 SHA512 d552e5657ad8117721685def6c9110a715a5b879cd0673753409b8bd95b456b6900613123e302ae72628052c5e3f5aa1ddc89df225591494cbc87129fc72a67e

View File

@ -0,0 +1,34 @@
--- a/scripts/bitcodes/compile.py
+++ b/scripts/bitcodes/compile.py
@@ -58,8 +58,10 @@ def compileScript(cmd, dst):
return_code = subprocess.call(cmd, shell=True)
if return_code != 0:
print(errorMessageHeader + ' executing command: ' + cmd)
+ sys.exit(1)
elif not os.path.exists(dst):
print(errorMessageHeader + ' The file ' + dst + ' does not exist.')
+ sys.exit(1)
else:
print('Compilation SUCCEEDED.')
sys.stdout.flush()
@@ -84,6 +86,7 @@ def compileAmd():
return_code = subprocess.call(cmd, shell=True)
if return_code != 0:
print(errorMessageHeader + ' executing command: ' + cmd)
+ sys.exit(1)
result = subprocess.check_output(cmd, shell=True)
hip_sdk_version = result.decode('utf-8')
--- a/scripts/bitcodes/precompile_bitcode.py
+++ b/scripts/bitcodes/precompile_bitcode.py
@@ -60,8 +60,10 @@ def compileScript(msg, cmd, dst):
return_code = subprocess.call(cmd, shell=True)
if return_code != 0:
print(errorMessageHeader + ' executing command: ' + cmd)
+ sys.exit(1)
elif not os.path.exists(dst):
print(errorMessageHeader + ' The file ' + dst + ' does not exist.')
+ sys.exit(1)
else:
print('Compilation SUCCEEDED.')
sys.stdout.flush()

View File

@ -0,0 +1,39 @@
Partial backport from upstream for hip-7 compatibility (no member named 'data' in 'HIP_vector_type...)
Backports https://github.com/GPUOpen-LibrariesAndSDKs/HIPRT/commit/592a92b5afcc6de16c5371b1f41daec4ac59b77b
--- a/hiprt/impl/hiprt_device_impl.h
+++ b/hiprt/impl/hiprt_device_impl.h
@@ -362,10 +362,10 @@ TraversalBase<Stack>::testInternalNode( const hiprtRay& ray, const float3& invD,
auto result = __builtin_amdgcn_image_bvh_intersect_ray_l(
encodeBaseAddr( nodes, nodeIndex ),
ray.maxT,
- float4{ ray.origin.x, ray.origin.y, ray.origin.z, 0.0f }.data,
- float4{ ray.direction.x, ray.direction.y, ray.direction.z, 0.0f }.data,
- float4{ invD.x, invD.y, invD.z, 0.0f }.data,
- m_descriptor.data );
+ { ray.origin.x, ray.origin.y, ray.origin.z, 0.0f },
+ { ray.direction.x, ray.direction.y, ray.direction.z, 0.0f },
+ { invD.x, invD.y, invD.z, 0.0f },
+ { m_descriptor.x, m_descriptor.y, m_descriptor.z, m_descriptor.w } );
#endif
if ( m_stack.vacancy() < 3 )
{
@@ -397,11 +397,13 @@ HIPRT_DEVICE bool TraversalBase<Stack>::testTriangleNode(
hit.normal = node.m_triPair.fetchTriangle( leafIndex & 1 ).normal( node.m_flags >> ( ( leafIndex & 1 ) * 8 ) );
}
#else
- const float4 origin = float4{ ray.origin.x, ray.origin.y, ray.origin.z, 0.0f };
- const float4 direction = float4{ ray.direction.x, ray.direction.y, ray.direction.z, 0.0f };
- const float4 invDir = float4{ invD.x, invD.y, invD.z, 0.0f };
- auto result = __builtin_amdgcn_image_bvh_intersect_ray_l(
- encodeBaseAddr( nodes, leafIndex ), ray.maxT, origin.data, direction.data, invDir.data, m_descriptor.data );
+ auto result = __builtin_amdgcn_image_bvh_intersect_ray_l(
+ encodeBaseAddr( nodes, leafIndex ),
+ ray.maxT,
+ { ray.origin.x, ray.origin.y, ray.origin.z, 0.0f },
+ { ray.direction.x, ray.direction.y, ray.direction.z, 0.0f },
+ { invD.x, invD.y, invD.z, 0.0f },
+ { m_descriptor.x, m_descriptor.y, m_descriptor.z, m_descriptor.w } );
float invDenom = __ocml_native_recip_f32( __int_as_float( result[1] ) );
float t = __int_as_float( result[0] ) * invDenom;
hasHit = ray.minT <= t && t <= ray.maxT;

View File

@ -0,0 +1,50 @@
Compile into hiprt64.so (as Blender expects) instead of hiprt<some-number>64[D].so
Install libraries to libdir, not /usr/bin
Upstream bug (rejected): https://github.com/GPUOpen-LibrariesAndSDKs/HIPRT/issues/22
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -354,11 +354,7 @@ add_library(${HIPRT_NAME} SHARED)
target_compile_definitions(${HIPRT_NAME} PRIVATE HIPRT_EXPORTS)
-if( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
- set_target_properties(${HIPRT_NAME} PROPERTIES OUTPUT_NAME "${HIPRT_NAME}64D")
-else()
- set_target_properties(${HIPRT_NAME} PROPERTIES OUTPUT_NAME "${HIPRT_NAME}64")
-endif()
+set_target_properties(${HIPRT_NAME} PROPERTIES OUTPUT_NAME "hiprt64")
if(BITCODE)
@@ -567,7 +563,7 @@ target_sources(${HIPRT_NAME} PRIVATE ${hiprt_sources} ${orochi_sources})
# install script
#
-install(TARGETS ${HIPRT_NAME} DESTINATION bin)
+install(TARGETS ${HIPRT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
# add header files
file(GLOB HIPRT_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/*.h")
@@ -589,7 +585,7 @@ install(FILES ${HIPRT_ORO_HEADERS}
# add hipfb files
if(PRECOMPILE AND NOT BAKE_COMPILED_KERNEL)
install(FILES ${KERNEL_HIPRT_COMP} ${KERNEL_OROCHI_COMP}
- DESTINATION bin)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
# Project: Unit Test
@@ -605,11 +601,7 @@ if(NOT NO_UNITTEST)
target_link_libraries(unittest PRIVATE version)
endif()
- if( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
- set_target_properties(unittest PROPERTIES OUTPUT_NAME "unittest64D")
- else()
- set_target_properties(unittest PROPERTIES OUTPUT_NAME "unittest64")
- endif()
+ set_target_properties(unittest PROPERTIES OUTPUT_NAME "unittest64")
target_include_directories(unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi)

View File

@ -0,0 +1,52 @@
Option --parallel-jobs is only supported by amdclang++
Upstream bug: https://github.com/GPUOpen-LibrariesAndSDKs/HIPRT/issues/21
--- a/contrib/Orochi/scripts/kernelCompile.py
+++ b/contrib/Orochi/scripts/kernelCompile.py
@@ -17,7 +17,7 @@ def compile( index ):
if index == 0 :
command = [
"hipcc",
- "-x", "hip", "..\ParallelPrimitives\RadixSortKernels.h", "-O3", "-std=c++17", "-ffast-math", "--cuda-device-only", "--genco", "-I../", "-include", "hip/hip_runtime.h", "-parallel-jobs=15"]
+ "-x", "hip", "..\ParallelPrimitives\RadixSortKernels.h", "-O3", "-std=c++17", "-ffast-math", "--cuda-device-only", "--genco", "-I../", "-include", "hip/hip_runtime.h"]
#command.append( "--offload-arch=gfx1100" )
for i in enumArch( "gfx900" ):
command.append( "--offload-arch=" + i )
--- a/scripts/bitcodes/compile.py
+++ b/scripts/bitcodes/compile.py
@@ -117,15 +117,15 @@ def compileAmd():
parallel_jobs = 15
dst = 'hiprt' + hiprt_ver + '_' + hip_version + '_amd_lib' + postfix
- cmd = hipccpath + ' -x hip ../../hiprt/impl/hiprt_kernels_bitcode.h -O3 -std=c++17 ' + targets + ' -fgpu-rdc -c --gpu-bundle-output -c -emit-llvm -I../../contrib/Orochi/ -I../../ -DHIPRT_BITCODE_LINKING -ffast-math -parallel-jobs=' + str(parallel_jobs) + ' -o ' + dst
+ cmd = hipccpath + ' -x hip ../../hiprt/impl/hiprt_kernels_bitcode.h -O3 -std=c++17 ' + targets + ' -fgpu-rdc -c --gpu-bundle-output -c -emit-llvm -I../../contrib/Orochi/ -I../../ -DHIPRT_BITCODE_LINKING -ffast-math -o ' + dst
compileScript(cmd, dst)
dst = 'hiprt' + hiprt_ver + '_' + hip_version + '_amd.hipfb'
- cmd = hipccpath + ' -x hip ../../hiprt/impl/hiprt_kernels.h -O3 -std=c++17 ' + targets + ' -mllvm -amdgpu-early-inline-all=false -mllvm -amdgpu-function-calls=true --genco -I../../ -DHIPRT_BITCODE_LINKING -ffast-math -parallel-jobs=' + str(parallel_jobs) + ' -o ' + dst
+ cmd = hipccpath + ' -x hip ../../hiprt/impl/hiprt_kernels.h -O3 -std=c++17 ' + targets + ' -mllvm -amdgpu-early-inline-all=false -mllvm -amdgpu-function-calls=true --genco -I../../ -DHIPRT_BITCODE_LINKING -ffast-math -o ' + dst
compileScript(cmd, dst)
dst = 'oro_compiled_kernels.hipfb'
- cmd = hipccpath + ' -x hip ../../contrib/Orochi/ParallelPrimitives/RadixSortKernels.h -O3 -std=c++17 ' + targets + ' --genco -I../../contrib/Orochi/ -include hip/hip_runtime.h -DHIPRT_BITCODE_LINKING -ffast-math -parallel-jobs=' + str(parallel_jobs) + ' -o ' + dst
+ cmd = hipccpath + ' -x hip ../../contrib/Orochi/ParallelPrimitives/RadixSortKernels.h -O3 -std=c++17 ' + targets + ' --genco -I../../contrib/Orochi/ -include hip/hip_runtime.h -DHIPRT_BITCODE_LINKING -ffast-math -o ' + dst
compileScript(cmd, dst)
--- a/scripts/bitcodes/precompile_bitcode.py
+++ b/scripts/bitcodes/precompile_bitcode.py
@@ -127,12 +127,12 @@ def compileAmd():
# compile custom function table
hiprt_custom_func = 'hiprt' + hiprt_ver + '_' + hip_version + '_custom_func_table.bc'
- cmd = hipccpath + ' -O3 -std=c++17 ' + targets + ' -fgpu-rdc -c --gpu-bundle-output -c -emit-llvm -I../../ -ffast-math ../../test/bitcodes/custom_func_table.cpp -parallel-jobs=15 -o ' + hiprt_custom_func
+ cmd = hipccpath + ' -O3 -std=c++17 ' + targets + ' -fgpu-rdc -c --gpu-bundle-output -c -emit-llvm -I../../ -ffast-math ../../test/bitcodes/custom_func_table.cpp -o ' + hiprt_custom_func
compileScript('compiling ', cmd, hiprt_custom_func)
# compiling unit test
hiprt_unit_test = 'hiprt' + hiprt_ver + '_' + hip_version + '_unit_test'+ postfix
- cmd = hipccpath + ' -O3 -std=c++17 ' + targets + ' -fgpu-rdc -c --gpu-bundle-output -c -emit-llvm -I../../ -ffast-math -D BLOCK_SIZE=64 -D SHARED_STACK_SIZE=16 ../../test/bitcodes/unit_test.cpp -parallel-jobs=15 -o ' + hiprt_unit_test
+ cmd = hipccpath + ' -O3 -std=c++17 ' + targets + ' -fgpu-rdc -c --gpu-bundle-output -c -emit-llvm -I../../ -ffast-math -D BLOCK_SIZE=64 -D SHARED_STACK_SIZE=16 ../../test/bitcodes/unit_test.cpp -o ' + hiprt_unit_test
compileScript('compiling ', cmd, hiprt_unit_test)
# linking

View File

@ -0,0 +1,29 @@
Fix gcc error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
--- a/contrib/Orochi/Orochi/Orochi.cpp
+++ b/contrib/Orochi/Orochi/Orochi.cpp
@@ -940,7 +940,9 @@ oroDevice oroSetRawDevice( oroApi api, oroDevice dev )
{
ioroDevice d( dev );
d.setApi( api );
- return *(oroDevice*)&d;
+ oroDevice result;
+ memcpy(&result, &d, sizeof(result));
+ return result;
}
//=================================
@@ -1005,7 +1007,13 @@ inline hipCtx_t* oroCtx2hip( oroCtx* a )
#define __ORO_FUNC(cuname,hipname) if( s_api == ORO_API_HIP ) return hip2oro(hipname);
#endif
-#define __ORO_FORCE_CAST(type,var) *((type*)(&var))
+#define __ORO_FORCE_CAST(type,var) \
+ ({ \
+ type __temp_result; \
+ static_assert(sizeof(type) == sizeof(var), "Types must be the same size for casting"); \
+ memcpy(&__temp_result, &(var), sizeof(type)); \
+ __temp_result; \
+ })

View File

@ -0,0 +1,73 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
ROCM_SKIP_GLOBALS=1
inherit cmake edo flag-o-matic rocm toolchain-funcs
RELEASE_TAG=2.5.a21e075.3
DESCRIPTION="A ray tracing library for HIP"
HOMEPAGE="https://github.com/GPUOpen-LibrariesAndSDKs/HIPRT"
SRC_URI="https://github.com/GPUOpen-LibrariesAndSDKs/HIPRT/archive/refs/tags/${RELEASE_TAG}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/HIPRT-${RELEASE_TAG}"
LICENSE="MIT"
SLOT="$(ver_cut 0-2)"
KEYWORDS="~amd64"
IUSE="debug test"
RESTRICT="!test? ( test )"
RDEPEND="
dev-util/hip
"
DEPEND="
dev-util/hipcc
${RDEPEND}
"
PATCHES=(
"${FILESDIR}/${PN}-2.5-no-parallel-jobs.patch"
"${FILESDIR}/${PN}-2.5-install-path.patch"
"${FILESDIR}/${PN}-2.5-strict-aliasing.patch"
"${FILESDIR}/${PN}-2.5-fail-on-errors.patch"
"${FILESDIR}/${PN}-2.5-hip7.patch"
)
src_prepare() {
sed "s|hipSdkPathFromArgument + '/bin/clang++'|'$(tc-getHIPCXX)'|" \
-i scripts/bitcodes/precompile_bitcode.py || die
cmake_src_prepare
}
src_configure() {
# ODR violations
filter-lto
# Only Release and Debug targets are supported
local CMAKE_BUILD_TYPE=$(usex debug Debug Release)
local mycmakeargs=(
-DHIP_PATH="${ESYSROOT}/usr"
-DFORCE_DISABLE_CUDA=ON
-DPRECOMPILE=ON
-DBITCODE=ON
-DNO_ENCRYPT=ON
-DNO_UNITTEST=$(usex !test)
-DCMAKE_INSTALL_PREFIX="${ESYSROOT}/usr/lib/hiprt/${SLOT}"
)
cmake_src_configure
}
src_test() {
check_amdgpu
local -x GTEST_FILTER="-hiprtTest.CudaEnabled"
pushd dist > /dev/null || die
edo ./bin/$(usex debug Debug Release)/unittest64
popd > /dev/null || die
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>lockalsash@gmail.com</email>
<name>Sv. Lockal</name>
</maintainer>
<maintainer type="project" proxied="proxy">
<email>proxy-maint@gentoo.org</email>
<name>Proxy Maintainers</name>
</maintainer>
<longdescription>
HIP RT is a ray tracing library for HIP, released by AMD's GPUOpen team. This
library is notably used in the Blender 3D modeling software for ray tracing acceleration
on Radeon GPUs.
</longdescription>
<upstream>
<remote-id type="github">GPUOpen-LibrariesAndSDKs/HIPRT</remote-id>
</upstream>
</pkgmetadata>