<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Stack overflow with Custom BVH builder in Intel® Embree Ray Tracing Kernels</title>
    <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204362#M858</link>
    <description>&lt;P&gt;Few more remarks:&lt;/P&gt;
&lt;P&gt;I take back my previous comment of the app being stuck in and endless loop on my machine. It seems it finishes but it just takes a very long time. Probably a combination of the app and Embree being run in DEBUG mode on my system and using only a single thread.&lt;/P&gt;
&lt;P&gt;About your questions:&lt;/P&gt;
&lt;P&gt;Do you infer the 500-1000% increase from the number of splitPrimitives()? That is misleading as Embree can call the splitFunction many more times than the number of input primitives.&lt;/P&gt;
&lt;P&gt;Under certain conditions our spatial split builder can create empty leaves, so a small number of those is not surprising.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Aug 2020 17:18:16 GMT</pubDate>
    <dc:creator>BenthinC_Intel</dc:creator>
    <dc:date>2020-08-26T17:18:16Z</dc:date>
    <item>
      <title>Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204237#M855</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm now trying to use custom BVH builder with rtcBuildBVH.&lt;BR /&gt;I attached the program files I used.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Embree 3.11.0&lt;/LI&gt;
&lt;LI&gt;Visual Studio 2019 16.7.2&lt;/LI&gt;
&lt;LI&gt;Core i9 9900K&lt;/LI&gt;
&lt;LI&gt;Windows 10 Pro 1909&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;It succeeds to build custom BVHs with low/medium quality settings but sometimes fails&amp;nbsp;due to stack overflow or produces a BVH with overusing primitive list size when using high-quality builder.&lt;/P&gt;
&lt;P&gt;Steps to reproduce:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Download Amazon Lumberyard Bistro 3D model from&amp;nbsp;&lt;A href="https://casual-effects.com/data/" target="_blank"&gt;https://casual-effects.com/data/&lt;/A&gt;&lt;BR /&gt;Sorry for the huge file for repro.&lt;/LI&gt;
&lt;LI&gt;Build the attached program with Release build (the issue happens also with Debug).&lt;/LI&gt;
&lt;LI&gt;Execute the program with&amp;nbsp;the path to Exterior\exterior.obj as the command line argument.&lt;/LI&gt;
&lt;LI&gt;I see the stack overflow exception during rtcBuildBVH().&lt;BR /&gt;The attached picture is the call stack window in Visual Studio.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="embree_stack_overflow.png" style="width: 505px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/12428iCAA69470E14079F3/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="embree_stack_overflow.png" alt="embree_stack_overflow.png" /&gt;&lt;/span&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I allocated 100% extra space for spatial splitting, I see the stack overflow with above settings but sometimes see that the build itself finishes but it produces primitive reference list of size over 200% of the original primitive list size (like 500% - 1000%).&lt;/P&gt;
&lt;P&gt;I have several questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is there my mistake or is this a known bug?&lt;/LI&gt;
&lt;LI&gt;If I do the above experiment but with multiple threads (by specifying "threads=0" at rtcNewDevice()), it succeeds to build but it gets small amount of leaf node creations with 0 primitives, is this expected behavior?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 07:52:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204237#M855</guid>
      <dc:creator>shocker_0x15</dc:creator>
      <dc:date>2020-08-26T07:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204239#M856</link>
      <description>&lt;P&gt;I reused Embree's internal splitting function but with own types as&amp;nbsp;splitPrimitive function.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 07:57:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204239#M856</guid>
      <dc:creator>shocker_0x15</dc:creator>
      <dc:date>2020-08-26T07:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204315#M857</link>
      <description>&lt;P&gt;Looking at it right now...&lt;/P&gt;
&lt;P&gt;Few things I noticed so far:&lt;/P&gt;
&lt;P&gt;I don't get a crash on my machine with your code but the BVH build process simply gets stuck and never finishes.&lt;/P&gt;
&lt;P&gt;Rendering the exterior obj file with Embree's viewer tutorial and the spatial split builder seems to work fine. Cmd line I've used:&lt;/P&gt;
&lt;P&gt;viewer.exe -i ..\..\..\lumberjack\Exterior\exterior.obj -verbose 2 --rtcore quality=high,max_spatial_split_replications=2&lt;/P&gt;
&lt;P&gt;Also when I replace the splitting function in your code with the simple version from our bvh_builder tutorial it works as well. I guess the new splitting function is somehow causing the BVH build process getting stuck but I don't know why yet.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 14:42:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204315#M857</guid>
      <dc:creator>BenthinC_Intel</dc:creator>
      <dc:date>2020-08-26T14:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204362#M858</link>
      <description>&lt;P&gt;Few more remarks:&lt;/P&gt;
