4 Replies Latest reply on Dec 10, 2008 12:30 PM by entity279

    Global stream variables

    entity279

         Well it's just that i need some help with the app I'm working on..  I have a .br file in my project and it has function(that wraps several kernels) that keeps getting called.

         In order to improve the performance a little, I found a stream that stays the same every time the function is called. So I was trying to make it a global stream in the file in order to use streamRead() only once for the data contained in it. Ok, but the problem is that if I declare it globaly, i must also specify its size from the start .

         And the size is variable so.. The result is that i've declared it something like this

            int size=0;

           float globalStream; and the obvious problem is that althought i've obtained my global stream, and the actual value of size is computed at the first instruction of the called function of the .br file, the stream will always have zero size.

           Since there are no pointers to streams and streams cannot be resized explictly as far as i know, I'm asking for any workaround you may think of in my case. Thank you.



        • Global stream variables
          jean-claude

          Hi,

          Interesting... After guessing, this is what I would try and do :

          Assume your br source file is "file_brook.br"

          and that so far you have something in it such as

          float2 my_stream<h,w>;

          obviusly this doen't satisfy you since you :

          (1) would want my_stream to be global

          (2) at init time you don't know the size of the stream

          Anyway, after precompile you get a file : file_brook.cpp and somewhere in it :

          ::brook::stream my_stream(::brook::getStreamType(( float2  *)0), h , w,-1);

          This will have to be replaced by hand...

           

          So what I suggest is that you edit file_brook.cpp and

          (1) add :

          ::brook::stream my_stream;      // outside any function so that my_stream is global

          (2) and then replace :

          ::brook::stream my_stream(::brook::getStreamType(( float2  *)0), h , w,-1);

          with

          my_stream.create<float2>(h ,w);

           

          Not fully sure, but this may give you a hint on how to solve your issue.

          Let us know how it works.

          Regars

          Jean-Claude

           

            • Global stream variables
              entity279

              I see. Will try today hopefully

              Actually, I already see the problem in your proposal..

              It's that file_brook.cpp has changed thus forcing the entire project to recompile. I don't know why, but since the mandatory use of x64 compiler on x64 systems (such as mine), Visual Studio ALWAYS rebuilds the .cpp file out of the .br file, no matter what.

              The only thing I could try is build the .cpp file out of the final source, exclude the .br file of the project, make the modifications you suggested and afterwrds rebuild the project.

                • Global stream variables
                  jean-claude

                  Yes,

                  What you merely do is :

                  (1) compile with the final .br code

                  (2) in Visual Studio: right click on .br file in your Solution explorer pane and set its properties to "exclude from build"

                  (3) do the suggested editing

                  (4) compile whole project

                  That should be ok.

                  let's know how it goes...

                    • Global stream variables
                      entity279

                      Ok, I've tried it but the consequent  streamRead crashes with memory acces violations

                      book.create<float>( linear_codebook_lenght,0);//tried with single parameter as well, same problem
                      streamRead(book, vectors);

                      It would seem the use of ::getStreamType(...) is compulsory, right? Maybe I could figure a way to go with this.