Skip to content

Commit

Permalink
Merge pull request #19 from GPUOpen-LibrariesAndSDKs/feature/HRT-0-02001
Browse files Browse the repository at this point in the history
hiprt 2.1
  • Loading branch information
meistdan authored Sep 26, 2023
2 parents 853935b + e7b0073 commit 7d2f55a
Show file tree
Hide file tree
Showing 66 changed files with 2,240 additions and 1,523 deletions.
2 changes: 1 addition & 1 deletion contrib/Orochi
Submodule Orochi updated 85 files
+1 −0 .gitattributes
+142 −0 Orochi/GpuMemory.h
+72 −52 Orochi/Orochi.cpp
+37 −62 Orochi/Orochi.h
+0 −4 Orochi/OrochiUtils.cpp
+48 −5 Orochi/OrochiUtils.h
+2 −1 README.md
+3 −3 Test/VulkanComputeSimple/main.cpp
+1 −0 Test/WMMA/main.cpp
+2 −0 UnitTest/bitcodes/generate_bitcodes.bat
+2 −30 UnitTest/bitcodes/generate_bitcodes.sh
+0 −7 UnitTest/bitcodes/generate_bitcodes_gfx1100.bat
+0 −6 UnitTest/bitcodes/generate_bitcodes_gfx1100.sh
+0 −7 UnitTest/bitcodes/generate_bitcodes_gfx1102.bat
+0 −6 UnitTest/bitcodes/generate_bitcodes_gfx1102.sh
+2 −0 UnitTest/bitcodes/generate_bitcodes_nvidia.bat
+2 −4 UnitTest/bitcodes/generate_bitcodes_nvidia.sh
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1010.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1011.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1012.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1013.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1030.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1031.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1032.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1033.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1034.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1035.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx1036.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx900.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa-gfx906.bc
+ UnitTest/bitcodes/moduleTestFunc-hip-amdgcn-amd-amdhsa.bc
+ UnitTest/bitcodes/moduleTestFunc.cubin
+ UnitTest/bitcodes/moduleTestFunc.fatbin
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1010.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1011.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1012.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1013.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1030.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1031.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1032.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1033.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1034.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1035.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx1036.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx900.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa-gfx906.bc
+ UnitTest/bitcodes/moduleTestKernel-hip-amdgcn-amd-amdhsa.bc
+ UnitTest/bitcodes/moduleTestKernel.cubin
+ UnitTest/bitcodes/moduleTestKernel.fatbin
+296 −45 UnitTest/main.cpp
+2 −0 UnitTest/moduleTestFunc.cpp
+0 −5 UnitTest/moduleTestFunc.cu
+0 −6 UnitTest/moduleTestKernel.cu
+4 −0 UnitTest/premake5.lua
+32 −0 UnitTest/testKernel.h
+ bitcodes/oro_compiled_kernels.fatbin
+ bitcodes/oro_compiled_kernels.hipfb
+ contrib/bin/win64/amd_comgr0504.dll
+3 −0 contrib/bin/win64/amd_comgr0505.dll
+ contrib/bin/win64/hiprtc-builtins0504.dll
+3 −0 contrib/bin/win64/hiprtc-builtins0505.dll
+ contrib/bin/win64/hiprtc0504.dll
+3 −0 contrib/bin/win64/hiprtc0505.dll
+2 −190 contrib/cuew/include/cuew.h
+11 −25 contrib/cuew/src/cuew.cpp
+10 −60 contrib/hipew/include/hipew.h
+89 −78 contrib/hipew/src/hipew.cpp
+23 −0 premake5.lua
+30 −0 scripts/amdGpuList.json
+22 −0 scripts/enumArch.py
+46 −0 scripts/kernelCompile.py
+4 −1 scripts/unittest.bat
+1 −1 scripts/unittest.sh
+0 −5 scripts/unittest_gfx1100.bat
+0 −4 scripts/unittest_gfx1100.sh
+0 −5 scripts/unittest_gfx1102.bat
+0 −4 scripts/unittest_gfx1102.sh
+0 −2 scripts/unittest_navi1.bat
+0 −3 scripts/unittest_navi1.sh
+0 −2 scripts/unittest_navi2.bat
+0 −3 scripts/unittest_navi2.sh
+0 −2 scripts/unittest_vega10.bat
+0 −3 scripts/unittest_vega10.sh
+0 −2 scripts/unittest_vega20.bat
+0 −3 scripts/unittest_vega20.sh
8 changes: 4 additions & 4 deletions tutorials/00_context_creation/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
int main( int argc, char** argv )
{
const int deviceIndex = 0;
CHECK_ORO( (oroError)oroInitialize( ( oroApi )( ORO_API_HIP | ORO_API_CUDA ), 0 ) );

CHECK_ORO( (oroError)oroInitialize( (oroApi)( ORO_API_HIP | ORO_API_CUDA ), 0 ) );

CHECK_ORO( oroInit( 0 ) );

Expand All @@ -45,11 +45,11 @@ int main( int argc, char** argv )
ctxtInput.deviceType = hiprtDeviceNVIDIA;
else
ctxtInput.deviceType = hiprtDeviceAMD;
ctxtInput.ctxt = oroGetRawCtx( oroCtx );
ctxtInput.ctxt = oroGetRawCtx( oroCtx );
ctxtInput.device = oroGetRawDevice( oroDevice );

hiprtContext ctxt;
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, ctxtInput, &ctxt ) );
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, ctxtInput, ctxt ) );
CHECK_HIPRT( hiprtDestroyContext( ctxt ) );