&lt;P&gt;I take back my previous comment of the app being stuck in and endless loop on my machine. It seems it finishes but it just takes a very long time. Probably a combination of the app and Embree being run in DEBUG mode on my system and using only a single thread.&lt;/P&gt;
&lt;P&gt;About your questions:&lt;/P&gt;
&lt;P&gt;Do you infer the 500-1000% increase from the number of splitPrimitives()? That is misleading as Embree can call the splitFunction many more times than the number of input primitives.&lt;/P&gt;
&lt;P&gt;Under certain conditions our spatial split builder can create empty leaves, so a small number of those is not surprising.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 17:18:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204362#M858</guid>
      <dc:creator>BenthinC_Intel</dc:creator>
      <dc:date>2020-08-26T17:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204363#M859</link>
      <description>&lt;P&gt;BTW: That's what I get one my machine (used maxDepth=32,maxLeafSize=8).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start loading assimp scene: ..\..\..\Exterior\exterior.obj ... done.&lt;BR /&gt;Generate RTCBuildPrimitive's ... done.&lt;BR /&gt;buildArgs.primitiveCount &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2837137&lt;BR /&gt;&amp;nbsp;buildArgs.primitiveArrayCapacity 5674274&lt;BR /&gt;&amp;nbsp;Build BVH ... done.&lt;BR /&gt;InternalNode::create(): 381669&lt;BR /&gt;LeafNode::create(): 1145004 (null: 35)&lt;BR /&gt;splitPrimitives(): 156214674&lt;BR /&gt;Convert BVH ... done.&lt;BR /&gt;Calculate Statistics ... done.&lt;BR /&gt;SAH Cost: 83.7197&lt;BR /&gt;Num Primitives: 2837137&lt;BR /&gt;Num Primitive References: 3744814 (132.0%)&lt;BR /&gt;Num Internal Nodes: 381669&lt;BR /&gt;&amp;nbsp;1 children: 11&lt;BR /&gt;&amp;nbsp;2 children: 1&lt;BR /&gt;&amp;nbsp;3 children: 4&lt;BR /&gt;&amp;nbsp;4 children: 381653&lt;BR /&gt;Num Leaf Nodes: 1144969&lt;BR /&gt;Min/Max/Mean Num Leaves: 1 / 8 / 3.3&lt;BR /&gt;Min/Max Depth: 4 / 25&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 17:20:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204363#M859</guid>
      <dc:creator>BenthinC_Intel</dc:creator>
      <dc:date>2020-08-26T17:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204371#M860</link>
      <description>&lt;P&gt;Thanks for checking the app.&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;Do you infer the 500-1000% increase from the number of splitPrimitives()?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;No, the percentage comes from the number of primitive references in the end, so it corresponds to:&amp;nbsp;&lt;SPAN&gt;Num Primitive References: 3744814 (&lt;STRONG&gt;132.0%&lt;/STRONG&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I try to increase the stack size from the default to 4MiB, it succeeds to build with HQ settings (200%).&lt;BR /&gt;However your last reply gave me a hint and I noticed that the maximum depth setting seems stupidly large... I got a success with maximum depth == 32&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I got more questions:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Does custom BVH builder deterministically build a BVH even with multi-threading from the viewpoint of tree structure?&lt;/LI&gt;
&lt;LI&gt;What does sahBlockSize argument mean? Is this something like the number of bins during object/spatial splitting?&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 26 Aug 2020 17:52:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204371#M860</guid>
      <dc:creator>shocker_0x15</dc:creator>
      <dc:date>2020-08-26T17:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204379#M861</link>
      <description>&lt;P&gt;The standard SAH builder is deterministic in a multi-threaded environment but the spatial split builder is not. When the number of possible spatial splits exceeds the spatial split budget in a given subtree, the build algorithm will fill up the limited spatial split budget aggressively using multiple threads, which introduces non-deterministic splitting at this point.&lt;/P&gt;
&lt;P&gt;sahBlockSize is used when computing the SAH of potential splits. For example in&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/embree/embree/blob/master/kernels/builders/heuristic_binning.h" target="_blank"&gt;https://github.com/embree/embree/blob/master/kernels/builders/heuristic_binning.h&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;line 359-373 the value blocks_shift is used which is basically log(sahBlockSize). If you build for example a 4-wide BVH you get a better quality BVH if you use a block size of 4.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 18:21:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204379#M861</guid>
      <dc:creator>BenthinC_Intel</dc:creator>
      <dc:date>2020-08-26T18:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Stack overflow with Custom BVH builder</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204383#M862</link>
      <description>&lt;P&gt;Thanks for the fast reply.&lt;/P&gt;
&lt;P&gt;I understand the determinism and will see the code to understand what the block size is.&lt;/P&gt;
&lt;P&gt;I'm not sure why I saw over use the split budget in certain conditions but I guess it is the result of multi-thread racing with bad argument (max depth == 1024) and it will not happen with the current setting (max depth == 32).&lt;/P&gt;
&lt;P&gt;Therefore I'll make this issue resolved.&lt;/P&gt;
&lt;P&gt;Thanks for the support!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 18:28:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Stack-overflow-with-Custom-BVH-builder/m-p/1204383#M862</guid>
      <dc:creator>shocker_0x15</dc:creator>
      <dc:date>2020-08-26T18:28:05Z</dc:date>
    </item>
  </channel>
</rss>

