12 Replies Latest reply on Jun 25, 2008 11:42 PM by michael.chu

    Problem with getting brook+ program result

    kos

      I've sum test project working but i can't save result's to file, and program window disappears to quickly no matter what I'm trying to do: read from console or make infinity loop.

        • Problem with getting brook+ program result
          Ceq
          Visual Studio will pause the program window after execution, however looks like your program isn't finishing normally, but with some kind of error.
          If you just want a easy way to pause your program you can use this line in your code:

          system("pause");

          The program will stop execution until you press any key.
          If you use it after the program error it won't work (in the same way read from console or the inf loop fails), so you have to try several locations.
          Making a debug compilation and using the built in debugger is a better solution, you can insert breakpoints in your code and see step by step the excecution and variable data.
          Check your code because it could be you're using 'streamWrite' not reserving enough memory with malloc for the destination variable.
          • Problem with getting brook+ program result
            dukeleto
            edit: I hadn't seen the previous answer!
            • Problem with getting brook+ program result
              Ceq
              I think that is a stream allocation failure... probably related to CAL
              What GPU are you using?

              You can also try running it with the CPU backend, setting the environment variable BRT_RUNTIME=CPU
                • Problem with getting brook+ program result
                  kos

                   

                   I'm using Palit 2600XT sonic. Take a look at this code:

                  ::brook::stream A(::brook::getStreamType(( float *)0), Height , Width,-1);
                  ::brook::stream B(::brook::getStreamType(( float *)0), Width , Height,-1);
                  ::brook::stream C(::brook::getStreamType(( float *)0), Height , Height,-1);
                  Start(0);
                  getch();//1
                  streamRead(A, inputA);
                  getch();//2
                  streamRead(B, inputB);
                  for (i = 0; i < sizeof(inputA); ++i)
                  {
                  simple_matmult((float ) (Width), A, B, C);
                  }
                  The programs spops twice and there are now

                  "Unhandled exception at 0x00409ba1 in simple_matmult.exe: 0xC0000005: Access violation reading location 0x00000000."

                  I'm using CPU backend, may be problem is in "sizeof(inputA)" statement. I've changed original code to that becouse I've no console input

                    • Problem with getting brook+ program result
                      Ceq
                      Umh, I think "Access violation reading location 0x00000000" is a null pointer exception.
                      Does the second streamRead returns?
                      Does it perform at least one iteration?



                      1. It will be easier if you start a debug session:

                      In the '.cpp' file you can set breakpoints by clicking in the gray vertical bar at the beginning of each line. (If you set them in the '.br' file it won't stop)

                      Debug -> Start debugging

                      Now the program will halt at the specified lines, for example, you can:
                      - Advance one instruction with 'Step Over' button
                      - Continue the execution with the play button
                      - Monitor variable values looking for any null pointer



                      2. You don't need console input to set the number of iterations in the examples, it
                      is only a program parameter:

                      Project -> Properties -> Configuration properties -> Debugging -> Command Arguments -> -i (iterations)

                      In 'common.h' you can see a list of parameters you can use.



                      3. Note:
                      It isn't a error, but I think 'sizeof(inputA)' is a bit weird as iteration control,
                      if inputA is a pointer it will return 4 (8 in 64 bit mode), and if inputA is a array it will return the size in bytes, for example, with float 'inputA[10];' it will return 40



                      I hope you find it helpfull, I apologize if you already knew this.
                        • Problem with getting brook+ program result
                          kos

                          first StreamRead was successfull.

                          There are no cmd.iterations parameter. And i can enable gpu computations at all, after first getch() i see "Using cpu backend" massage. I can't use debug in VS2008. The following code :

                          for (i = 0; i < 1; ++i)
                          {

                              simple_matmult((float ) (Width), A, B, C);

                          }
                          returns the same exeption

                          I think that StreamRead's at all works right.

                    • Problem with getting brook+ program result
                      Ceq
                      Sorry, I'm a bit confused...
                      Isn't there a cmd.Iterations parameter? I thought you were running simple_matmult example, have you modified it?
                      Do other Brook+ examples work?
                      Why can't you use debug in VS2008? I've tested and it seems to work ok.
                      What happens if you disable line "simple_matmult((float..." , still unhandled exception message?
                        • Problem with getting brook+ program result
                          kos

                          following code

                          ::brook::stream A(::brook::getStreamType(( float *)0), Height , Width,-1);
                          ::brook::stream B(::brook::getStreamType(( float *)0), Width , Height,-1);
                          ::brook::stream C(::brook::getStreamType(( float *)0), Height , Height,-1);
                          Start(0);
                          streamRead(A, inputA);
                          streamRead(B, inputB);
                          getch();//1
                          for (i = 0; i < 1; ++i)
                          {
                          //simple_matmult((float ) (Width), A, B, C);
                          }
                          getch();//2
                          streamWrite(C, output);
                          getch();//3
                          Stop(0);
                          getch();//4

                          couses following result

                          0,001327 foreach item in stream C

                          I can't use debug becouse there are some problems with  using cusom tool in VS2008. I can't run brok+ in debug at all.