Skip to content

Commit

Permalink
Start running OSPRay as DPC++ on the GPU
Browse files Browse the repository at this point in the history
Use an enum + switch statements to avoid issues/limitations with
function ptrs.

Renable volumes with OpenVKL when running on CPU w/ enable volumes

Put both CPU and GPU modules behind CMake flags

workaround odd bug with AO renderer and intervals

Add spheres geometry and port to use Embree sphere point

Push math constants for RNG to USM instead of in global constant

WA for `Material_dispatch_getTransparency` hang, working path tracer

Re-enable subdivision surfaces for CPU-only

Port Texture2D to use switch statement dispatch

Migrate all materials to switch dispatch

Add option for large grf, does improve performance

Workaround for TextureParam get3f bug

Update headers and APIs for L0 interop header updates/deprecations
  • Loading branch information
Will Usher authored and miroslawpawlowski committed Jan 11, 2023
1 parent 73f4c42 commit 078c589
Show file tree
Hide file tree
Showing 376 changed files with 8,096 additions and 1,931 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ premake.local.*
cmake-build*/
.clangd
compile_commands.json
.cache/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
9 changes: 8 additions & 1 deletion apps/common/ospray_testing/builders/CornellBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,16 @@ cpp::Group CornellBox::buildGroup() const
{
cpp::Geometry quadMesh("mesh");

// TODO: Temporarily try triangulating the scene
std::vector<vec3ui> triangleIndices;
for (const auto &idx : indices) {
triangleIndices.push_back(vec3ui(idx.x, idx.y, idx.z));
triangleIndices.push_back(vec3ui(idx.z, idx.w, idx.x));
}

quadMesh.setParam("vertex.position", cpp::CopiedData(vertices));
quadMesh.setParam("vertex.color", cpp::CopiedData(colors));
quadMesh.setParam("index", cpp::CopiedData(indices));
quadMesh.setParam("index", cpp::CopiedData(triangleIndices));
quadMesh.commit();

cpp::GeometricModel model(quadMesh);
Expand Down
2 changes: 1 addition & 1 deletion apps/ospExamples/GLFWOSPRayWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void GLFWOSPRayWindow::buildUI()
rendererTypeStr = g_renderers[whichRenderer];

if (rendererType == OSPRayRendererType::DEBUGGER)
whichDebuggerType = 0; // reset UI if switching away from debug renderer
whichDebuggerType = 1; // reset UI if switching away from debug renderer

if (rendererTypeStr == "scivis")
rendererType = OSPRayRendererType::SCIVIS;
Expand Down
6 changes: 3 additions & 3 deletions apps/ospExamples/GLFWOSPRayWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ class GLFWOSPRayWindow
float turbidity{3.f};
float horizonExtension{0.1f};

std::string scene{"boxes_lit"};
std::string scene{"cornell_box"};

std::string curveVariant{"bspline"};

OSPRayRendererType rendererType{OSPRayRendererType::SCIVIS};
std::string rendererTypeStr{"scivis"};
OSPRayRendererType rendererType{OSPRayRendererType::PATHTRACER};
std::string rendererTypeStr{"pathtracer"};

std::string pixelFilterTypeStr{"gaussian"};

Expand Down
7 changes: 7 additions & 0 deletions apps/ospTestSuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
)

if (OSPRAY_ENABLE_VOLUMES)
target_compile_definitions(ospray_gtest_utils
PUBLIC
-DOSPRAY_ENABLE_VOLUMES
)
endif()

