<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 "<a href="http://kernel.cl">kernel.cl</a>" and create a kernel object (clCreateKernel) for "kernel_ocl_path_trace".</i></div>
<div><i>I see that one of the kernels is commented in "<a href="http://kernel.cl">kernel.cl</a>" (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 <Windows.h></div><div style="font-style:italic">#include <WinBase.h></div><div style="font-style:italic">#include <ocl.hpp></div>
<div style="font-style:italic">#include <iostream></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("<a href="http://kernel.cl">kernel.cl</a>", 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, "kernel_ocl_path_trace", "-I." );</div>
<div style="font-style:italic"> std::cout << "Build Kernel Returned " << err << 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, &kernelString, NULL, &err);</div>
<div> if(err != CL_SUCCESS)</div><div> {</div><div> #ifndef PRINT_MUTE</div><div> std::cerr << " ocl: couldn't create program from the provided kernel string " << err << std::endl;</div>
<div> #endif</div><div> return err;</div><div> }</div><div><br></div><div> err = clBuildProgram(program, 1, &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, &buildLogSize);</div><div> buildLog = (char*)(::malloc)(buildLogSize+1);</div><div><br></div><div> #ifndef PRINT_MUTE</div>
<div> std::cerr << " ocl: Failed to build program executable Build log Size:" << buildLogSize << "\tBuild Log:\n";</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 << buildLog << std::endl;</div><div> #endif</div><div> ::free(buildLog);;</div><div> return err;</div><div> }</div><div><br>
</div><div> kernel = clCreateKernel(program, kernelFuncName, &err);</div><div> if ( (!kernel) || (err != CL_SUCCESS) )</div><div> {</div><div> #ifndef PRINT_MUTE</div><div> std::cerr << "ocl: kernel could not be created " << err << 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>