Skip to content

Commit

Permalink
rename host_device_memory tutorial and add CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freibold committed Dec 5, 2024
1 parent cb89398 commit 8e98a76
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 386 deletions.
2 changes: 1 addition & 1 deletion tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ADD_SUBDIRECTORY(next_hit)
ADD_SUBDIRECTORY(multiscene_geometry)
ADD_SUBDIRECTORY(ray_mask)
ADD_SUBDIRECTORY(forest)
ADD_SUBDIRECTORY(debug_device_memory)
ADD_SUBDIRECTORY(host_device_memory)
ADD_SUBDIRECTORY(embree_tests)


Expand Down
11 changes: 0 additions & 11 deletions tutorials/debug_device_memory/CMakeLists.txt

This file was deleted.

227 changes: 0 additions & 227 deletions tutorials/debug_device_memory/debug_device_memory_device.ispc

This file was deleted.

25 changes: 0 additions & 25 deletions tutorials/debug_device_memory/debug_device_memory_device.isph

This file was deleted.

28 changes: 21 additions & 7 deletions tutorials/forest/forest_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,16 @@ void update_trees(float time)
rtcGetSceneBounds(scene_terrain, &bounds);

RTCTraversable traversable = rtcGetSceneTraversable(scene_terrain);
TutorialData ldata = data;
unsigned int lnum_trees_sqrt = num_trees_sqrt;

#if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION)
unsigned int* tree_ids = data.tree_ids_device;
AffineSpace3fa* tree_transforms = data.tree_transforms_device;
#else
unsigned int* tree_ids = data.tree_ids_host;
AffineSpace3fa* tree_transforms = data.tree_transforms_host;
#endif

#if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION)
unsigned int lnum_trees = num_trees;
sycl::event event = global_gpu_queue->submit([=](sycl::handler& cgh) {
Expand All @@ -161,7 +168,7 @@ void update_trees(float time)
#endif
RandomSampler rng;
RandomSampler_init(rng, t);
ldata.tree_ids_device[t] = min(5, (int)(6 * RandomSampler_getFloat(rng)));
tree_ids[t] = min(5, (int)(6 * RandomSampler_getFloat(rng)));

unsigned int j = t / lnum_trees_sqrt;
unsigned int i = t % lnum_trees_sqrt;
Expand Down Expand Up @@ -210,12 +217,12 @@ void update_trees(float time)
treePos = Vec3fa(inf, inf, inf);
}

ldata.tree_transforms_device[t] = AffineSpace3fa::translate(treePos);
tree_transforms[t] = AffineSpace3fa::translate(treePos);
#if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION)
});
});
global_gpu_queue->memcpy(ldata.tree_ids_host, ldata.tree_ids_device, sizeof(uint32_t)*num_trees);
global_gpu_queue->memcpy(ldata.tree_transforms_host, ldata.tree_transforms_device, sizeof(AffineSpace3fa)*num_trees);
global_gpu_queue->memcpy(data.tree_ids_host, data.tree_ids_device, sizeof(uint32_t)*num_trees);
global_gpu_queue->memcpy(data.tree_transforms_host, data.tree_transforms_device, sizeof(AffineSpace3fa)*num_trees);
global_gpu_queue->wait_and_throw();
#else
}});
Expand Down Expand Up @@ -293,10 +300,17 @@ void rebuild_instances(size_t old_num_trees)

if (g_use_instance_array)
{
#if defined(EMBREE_SYCL_TUTORIAL)
void* tree_ids_device = data.tree_ids_device;
void* tree_transforms_device = data.tree_transforms_device;
#else
void* tree_ids_device = nullptr;
void* tree_transforms_device = nullptr;
#endif
instance_array = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE_ARRAY);
rtcSetGeometryInstancedScenes(instance_array,(RTCScene*)scene_trees_selected,6);
rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, (void*)data.tree_ids_host, (void*)data.tree_ids_device, 0, sizeof(unsigned int), num_trees);
rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_TRANSFORM, 0, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, (void*)data.tree_transforms_host, (void*)data.tree_transforms_device, 0, sizeof(AffineSpace3fa), num_trees);
rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, (void*)data.tree_ids_host, tree_ids_device, 0, sizeof(unsigned int), num_trees);
rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_TRANSFORM, 0, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, (void*)data.tree_transforms_host, tree_transforms_device, 0, sizeof(AffineSpace3fa), num_trees);
rtcAttachGeometry(data.g_scene,instance_array);
rtcReleaseGeometry(instance_array);
rtcCommitGeometry(instance_array);
Expand Down
12 changes: 12 additions & 0 deletions tutorials/host_device_memory/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Copyright 2009-2021 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

IF (EMBREE_GEOMETRY_TRIANGLE)

INCLUDE(tutorial)
ADD_TUTORIAL(host_device_memory)
ADD_TUTORIAL_SYCL(host_device_memory)

ADD_EMBREE_TEST_ECS(host_device_memory embree_host_device_memory ARGS NO_ISPC)

ENDIF()
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "../common/tutorial/benchmark_render.h"

#if defined(EMBREE_SYCL_TUTORIAL)
# define NAME "debug_device_memory_sycl"
# define NAME "host_device_memory_sycl"
# define FEATURES FEATURE_RTCORE | FEATURE_SYCL
#else
# define NAME "debug_device_memory"
# define NAME "host_device_memory"
# define FEATURES FEATURE_RTCORE
#endif

Expand All @@ -30,7 +30,7 @@ namespace embree
int main(int argc, char** argv) {
try {
if (embree::TutorialBenchmark::benchmark(argc, argv)) {
return embree::TutorialBenchmark(embree::renderBenchFunc<embree::Tutorial>).main(argc, argv, "debug_device_memory");
return embree::TutorialBenchmark(embree::renderBenchFunc<embree::Tutorial>).main(argc, argv, "host_device_memory");
}
return embree::Tutorial().main(argc,argv);
} catch (std::exception& e ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EMBREE_GEOMETRY_TRIANGLE == ON
Binary file not shown.
Loading

0 comments on commit 8e98a76

Please sign in to comment.