Post a reply
Username:
Note:If not registered, provide any username. For more comfort, register here.
Subject:
Message body:
Enter your message here, it may contain no more than 60000 characters. 

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
Font size:
Font colour
Options:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation of post
To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.
Confirmation code:
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
   

Topic review - libSingular and openmp
Author Message
  Post subject:  Re: libSingular and openmp  Reply with quote
- the need for siInit: it initialized all parts of Singular (with the exceptions of signals): without it the interpreter can not be used, the factorization does not work,
routines for memory management are not set, etc.
It also sets the path to find the code parts which are not in the main program:
for example all specialized p_* routines are in p_Procs_*.so
- parallelization via openmp: the standard Singular is not thread-safe,
you need a special version as described in README.pSingular
or have a look at modstd.lib and kverify.cc how parallelization works in Singular.
Post Posted: Wed Jan 26, 2022 2:51 pm
  Post subject:  libSingular and openmp  Reply with quote
Hi,
Is it possible to parallelize calls to functions in libSingular using openmp (or pthreads)? My naive approach, starting from the example given in https://github.com/Singular/Singular/bl ... ibsingular, had some problems:
Code:
#include <iostream>
#include <Singular/libsingular.h>
#include <omp.h>

int main() {
   //initialize singular
   siInit((char *)"/usr/lib/libSingular.so");

   #pragma omp parallel
   {
      // construct the ring Z/32003[x,y,z]
      // the variable names
      char **n=(char**)omalloc(3*sizeof(char*));
      n[0]=omStrDup("x");
      n[1]=omStrDup("y");
      n[2]=omStrDup("z");

      ring R=rDefault(32003,3,n);
      // make R the default ring: not needed if p_<...> functions are used
      //rChangeCurrRing(R);

      // create the polynomial 1
      poly p1=p_ISet(1,R);

      // create the polynomial 2*x^3*z^2
      poly p2=p_ISet(2,R);
      p_SetExp(p2,1,3,R);
      p_SetExp(p2,3,2,R);
      p_Setm(p2,R);

      // print p1 + p2
      #pragma omp critical
      {
         p_Write(p1,R); printf(" + \n"); p_Write(p2,R); printf("\n");
      }
   }

   return 0;
}

The compilation runs fine, and it produces the correct output intersected with the following error message (appearing several times):
Code:
// ***dError: Bug reported: p_Procs is NULL
occurred at ./templates/p_Procs_Set.h,170
// ** Singular will work properly, but much slower
// ** If you chose a coef ring, it may not work at all

Related to this is the question why it is necessary to initialize singular if one only uses "standalone" functions (e.g. all p_<...> functions) that don't seem to rely on any global object (like the current ring) or interpreter? I tried to dig into the source code and documentation but couldn't really understand what's happening.
Post Posted: Wed Jan 26, 2022 11:35 am


It is currently Fri May 13, 2022 10:54 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group