Skip to content

Commit

Permalink
[WIP] port forest tutorial to new host/device memory support
Browse files Browse the repository at this point in the history
  • Loading branch information
freibold committed Nov 27, 2024
1 parent 190b4aa commit 96782b9
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 109 deletions.
9 changes: 1 addition & 8 deletions common/cmake/dpcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,7 @@ IF (EMBREE_SYCL_SUPPORT)
SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} /debug:none") # FIXME: debug information generation takes forever in SYCL
SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} /DNDEBUG") # FIXME: debug information generation takes forever in SYCL
ELSE()
message("CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
if((CMAKE_BUILD_TYPE STREQUAL "Debug"))
message(STATUS "generate debug information")
SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -g") # FIXME: debug information generation takes forever in SYCL
else()
message(STATUS "generate NO debug information")
SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -g0") # FIXME: debug information generation takes forever in SYCL
endif()
SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -g0") # FIXME: debug information generation takes forever in SYCL
SET(CMAKE_CXX_FLAGS_SYCL "${CMAKE_CXX_FLAGS_SYCL} -UDEBUG -DNDEBUG") # FIXME: assertion still not working in SYCL
ENDIF()

Expand Down
14 changes: 12 additions & 2 deletions common/sys/alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ namespace embree
total_allocations++;

void* ptr = nullptr;
if (mode == EMBREE_USM_SHARED_DEVICE_READ_ONLY)
if (mode == EMBREE_USM_SHARED_DEVICE_READ_ONLY) {
std::cout << "XXX shared memory allocation!" << std::endl;
ptr = sycl::aligned_alloc_shared(align,size,*device,*context,sycl::ext::oneapi::property::usm::device_read_only());
else
}
else {
std::cout << "XXX shared memory allocation!" << std::endl;
ptr = sycl::aligned_alloc_shared(align,size,*device,*context);
}

if (size != 0 && ptr == nullptr)
throw std::bad_alloc();
Expand All @@ -114,9 +118,15 @@ namespace embree
void* ptr = nullptr;
if (type == EmbreeMemoryType::SHARED) {
if (mode == EMBREE_USM_SHARED_DEVICE_READ_ONLY)
{
std::cout << "XXX shared memory allocation!" << std::endl;
ptr = sycl::aligned_alloc_shared(align,size,*device,*context,sycl::ext::oneapi::property::usm::device_read_only());
}
else
{
std::cout << "XXX shared memory allocation!" << std::endl;
ptr = sycl::aligned_alloc_shared(align,size,*device,*context);
}
}
else if (type == EmbreeMemoryType::HOST) {
ptr = sycl::aligned_alloc_host(align,size,*context);
Expand Down
5 changes: 5 additions & 0 deletions include/embree4/rtcore_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ RTC_API void rtcCommitBufferWithQueue(RTCBuffer buffer, sycl::queue queue);
/* Returns a pointer to the buffer data. */
RTC_API void* rtcGetBufferData(RTCBuffer buffer);

/* Returns a pointer to the buffer data on the device. Returns the same pointer as
rtcGetBufferData if the device is no SYCL device or if Embree is executed on a
system with unified memory (e.g., iGPUs). */
RTC_API void* rtcGetBufferDataDevice(RTCBuffer buffer);

/* Retains the buffer (increments the reference count). */
RTC_API void rtcRetainBuffer(RTCBuffer buffer);

Expand Down
15 changes: 15 additions & 0 deletions kernels/common/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ namespace embree
return ptr;
}

/*! gets buffer pointer */
void* dataDevice()
{
/* report error if buffer is not existing */
if (!device)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "invalid buffer specified");

/* return buffer */
#if defined(EMBREE_SYCL_SUPPORT)
return dptr;
#else
return ptr;
#endif
}

/*! returns pointer to first element */
__forceinline char* getPtr() const {
return ptr;
Expand Down
12 changes: 12 additions & 0 deletions kernels/common/rtcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ RTC_NAMESPACE_BEGIN;
return nullptr;
}

RTC_API void* rtcGetBufferDataDevice(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetBufferDataDevice);
RTC_VERIFY_HANDLE(hbuffer);
RTC_ENTER_DEVICE(hbuffer);
return buffer->dataDevice();
RTC_CATCH_END2(buffer);
return nullptr;
}

