3 Replies Latest reply on Oct 26, 2014 1:58 AM by cxyzs7

    Problem with parallel calls of dgemm

    awet

      Hello all,

       

      I am using the single threaded library of ACML 5.3.1 compiled with Intel Fortran. I am compiling c++ code with Visual Studio 2012 and I test on an intel core2 duo and Windows 8.

      I am assuming that dgemm is thread safe (am I wrong here?), so I am simply trying to call dgemm from two different threads, but I am getting a runtime error in some cases:

       

      Unhandled exception at 0x00007FF95678BB96 (ntdll.dll) in ACML_test.exe: 0xC0000005: Access violation writing location 0x0000000000000024.

       

      Here is the code of a small test using boost::thread

       

      #include <iostream>

      #include <boost/thread.hpp>

      #include <acml.h>

       

      void thread()

      {

         double m1[100];

         double m2[100];

         double res[100];

       

         for(int i=0;i<100;i++){

             m1[i]=1.;

             m2[i]=1.;

             res[i]=0.;

         }

       

         for(int i=0;true;i++)

             dgemm('N','N',10,10,10,1,m1,10,m2,10,1.,res,10);

       

      }


      int main()

      {

        boost::thread t1(thread);

        boost::thread t2(thread);

       


          std::cin.get();

      }

       

       

      Am I doing something wrong?

       

      Thanks, David

        • Re: Problem with parallel calls of dgemm
          timmy.liu

          Hi Awet,

           

          The problem is that you are doing an endless loop and I think the error message you see was due to running out of memory.

          I was able to run the task by modify your code to

             for(int i=0;i<100;i++)

                 dgemm('N','N',10,10,10,1,m1,10,m2,10,1.,res,10);

          or if you want to keep the endless loop just print out some of the result so the program wont run too fast and hit the memory limit

             for(int i=0;ture;i++)

             {

                 dgemm('N','N',10,10,10,1,m1,10,m2,10,1.,res,10);

                 std::cout<<res[9]<<std::endl;

             }


          Thanks,

          Timmy

            • Re: Problem with parallel calls of dgemm
              awet

              Hello Timmy,

               

              thanks for your answer. But I don't think this is the problem.

               

              1. The program runs just fine, if I run only one thread.

              2. The program also crashes in most cases, if I do not keep the endless loop. In fact, sometimes it crashes in the first loop (debugger says i=0).

               

              I think it has something to do with the internal memory management of ACML. Right now I use another blas library and my program works without any problems.

               

              Regards, David

            • Re: Problem with parallel calls of dgemm
              cxyzs7

              Hi,

               

              I am currently facing the same problem with the latest 6.0.6 version.

              I was using Visual Studio 2013, and I downloaded acml-6.0.6.17-ifort64.zip. I used single threaded version of the library.

               

              I ran the original poster's program,with finite number of loop. This is what I got:

              First-chance exception at 0x0000000076DFE4E4 (ntdll.dll) in test.exe: 0xC0000005: Access violation writing location 0x0000000000000024.

              Unhandled exception at 0x0000000076DFE4E4 (ntdll.dll) in test.exe: 0xC0000005: Access violation writing location 0x0000000000000024.

               

              Did I do something wrong?

               

              Thanks,

              Michael