3 Replies Latest reply on Aug 8, 2009 6:09 PM by Raistmer

    Allocate memory failed. How to clear memory on display card?

    codeboycjy

      Hi:
         Currently, we're doing ray tracing.
         And there is a problem for us. Each frame for our scene, we have to allocate memory on our display card. If the resolution is large ( such as 1280 * 1024 ), allocation for memory will failed because memory doesn't dissappear immiediately if stream is deleted on host side.

         Is there a way to clear the memory on GPU side?
         For example , i've a stream . And i want to resize it , so i have to delete the old one and create the new one, but it doesn't work every time because the memory is not deleted on GPU side immiediately.

        • Allocate memory failed. How to clear memory on display card?
          gaurav.garg

          Brook+ doesn't delete the memory immediately. It puts all the previously allocated memory in a cache (used in case application requires the same size memory) and deletes this memory only if GPU goes out of memory and Brook+ fails to allocate memory for new streams.

            • Allocate memory failed. How to clear memory on display card?
              codeboycjy

              We really appreciate ur help for us.

              Actually , for each pass during ray tracing there are different number of rays. And we have to copy some data back to CPU to do some work, the size of the data is the same with the ray number. But there is no domainSize for Stream<T>::write, in order to pass less data to CPU, we have to create a new stream with the specific size to exchange data with CPU. Here comes the problem, for large resolution, memory allocation will fail if we create new stream during each loop of ray tracing.( Of course here we delete the stream before creating a new one )

              Domain of stream neither solve the problem because it create new stream too. There is no domain size for write.

              So is there a way to solve it??

              for( loop )
              {
                  pass data to CPU ( size , ray number )
              }
              ( if the stream size doen't change, there will be more data passed to CPU unneccessarily. Actuall , the second time iteration , there are less rays. 

              Thanks for helping us!

              • Allocate memory failed. How to clear memory on display card?
                Raistmer
                Originally posted by: gaurav.garg

                Brook+ doesn't delete the memory immediately. It puts all the previously allocated memory in a cache (used in case application requires the same size memory) and deletes this memory only if GPU goes out of memory and Brook+ fails to allocate memory for new streams.


                It seems this connected with my problems with allocation temporary linear stream for 2D scatter stream.
                Will Brook+ free memory if such allocation fails (it needs this allocation internally, my code didn't ask to create any temporary streams) or will just report error?
                If second, how to force Brook+ to free memory ?

                ADDON: I intensivly use stream domains to return only part of 2D buffer to host memory. AFAIK Brook+ allocates new buffer internally for stream domain. This increase memory consumption. Does some way exist to tell Brook+ to free memory more agressively ?