add_executable(ospTestSuite
${OSPRAY_RESOURCE}
test_geometry.cpp
Expand Down
2 changes: 2 additions & 0 deletions apps/ospTestSuite/test_appearance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,13 @@ void PTBackgroundRefraction::SetUp()

// Test Instantiations //////////////////////////////////////////////////////

#if 0
INSTANTIATE_TEST_SUITE_P(Transparency,
FromOsprayTesting,
::testing::Combine(::testing::Values("transparency"),
::testing::Values("scivis", "pathtracer", "ao"),
::testing::Values(16)));
#endif

TEST_P(RendererMaterialList, material_list)
{
Expand Down
7 changes: 5 additions & 2 deletions apps/ospTestSuite/test_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0

#include <gtest/gtest.h>
#include "embree3/rtcore.h"
#include "openvkl/openvkl.h"
#include "embree4/rtcore.h"
#include "ospray/OSPEnums.h"

#ifdef OSPRAY_ENABLE_VOLUMES
#include "openvkl/openvkl.h"

TEST(Enums, VKLLogLevel)
{
ASSERT_LE(sizeof(OSPLogLevel), sizeof(VKLLogLevel));
Expand Down Expand Up @@ -128,6 +130,7 @@ TEST(Enums, VKLError)
ASSERT_EQ(OSP_OUT_OF_MEMORY, VKL_OUT_OF_MEMORY);
ASSERT_EQ(OSP_UNSUPPORTED_CPU, VKL_UNSUPPORTED_CPU);
}
#endif

TEST(Enums, RTCSubdivisionMode)
{
Expand Down
28 changes: 21 additions & 7 deletions apps/ospTestSuite/test_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,20 @@ TEST_P(FromOsprayTesting, test_scenes)
INSTANTIATE_TEST_SUITE_P(TestScenesGeometry,
FromOsprayTesting,
::testing::Combine(::testing::Values("cornell_box",
#ifdef OSPRAY_ENABLE_VOLUMES
"gravity_spheres_isosurface",
#endif
"empty",
"random_spheres",
"streamlines",
"subdivision_cube",
"planes",
"planes"
#ifdef OSPRAY_ENABLE_VOLUMES
,
"unstructured_volume_isosurface",
"instancing"),
"instancing"
#endif
),
::testing::Values("scivis", "pathtracer", "ao"),
::testing::Values(16)));

Expand Down Expand Up @@ -223,9 +229,13 @@ INSTANTIATE_TEST_SUITE_P(TestScenesClipping,
"clip_with_meshes",
"clip_with_subdivisions",
"clip_with_linear_curves",
"clip_with_bspline_curves",
"clip_with_bspline_curves"
#ifdef OSPRAY_ENABLE_VOLUMES
,
"clip_gravity_spheres_volume",
"clip_perlin_noise_volumes"),
"clip_perlin_noise_volumes"
#endif
),
::testing::Values("scivis", "pathtracer", "ao"),
::testing::Values(16)));

Expand All @@ -241,9 +251,13 @@ TEST_P(FromOsprayTestingMaxDepth, test_scenes)