return 0;
Expand Down
40 changes: 22 additions & 18 deletions tutorials/01_geom_intersection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,60 +25,64 @@
class Tutorial : public TutorialBase
{
public:
void run()
void run()
{
hiprtContext ctxt;
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, &ctxt ) );
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, ctxt ) );

hiprtTriangleMeshPrimitive mesh;
mesh.triangleCount = 2;
mesh.triangleStride = sizeof( hiprtInt3 );
int triangleIndices[] = { 0, 1, 2, 3, 4, 5 };
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
CHECK_ORO(
oroMemcpyHtoD( (oroDeviceptr)mesh.triangleIndices, triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.triangleIndices ), mesh.triangleCount * sizeof( hiprtInt3 ) ) );
CHECK_ORO( oroMemcpyHtoD(
reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ),
triangleIndices,
mesh.triangleCount * sizeof( hiprtInt3 ) ) );

mesh.vertexCount = 6;
mesh.vertexStride = sizeof( hiprtFloat3 );
mesh.vertexCount = 6;
mesh.vertexStride = sizeof( hiprtFloat3 );
hiprtFloat3 vertices[] = {
{ 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.0f },
{ 0.5f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 0.5f, 1.0f, 1.0f } };
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)mesh.vertices, vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.vertices ), mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
CHECK_ORO( oroMemcpyHtoD(
reinterpret_cast<oroDeviceptr>( mesh.vertices ), vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );

hiprtGeometryBuildInput geomInput;
geomInput.type = hiprtPrimitiveTypeTriangleMesh;
geomInput.triangleMesh.primitive = &mesh;
geomInput.triangleMesh.primitive = mesh;

size_t geomTempSize;
hiprtDevicePtr geomTemp;
hiprtBuildOptions options;
options.buildFlags = hiprtBuildFlagBitPreferFastBuild;
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, &geomInput, &options, &geomTempSize ) );
CHECK_ORO( oroMalloc( (oroDeviceptr*)&geomTemp, geomTempSize ) );
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, geomInput, options, geomTempSize ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &geomTemp ), geomTempSize ) );

hiprtGeometry geom;
CHECK_HIPRT( hiprtCreateGeometry( ctxt, &geomInput, &options, &geom ) );
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, &geomInput, &options, geomTemp, 0, geom ) );
CHECK_HIPRT( hiprtCreateGeometry( ctxt, geomInput, options, geom ) );
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, geomInput, options, geomTemp, 0, geom ) );

oroFunction func;
buildTraceKernelFromBitcode( ctxt, "../common/TutorialKernels.h", "GeomIntersectionKernel", func );

