<div dir="ltr">Hi,<div><br></div><div>Brecht, nice work indeed! :)</div><div><br></div><div>Stefan, sharing the stack is an interesting idea indeed, but there are techniques of stack-less BVH traversal. If i read it correct, that&#39;s exactly what was implemented in FireRays. Shouldn&#39;t be that hard to experiment with both shared stack and stackless implementations. Let me know if you&#39;re up to that tests or if me or Brecht can look into this (so we don&#39;t do duplicated work).</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 12:32 PM, Stefan Werner <span dir="ltr">&lt;<a href="mailto:swerner@smithmicro.com" target="_blank">swerner@smithmicro.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Impressive! That goes beyond what I’ve done so far. One thing we may want to test is to share the BVH traversal stack, my suspicion is that nvcc for Maxwell also reserves memory for every possible instance of the traversal function (triangle, hair, motion, SSS, etc).<br>
<br>
Next up in terms of breaking the memory barrier is using host memory when CUDA runs out of device memory, we’ve tested it extensively for 2D textures already in Poser. I’m working on a patch right now, it will just take a little time to make it work with 3d and bindless textures. When using host memory, I can throw GB’s worth of textures at an anemic GTX 460 (768MB VRAM).<br>
<span class="HOEnZb"><font color="#888888"><br>
-Stefan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 5/22/16, 6:53 PM, &quot;<a href="mailto:bf-cycles-bounces@blender.org">bf-cycles-bounces@blender.org</a> on behalf of Brecht Van Lommel&quot; &lt;<a href="mailto:bf-cycles-bounces@blender.org">bf-cycles-bounces@blender.org</a> on behalf of <a href="mailto:brechtvanlommel@pandora.be">brechtvanlommel@pandora.be</a>&gt; wrote:<br>
<br>
&gt;I&#39;ve added some optimizations for reducing stack memory usage here:<br>
&gt;<a href="https://developer.blender.org/D2023" rel="noreferrer" target="_blank">https://developer.blender.org/D2023</a><br>
&gt;<br>
&gt;On Wed, May 18, 2016 at 2:27 PM, Stefan Werner &lt;<a href="mailto:swerner@smithmicro.com">swerner@smithmicro.com</a>&gt; wrote:<br>
&gt;&gt; Don’t be too excited too early. The more I work with it, the more it looks<br>
&gt;&gt; like it’s just an elaborate workaround for compiler behavior. It appears<br>
&gt;&gt; that NVCC insists on inlining everything on Maxwell, ignoring any<br>
&gt;&gt; __noinline__ hints.  So far, there are no benefits whatsoever on Kepler,<br>
&gt;&gt; there NVCC appears to do the right thing out of the box.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I submitted a bug report to Nvidia about the difference in stack usage<br>
&gt;&gt; between Kepler and Maxwell last year, and it was marked as resolved and to<br>
&gt;&gt; be shipped in the next CUDA update. So maybe I shouldn’t spend too much time<br>
&gt;&gt; with it until we see CUDA 8.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; -Stefan<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; From: &lt;<a href="mailto:bf-cycles-bounces@blender.org">bf-cycles-bounces@blender.org</a>&gt; on behalf of Thomas Dinges<br>
&gt;&gt; &lt;<a href="mailto:blender@dingto.org">blender@dingto.org</a>&gt;<br>
&gt;&gt; Reply-To: Discussion list to assist Cycles render engine developers<br>
&gt;&gt; &lt;<a href="mailto:bf-cycles@blender.org">bf-cycles@blender.org</a>&gt;<br>
&gt;&gt; Date: Tuesday, May 17, 2016 at 4:45 PM<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; To: Discussion list to assist Cycles render engine developers<br>
&gt;&gt; &lt;<a href="mailto:bf-cycles@blender.org">bf-cycles@blender.org</a>&gt;<br>
&gt;&gt; Subject: Re: [Bf-cycles] split kernel and CUDA<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; That sounds promising, feel free to submit a patch for this and we can<br>
&gt;&gt; check. :)<br>
&gt;&gt;<br>
&gt;&gt; Am 17.05.2016 um 16:40 schrieb Stefan Werner:<br>
&gt;&gt;<br>
&gt;&gt; The patch is surprisingly clean. It removes some of the #ifdef<br>
&gt;&gt; __SPLIT_KERNEL__ blocks and unifies CPU, OpenCL and CUDA a bit more. I<br>
&gt;&gt; didn’t run a speed benchmark, and I wouldn’t even make speed the ultimate<br>
&gt;&gt; top priority: Right now, the problem we see in the field is that people are<br>
&gt;&gt; unable to use high-end gaming GPUs because the VRAM is so full of geometry<br>
&gt;&gt; and textures that the CUDA runtime doesn’t have room for kernel memory any<br>
&gt;&gt; more. On my 1664 core M4000 card, I see a simple kernel launch already<br>
&gt;&gt; taking ~1600MB of VRAM with almost empty scenes.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; It looks to me like the CUDA compiler reserves room for every stack instance<br>
&gt;&gt; of ShaderData (or other structs) in advance, and that sharing that memory<br>
&gt;&gt; instead of instantiating it separately is an easy way to reduce VRAM<br>
&gt;&gt; requirements without changing the code much.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; -Stefan<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; From: &lt;<a href="mailto:bf-cycles-bounces@blender.org">bf-cycles-bounces@blender.org</a>&gt; on behalf of Sergey Sharybin<br>
&gt;&gt; &lt;<a href="mailto:sergey.vfx@gmail.com">sergey.vfx@gmail.com</a>&gt;<br>
&gt;&gt; Reply-To: Discussion list to assist Cycles render engine developers<br>
&gt;&gt; &lt;<a href="mailto:bf-cycles@blender.org">bf-cycles@blender.org</a>&gt;<br>
&gt;&gt; Date: Tuesday, May 17, 2016 at 9:20 AM<br>
&gt;&gt; To: Discussion list to assist Cycles render engine developers<br>
&gt;&gt; &lt;<a href="mailto:bf-cycles@blender.org">bf-cycles@blender.org</a>&gt;<br>
&gt;&gt; Subject: Re: [Bf-cycles] split kernel and CUDA<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; hi,<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Lukas Stocker was doing experiments with CUDA split kernel. With the current<br>
&gt;&gt; design of the split it was taking more VRAM actually, AFAIR. Hopefully he&#39;ll<br>
&gt;&gt; read this mail and reply in more details.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Would be cool to have this front moving forward, but i fear we&#39;ll have to<br>
&gt;&gt; step back and reconsider some things about how split kernel works together<br>
&gt;&gt; with a regular one.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; There are interesting results on the stack memory! I can see number of spill<br>
&gt;&gt; loads go up tho, did you measure if it gives measurable render time<br>
&gt;&gt; slowdown? And how messy is the patch i wonder :)<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Tue, May 17, 2016 at 8:47 AM, Stefan Werner &lt;<a href="mailto:swerner@smithmicro.com">swerner@smithmicro.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; Has anyone experimented with building a split kernel for CUDA? It seems to<br>
&gt;&gt; me that this could lift some of the limitations on Nvidia hardware, such as<br>
&gt;&gt; the high memory requirements on cards with many CUDA cores or the driver<br>
&gt;&gt; time out. I just tried out what happens when I take the shared ShaderData<br>
&gt;&gt; (KernelGlobals.sd_input) from the split kernel into the CUDA kernel, as<br>
&gt;&gt; opposed to creating separate ShaderData structs on the stack, and it looks<br>
&gt;&gt; like it has an impact:<br>
&gt;&gt;<br>
&gt;&gt; before:<br>
&gt;&gt; ptxas info    : Compiling entry function &#39;kernel_cuda_branched_path_trace&#39;<br>
&gt;&gt; for &#39;sm_50&#39;<br>
&gt;&gt; ptxas info    : Function properties for kernel_cuda_branched_path_trace<br>
&gt;&gt;     68416 bytes stack frame, 1188 bytes spill stores, 3532 bytes spill loads<br>
&gt;&gt;<br>
&gt;&gt; after:<br>
&gt;&gt; ptxas info    : Compiling entry function &#39;kernel_cuda_branched_path_trace&#39;<br>
&gt;&gt; for &#39;sm_50&#39;<br>
&gt;&gt; ptxas info    : Function properties for kernel_cuda_branched_path_trace<br>
&gt;&gt;     58976 bytes stack frame, 1256 bytes spill stores, 3676 bytes spill loads<br>
&gt;&gt;<br>
&gt;&gt; -Stefan<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Bf-cycles mailing list<br>
&gt;&gt; <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
&gt;&gt; <a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt;<br>
&gt;&gt; With best regards, Sergey Sharybin<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt;<br>
&gt;&gt; Bf-cycles mailing list<br>
&gt;&gt;<br>
&gt;&gt; <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
&gt;&gt;<br>
&gt;&gt; <a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Bf-cycles mailing list<br>
&gt;&gt; <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
&gt;&gt; <a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
&gt;&gt;<br>
&gt;_______________________________________________<br>
&gt;Bf-cycles mailing list<br>
&gt;<a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
&gt;<a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
<br>
_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div><span style="color:rgb(102,102,102)">With best regards, Sergey Sharybin</span></div></div>
</div>