RTC_API void* rtcGetBufferData(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
Expand Down
2 changes: 1 addition & 1 deletion kernels/sycl/rthwif_embree_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ namespace embree
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "AccelBuffer constructor called with non-GPU device");
}

unifiedMemory = true; //gpu_device->has_unified_memory();
unifiedMemory = gpu_device->has_unified_memory();

if (unifiedMemory)
{
Expand Down
66 changes: 33 additions & 33 deletions tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,40 +79,40 @@ IF (EMBREE_TUTORIALS_GLFW)
ENDIF()

ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(embree_info)
ADD_SUBDIRECTORY(minimal)
ADD_SUBDIRECTORY(verify)
ADD_SUBDIRECTORY(triangle_geometry)
ADD_SUBDIRECTORY(dynamic_scene)
ADD_SUBDIRECTORY(voronoi)
ADD_SUBDIRECTORY(closest_point)
ADD_SUBDIRECTORY(user_geometry)
ADD_SUBDIRECTORY(viewer)
ADD_SUBDIRECTORY(instanced_geometry)
ADD_SUBDIRECTORY(multi_instanced_geometry)
ADD_SUBDIRECTORY(intersection_filter)
ADD_SUBDIRECTORY(pathtracer)
ADD_SUBDIRECTORY(hair_geometry)
ADD_SUBDIRECTORY(subdivision_geometry)
ADD_SUBDIRECTORY(displacement_geometry)
ADD_SUBDIRECTORY(grid_geometry)
ADD_SUBDIRECTORY(bvh_builder)
ADD_SUBDIRECTORY(lazy_geometry)
ADD_SUBDIRECTORY(bvh_access)
ADD_SUBDIRECTORY(quaternion_motion_blur)
ADD_SUBDIRECTORY(motion_blur_geometry)
ADD_SUBDIRECTORY(interpolation)
ADD_SUBDIRECTORY(curve_geometry)
ADD_SUBDIRECTORY(point_geometry)
ADD_SUBDIRECTORY(buildbench)
ADD_SUBDIRECTORY(convert)
ADD_SUBDIRECTORY(collide)
ADD_SUBDIRECTORY(next_hit)
ADD_SUBDIRECTORY(multiscene_geometry)
ADD_SUBDIRECTORY(ray_mask)
#ADD_SUBDIRECTORY(embree_info)
#ADD_SUBDIRECTORY(minimal)
#ADD_SUBDIRECTORY(verify)
#ADD_SUBDIRECTORY(triangle_geometry)
#ADD_SUBDIRECTORY(dynamic_scene)
#ADD_SUBDIRECTORY(voronoi)
#ADD_SUBDIRECTORY(closest_point)
#ADD_SUBDIRECTORY(user_geometry)
#ADD_SUBDIRECTORY(viewer)
#ADD_SUBDIRECTORY(instanced_geometry)
#ADD_SUBDIRECTORY(multi_instanced_geometry)
#ADD_SUBDIRECTORY(intersection_filter)
#ADD_SUBDIRECTORY(pathtracer)
#ADD_SUBDIRECTORY(hair_geometry)
#ADD_SUBDIRECTORY(subdivision_geometry)
#ADD_SUBDIRECTORY(displacement_geometry)
#ADD_SUBDIRECTORY(grid_geometry)
#ADD_SUBDIRECTORY(bvh_builder)
#ADD_SUBDIRECTORY(lazy_geometry)
#ADD_SUBDIRECTORY(bvh_access)
#ADD_SUBDIRECTORY(quaternion_motion_blur)
#ADD_SUBDIRECTORY(motion_blur_geometry)
#ADD_SUBDIRECTORY(interpolation)
#ADD_SUBDIRECTORY(curve_geometry)
#ADD_SUBDIRECTORY(point_geometry)
#ADD_SUBDIRECTORY(buildbench)
#ADD_SUBDIRECTORY(convert)
#ADD_SUBDIRECTORY(collide)
#ADD_SUBDIRECTORY(next_hit)
#ADD_SUBDIRECTORY(multiscene_geometry)
#ADD_SUBDIRECTORY(ray_mask)
ADD_SUBDIRECTORY(forest)
ADD_SUBDIRECTORY(debug_device_memory)
ADD_SUBDIRECTORY(embree_tests)
#ADD_SUBDIRECTORY(debug_device_memory)
#ADD_SUBDIRECTORY(embree_tests)


ENDIF()
Loading

0 comments on commit 96782b9

Please sign in to comment.