u8* pixels;
CHECK_ORO( oroMalloc( (oroDeviceptr*)&pixels, m_res.x * m_res.y * 4 ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &pixels ), m_res.x * m_res.y * 4 ) );

void* args[] = { &geom, &pixels, &m_res };
launchKernel( func, m_res.x, m_res.y, args );
writeImage( "01_geom_intersection.png", m_res.x, m_res.y, pixels );

CHECK_ORO( oroFree( (oroDeviceptr)mesh.triangleIndices ) );
CHECK_ORO( oroFree( (oroDeviceptr)mesh.vertices ) );
CHECK_ORO( oroFree( (oroDeviceptr)geomTemp ) );
CHECK_ORO( oroFree( (oroDeviceptr)pixels ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.vertices ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( geomTemp ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( pixels ) ) );

CHECK_HIPRT( hiprtDestroyGeometry( ctxt, geom ) );
CHECK_HIPRT( hiprtDestroyContext( ctxt ) );
Expand Down
43 changes: 0 additions & 43 deletions tutorials/02_scene_intersection/TestKernel.h

This file was deleted.

64 changes: 34 additions & 30 deletions tutorials/02_scene_intersection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@
class Tutorial : public TutorialBase
{
public:
void run()
void run()
{
hiprtContext ctxt;
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, &ctxt ) );
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, ctxt ) );

hiprtTriangleMeshPrimitive mesh;
mesh.triangleCount = 2;
mesh.triangleStride = sizeof( hiprtInt3 );
mesh.triangleCount = 2;
mesh.triangleStride = sizeof( hiprtInt3 );
int triangleIndices[] = { 0, 1, 2, 3, 4, 5 };
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
CHECK_ORO(
oroMemcpyHtoD( (oroDeviceptr)mesh.triangleIndices, triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.triangleIndices ), mesh.triangleCount * sizeof( hiprtInt3 ) ) );
CHECK_ORO( oroMemcpyHtoD(
reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ),
triangleIndices,
mesh.triangleCount * sizeof( hiprtInt3 ) ) );

mesh.vertexCount = 6;
mesh.vertexStride = sizeof( hiprtFloat3 );
Expand All @@ -49,65 +52,68 @@ class Tutorial : public TutorialBase
{ -s, s, 0.0f },
{ -s + t * s, -s * s, 0.0f },
{ -s - t * s, -s * s, 0.0f } };
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)mesh.vertices, vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.vertices ), mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
CHECK_ORO( oroMemcpyHtoD(
reinterpret_cast<oroDeviceptr>( mesh.vertices ), vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );

hiprtGeometryBuildInput geomInput;
geomInput.type = hiprtPrimitiveTypeTriangleMesh;
geomInput.triangleMesh.primitive = &mesh;
geomInput.triangleMesh.primitive = mesh;

size_t geomTempSize;
hiprtDevicePtr geomTemp;
hiprtBuildOptions options;
options.buildFlags = hiprtBuildFlagBitPreferFastBuild;
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, &geomInput, &options, &geomTempSize ) );
CHECK_ORO( oroMalloc( (oroDeviceptr*)&geomTemp, geomTempSize ) );
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, geomInput, options, geomTempSize ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &geomTemp ), geomTempSize ) );

hiprtGeometry geom;
CHECK_HIPRT( hiprtCreateGeometry( ctxt, &geomInput, &options, &geom ) );
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, &geomInput, &options, geomTemp, 0, geom ) );
CHECK_HIPRT( hiprtCreateGeometry( ctxt, geomInput, options, geom ) );
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, geomInput, options, geomTemp, 0, geom ) );

hiprtSceneBuildInput sceneInput;
sceneInput.instanceCount = 1;
sceneInput.instanceMasks = nullptr;
sceneInput.instanceTransformHeaders = nullptr;
hiprtDevicePtr geoms[] = { geom };
CHECK_ORO( oroMalloc( (oroDeviceptr*)&sceneInput.instanceGeometries, sizeof( hiprtDevicePtr ) ) );
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)sceneInput.instanceGeometries, geoms, sizeof( hiprtDevicePtr ) ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &sceneInput.instanceGeometries ), sizeof( hiprtDevicePtr ) ) );
CHECK_ORO(
oroMemcpyHtoD( reinterpret_cast<oroDeviceptr>( sceneInput.instanceGeometries ), geoms, sizeof( hiprtDevicePtr ) ) );

