<div>Dear Blenderheads,</div><div>Hope all is well.</div><div>i got someone to have a look at cycles from the AMD developer forum.</div><div>THIS IS WHAT THEY DID:</div><div>Source:(<a href="http://devgurus.amd.com/message/1286178#1286178">http://devgurus.amd.com/message/1286178#1286178</a>)</div>
<div>--------------------------------------------------------------------------------------------------------------------------------------</div><div>--------------------------------------------------------------------------------------------------------------------------------------</div>
<div><div><i>Hi Nazim,</i></div><div><i> </i></div><div><i>I am able to compile the &quot;<a href="http://kernel.cl">kernel.cl</a>&quot; and create a kernel object (clCreateKernel) for &quot;kernel_ocl_path_trace&quot;.</i></div>
<div><i>I see that one of the kernels is commented in &quot;<a href="http://kernel.cl">kernel.cl</a>&quot; (kernel_ocl_shader). Hope this is intended.</i></div><div><i> </i></div><div><i> </i></div><div><i>I am on a windows 7 64-bit system with AMD Cayman GPU.</i></div>
<div><i>But the application is 32-bit only.</i></div><div><i>AMD APP 2.8 (32-bit) is installed on my machine</i></div><div><i>The driver version I see in device manager is 9.2.0.0</i></div><div><i>The driver packaging version I see in AMD control center is 9.002-120928m-xxxxxxxx</i></div>
<div><i>Catalyst version 12.10</i></div><div><i> </i></div><div><i> </i></div><div><i>While compiling <a href="http://kernel.cl">kernel.cl</a>, the maximum memory usage of the application was ~525MB.</i></div><div><i>How much memory do you have on your machines?</i></div>
<div><i>I will post the exact code snippets that I used in the next post.</i></div><div><i> </i></div><div><i>Best Regards,</i></div><div><i>Work Item 6</i></div></div><div><i>.......................................................................</i></div>
<div><div style="font-style:italic">Here is a copy of the host code that I used to compile in Windows using Visual Studio 2010. Note that OCL is a helper C++ class that I use for internal use. It just avoids the hassle of complex initialization.</div>
<div style="font-style:italic"> </div><div style="font-style:italic">#include &lt;Windows.h&gt;</div><div style="font-style:italic">#include &lt;WinBase.h&gt;</div><div style="font-style:italic">#include &lt;ocl.hpp&gt;</div>
<div style="font-style:italic">#include &lt;iostream&gt;</div><div style="font-style:italic"><br></div><div style="font-style:italic">int main()</div><div style="font-style:italic">{</div><div style="font-style:italic">     ocl::platform_t platformType = ocl::platform_t::amd;</div>
<div style="font-style:italic">     ocl::device_t deviceType = ocl::device_t::gpu;</div><div style="font-style:italic"><br></div><div style="font-style:italic">     ocl O(platformType, deviceType);</div><div style="font-style:italic">
<br></div><div style="font-style:italic">     HANDLE fileHandle = CreateFile(&quot;<a href="http://kernel.cl">kernel.cl</a>&quot;, GENERIC_READ, FILE_SHARE_READ, NULL, </div><div style="font-style:italic">                                             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);</div>
<div style="font-style:italic">     HANDLE mapHandle = CreateFileMapping(fileHandle, NULL, PAGE_READONLY, 0, 0, NULL);</div><div style="font-style:italic">     LPVOID fileContent = MapViewOfFile(mapHandle, FILE_MAP_READ, 0, 0, 0);</div>
<div style="font-style:italic">     DWORD size = GetFileSize(fileHandle, NULL);</div><div style="font-style:italic"><br></div><div style="font-style:italic">      cl_int err = O.buildKernel((const char*)fileContent, &quot;kernel_ocl_path_trace&quot;, &quot;-I.&quot; );</div>
<div style="font-style:italic">      std::cout &lt;&lt; &quot;Build Kernel Returned &quot; &lt;&lt; err &lt;&lt; std::endl;</div><div style="font-style:italic">      return 0;</div><div style="font-style:italic">                                                             .................................................................................</div>
<div style="font-style:italic"><div>The buildKernel in OCL wrapper does this:</div><div>{</div><div>    int err;</div><div>    char* buildLog = NULL;</div><div>    size_t buildLogSize = 0;</div><div><br></div><div>    program = clCreateProgramWithSource(context, 1, &amp;kernelString, NULL, &amp;err);</div>
<div>    if(err != CL_SUCCESS)</div><div>    {</div><div>        #ifndef PRINT_MUTE</div><div>            std::cerr &lt;&lt; &quot; ocl: couldn&#39;t create program from the provided kernel string &quot; &lt;&lt; err &lt;&lt; std::endl;</div>
<div>        #endif</div><div>        return err;</div><div>    }</div><div><br></div><div>    err = clBuildProgram(program, 1, &amp;device_id, buildOptions, NULL, NULL);</div><div>    if(err != CL_SUCCESS)</div><div>    {</div>
<div>        clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &amp;buildLogSize);</div><div>        buildLog = (char*)(::malloc)(buildLogSize+1);</div><div><br></div><div>        #ifndef PRINT_MUTE</div>
<div>            std::cerr &lt;&lt; &quot; ocl: Failed to build program executable Build log Size:&quot; &lt;&lt; buildLogSize &lt;&lt; &quot;\tBuild Log:\n&quot;;</div><div>        #endif</div><div>        clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, NULL);</div>
<div>        #ifndef PRINT_MUTE</div><div>            std::cerr &lt;&lt; buildLog &lt;&lt; std::endl;</div><div>        #endif</div><div>        ::free(buildLog);;</div><div>        return err;</div><div>    }</div><div><br>
</div><div>    kernel = clCreateKernel(program, kernelFuncName, &amp;err);</div><div>    if ( (!kernel) || (err != CL_SUCCESS) )</div><div>    {</div><div>        #ifndef PRINT_MUTE</div><div>            std::cerr &lt;&lt; &quot;ocl: kernel could not be created &quot; &lt;&lt; err &lt;&lt; std::endl;</div>
<div>        #endif</div><div>        return err;</div><div>    }</div><div>    return err;</div><div>}</div></div><div style="font-style:italic">                                                 .............................................................................................</div>
<div style="font-style:italic"><div>Hi Nazim,</div><div> </div><div>Since the peak memory consumption is 512MB, this can be a problem</div><div>if your application has already loaded a lot of memory (in the form of </div>
<div>images or frames or any others).</div><div>As a workaround, Consider compiling the OpenCL program at start of day --</div><div>before loading any images or frames or whatever. Once the compilation is done, </div><div>
the memory consumption goes back to normal and hence you will have enough </div><div>memory to do your other operations....This can be a workaround.</div><div> </div><div>Best Regards,</div><div>WorkItem 6</div></div><div style="font-style:italic">
<br></div><div style="font-style:italic">------------------------------------------------------------------------------------------------------------------------------------------------------------</div><div style="font-style:italic">
<br></div><div>I hope that this is in favor of all parties involved with cycles(mostly brecht and his vision on cycles, developers, and AMD GPU card owners ).</div></div><div><br></div><div>Kind Regards,</div><div><br></div>
<div>Nazim</div>