INSTANTIATE_TEST_SUITE_P(TestScenesMaxDepth,
FromOsprayTestingMaxDepth,
::testing::Combine(
::testing::Values(
"cornell_box", "clip_with_spheres", "clip_gravity_spheres_volume"),
::testing::Combine(::testing::Values("cornell_box",
"clip_with_spheres"
#ifdef OSPRAY_ENABLE_VOLUMES
,
"clip_gravity_spheres_volume"
#endif
),
::testing::Values("ao"),
::testing::Values(16)));

Expand Down
3 changes: 2 additions & 1 deletion apps/ospTestSuite/test_motionblur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ void MotionCamera::SetUp()

// Test Instantiations //////////////////////////////////////////////////////

#if 0
TEST_P(MotionBlurBoxes, instance_mb)
{
PerformRenderTest();
Expand Down Expand Up @@ -318,7 +319,7 @@ INSTANTIATE_TEST_SUITE_P(CameraStereoRollingShutter,
::testing::Values(OSP_STEREO_TOP_BOTTOM),
::testing::Values(OSP_SHUTTER_ROLLING_DOWN),
::testing::Values(0.f)));

#endif
TEST_P(MotionCamera, camera_mb)
{
PerformRenderTest();
Expand Down
2 changes: 2 additions & 0 deletions apps/ospTestSuite/test_volumetric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ void UnstructuredVolume::SetUp()

// Test Instantiations //////////////////////////////////////////////////////

#ifdef OSPRAY_ENABLE_VOLUMES
INSTANTIATE_TEST_SUITE_P(TestScenesVolumes,
FromOsprayTesting,
::testing::Combine(::testing::Values("gravity_spheres_volume",
Expand Down Expand Up @@ -391,5 +392,6 @@ INSTANTIATE_TEST_SUITE_P(Renderers,
vec4f(1.f),
vec4f(0.f, 0.f, 0.f, 1.f),
vec4f(1.f, 0.f, 0.f, 0.5f))));
#endif

} // namespace OSPRayTestScenes
102 changes: 98 additions & 4 deletions cmake/compiler/dpcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,101 @@ if (APPLE)
endif()

# enable -static-intel
set(CMAKE_EXE_LINKER_FLAGS "-static-intel ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-static-intel ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS "-static-intel ${CMAKE_STATIC_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-static-intel ${CMAKE_MODULE_LINKER_FLAGS}")
# Note: this doesn't seem to be used/relevant to the DPC++ compiler? Maybe just the
# DPCPP release one? The nightly clang compiler doesn't recognize this flag
#set(CMAKE_EXE_LINKER_FLAGS "-static-intel ${CMAKE_EXE_LINKER_FLAGS}")
#set(CMAKE_SHARED_LINKER_FLAGS "-static-intel ${CMAKE_SHARED_LINKER_FLAGS}")
#set(CMAKE_STATIC_LINKER_FLAGS "-static-intel ${CMAKE_STATIC_LINKER_FLAGS}")
#set(CMAKE_MODULE_LINKER_FLAGS "-static-intel ${CMAKE_MODULE_LINKER_FLAGS}")

# TODO: These flags aren't recognized by IntelLLVM (the nightly dpcpp compiler)
# but at least the nan one does show up in the released dpcpp compiler.
# Are they being removed? or added?
#set(CMAKE_CXX_FLAGS "-fhonor-nan-compares -fhonor-infinities ${CMAKE_CXX_FLAGS}")

# SYCL flags to match Embree
list(APPEND OSPRAY_CXX_FLAGS_SYCL
-Wno-mismatched-tags
-Wno-pessimizing-move
-Wno-reorder
-Wno-unneeded-internal-declaration
-Wno-delete-non-abstract-non-virtual-dtor
-Wno-dangling-field
-Wno-unknown-pragmas
-Wno-logical-op-parentheses
-fsycl
-fsycl-unnamed-lambda
-Xclang -fsycl-allow-func-ptr)

# FIXME: debug information generation takes forever in SYCL
# TODO: Still true?
list(APPEND OSPRAY_CXX_FLAGS_SYCL -g0)
# FIXME: assertion still not working in SYCL
# TODO: Still true?
#list(APPEND OSPRAY_CXX_FLAGS_SYCL -UDEBUG -DNDEBUG)

# IGC options from Embree
# Enable __noinline
list(APPEND OSPRAY_IGC_OPTIONS "EnableOCLNoInlineAttr=0")
# This works around some IGC bug in spill compression
# TODO: Still true?
list(APPEND OSPRAY_IGC_OPTIONS "VISAOptions=-scratchAllocForStackInKB 128 -nospillcompression")

# Allow printf inside indirectly callable function, right now I have this in all for testing
# TODO: Should only enable for debug builds, and this needs to be done using a generator expression
# if we want to support it in VS
list(APPEND OSPRAY_IGC_OPTIONS "ForceInlineStackCallWithImplArg=0" "EnableGlobalStateBuffer=1")

# This significantly improves compile times on 17028 and up, though also impacts performance some
option(OSPRAY_IGC_FAST_COMPILE
"Pass flags to improve compilation speed at the cost of some optimization" OFF)
if (OSPRAY_IGC_FAST_COMPILE)
list(APPEND OSPRAY_IGC_OPTIONS "PartitionUnit=1")
list(APPEND OSPRAY_IGC_OPTIONS "UnitSizeThreshold=20000")
endif()
#list(APPEND OSPRAY_IGC_OPTIONS "ForceOCLSIMDWidth=8")

# Development option to dump shaders, when we compile AOT this has to be done at build time
option(OSPRAY_IGC_DUMP_SHADERS "Dump IGC shaders during build" OFF)
if (OSPRAY_IGC_DUMP_SHADERS)
list(APPEND OSPRAY_IGC_OPTIONS
"ShaderDumpEnable=1"
"ShowFullVectorsInShaderDumps=1"
"DumpToCustomDir=${PROJECT_BINARY_DIR}/ospray_igc_shader_dump")
endif()

# enables support for buffers larger than 4GB
list(APPEND OSPRAY_OCL_OPTIONS -cl-intel-greater-than-4GB-buffer-required)
list(APPEND OSPRAY_OCL_OTHER_OPTIONS
-cl-intel-force-global-mem-allocation
-cl-intel-no-local-to-generic)

# Large GRF mode
option(OSPRAY_DPCPP_LARGEGRF "Enable DPC++ Large GRF Support" OFF)
if (OSPRAY_DPCPP_LARGEGRF)
list(APPEND CMAKE_OCL_OPTIONS "-internal_options -cl-intel-256-GRF-per-thread")
endif()

# SYCL options for AOT/JIT compilation
set(OSPRAY_DPCPP_AOT_DEVICES "none" CACHE STRING
"SYCL devices to use for AOT compilation. Selecting none will compile to SPV for JIT compilation")
set_property(CACHE OSPRAY_DPCPP_AOT_DEVICES PROPERTY STRINGS none dg2 pvc)

# TODO: Is this revision info going to be visible to end users? In the end the public release
# of the code should probably just have one revision it targets right? The final consumer release rev.
set(OSPRAY_DPCPP_AOT_DEVICE_REVISION "8" CACHE STRING "AOT target device revision")

string(REPLACE ";" "," OSPRAY_IGC_OPTIONS_STR "${OSPRAY_IGC_OPTIONS}")

set(OSPRAY_OCL_OPTIONS_STR "${OSPRAY_OCL_OPTIONS}")
string(REPLACE ";" " " OSPRAY_OCL_OPTIONS_STR "${OSPRAY_OCL_OPTIONS}")

set(OSPRAY_OCL_OTHER_OPTIONS_STR "${OSPRAY_OCL_OTHER_OPTIONS}")
string(REPLACE ";" " " OSPRAY_OCL_OTHER_OPTIONS_STR "${OSPRAY_OCL_OTHER_OPTIONS}")

if (OSPRAY_DPCPP_AOT_DEVICES STREQUAL "none")
set(OSPRAY_SYCL_TARGET spir64)
else()
set(OSPRAY_SYCL_TARGET spir64_gen)
endif()

19 changes: 16 additions & 3 deletions cmake/ospray_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ macro(ospray_configure_compiler)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(OSPRAY_COMPILER_CLANG TRUE)
include(clang)
#include(clang)
# TODO WILL: We need to distinguish "clang" being real clang
# and "clang" being dpcpp nightly
message(WARNING "TODO WILL: We need to distinguish 'clang' = real clang vs. nightly dpcpp")
include(dpcpp)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(OSPRAY_COMPILER_MSVC TRUE)
include(msvc)
Expand Down Expand Up @@ -377,10 +381,12 @@ endfunction()

function(ospray_verify_embree_features)
ospray_check_embree_feature(ISPC_SUPPORT ISPC)
ospray_check_embree_feature(FILTER_FUNCTION "intersection filter")
# TODO: Having Function pointers enabled has a massive performance impact on GPU
#ospray_check_embree_feature(FILTER_FUNCTION "intersection filter")
ospray_check_embree_feature(GEOMETRY_TRIANGLE "triangle geometries")
ospray_check_embree_feature(GEOMETRY_CURVE "spline curve geometries")
ospray_check_embree_feature(GEOMETRY_USER "user geometries")
# TODO: Having Function pointers enabled has a massive performance impact on GPU
#ospray_check_embree_feature(GEOMETRY_USER "user geometries")
ospray_check_embree_feature(RAY_PACKETS "ray packets")
ospray_check_embree_feature(BACKFACE_CULLING "backface culling" OFF)
endfunction()
Expand All @@ -395,12 +401,19 @@ macro(ospray_find_embree EMBREE_VERSION_REQUIRED)
" set the 'embree_DIR' variable to the installation (or build)"
" directory.")
endif()
# Get Embree CPU info
get_target_property(EMBREE_INCLUDE_DIRS embree
INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(CONFIGURATIONS embree IMPORTED_CONFIGURATIONS)
list(GET CONFIGURATIONS 0 CONFIGURATION)
get_target_property(EMBREE_LIBRARY embree
IMPORTED_LOCATION_${CONFIGURATION})
# Get Embree SYCL info
get_target_property(CONFIGURATIONS embree_sycl IMPORTED_CONFIGURATIONS)
list(GET CONFIGURATIONS 0 CONFIGURATION)
get_target_property(EMBREE_SYCL_LIBRARY embree_sycl
IMPORTED_LOCATION_${CONFIGURATION})

message(STATUS "Found Embree v${embree_VERSION}: ${EMBREE_LIBRARY}")
endmacro()

Expand Down
6 changes: 4 additions & 2 deletions cmake/ospray_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(OSPRAY_CMAKECONFIG_DIR

set(ISPC_VERSION_REQUIRED 1.18.0)
set(RKCOMMON_VERSION_REQUIRED 1.10.0)
set(EMBREE_VERSION_REQUIRED 3.13.1)
set(EMBREE_VERSION_REQUIRED 4.0.0)
set(OPENVKL_VERSION_REQUIRED 1.3.0)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
Expand All @@ -38,7 +38,9 @@ ospray_verify_embree_features()
ospray_determine_embree_isa_support()

# Open VKL
ospray_find_openvkl(${OPENVKL_VERSION_REQUIRED})
if (OSPRAY_ENABLE_VOLUMES)
ospray_find_openvkl(${OPENVKL_VERSION_REQUIRED})
endif()

# OpenImageDenoise
if (OSPRAY_MODULE_DENOISER)
Expand Down
Loading

0 comments on commit 078c589

Please sign in to comment.