hiprtFrameSRT frame;
frame.translation = make_hiprtFloat3( 0.0f, 0.0f, 0.0f );
frame.scale = make_hiprtFloat3( 0.5f, 0.5f, 0.5f );
frame.rotation = make_hiprtFloat4( 0.0f, 0.0f, 1.0f, 0.0f );
sceneInput.frameCount = 1;
CHECK_ORO( oroMalloc( (oroDeviceptr*)&sceneInput.instanceFrames, sizeof( hiprtFrameSRT ) ) );
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)sceneInput.instanceFrames, &frame, sizeof( hiprtFrameSRT ) ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &sceneInput.instanceFrames ), sizeof( hiprtFrameSRT ) ) );
CHECK_ORO(
oroMemcpyHtoD( reinterpret_cast<oroDeviceptr>( sceneInput.instanceFrames ), &frame, sizeof( hiprtFrameSRT ) ) );

size_t sceneTempSize;
hiprtDevicePtr sceneTemp;
CHECK_HIPRT( hiprtGetSceneBuildTemporaryBufferSize( ctxt, &sceneInput, &options, &sceneTempSize ) );
CHECK_ORO( oroMalloc( (oroDeviceptr*)&sceneTemp, sceneTempSize ) );
CHECK_HIPRT( hiprtGetSceneBuildTemporaryBufferSize( ctxt, sceneInput, options, sceneTempSize ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &sceneTemp ), sceneTempSize ) );

hiprtScene scene;
CHECK_HIPRT( hiprtCreateScene( ctxt, &sceneInput, &options, &scene ) );
CHECK_HIPRT( hiprtBuildScene( ctxt, hiprtBuildOperationBuild, &sceneInput, &options, sceneTemp, 0, scene ) );
CHECK_HIPRT( hiprtCreateScene( ctxt, sceneInput, options, scene ) );
CHECK_HIPRT( hiprtBuildScene( ctxt, hiprtBuildOperationBuild, sceneInput, options, sceneTemp, 0, scene ) );

oroFunction func;
buildTraceKernelFromBitcode( ctxt, "../common/TutorialKernels.h", "SceneIntersectionKernel", func );

u8* pixels;
CHECK_ORO( oroMalloc( (oroDeviceptr*)&pixels, m_res.x * m_res.y * 4 ) );
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &pixels ), m_res.x * m_res.y * 4 ) );

void* args[] = { &scene, &pixels, &m_res };
launchKernel( func, m_res.x, m_res.y, args );
writeImage( "02_scene_intersection.png", m_res.x, m_res.y, pixels );

CHECK_ORO( oroFree( (oroDeviceptr)sceneInput.instanceGeometries ) );
CHECK_ORO( oroFree( (oroDeviceptr)sceneInput.instanceFrames ) );
CHECK_ORO( oroFree( (oroDeviceptr)mesh.triangleIndices ) );
CHECK_ORO( oroFree( (oroDeviceptr)mesh.vertices ) );
CHECK_ORO( oroFree( (oroDeviceptr)geomTemp ) );
CHECK_ORO( oroFree( (oroDeviceptr)pixels ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( sceneInput.instanceGeometries ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( sceneInput.instanceFrames ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.vertices ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( geomTemp ) ) );
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( pixels ) ) );

CHECK_HIPRT( hiprtDestroyGeometry( ctxt, geom ) );
CHECK_HIPRT( hiprtDestroyScene( ctxt, scene ) );
Expand All @@ -123,5 +129,3 @@ int main( int argc, char** argv )

return 0;
}


82 changes: 0 additions & 82 deletions tutorials/03_custom_intersection/TestKernel.h

This file was deleted.

Loading

0 comments on commit 7d2f55a

Please sign in to comment.