Changeset c10f46 in git for Singular/LIB/parallel.lib


Ignore:
Timestamp:
Aug 3, 2012, 1:06:22 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
b0732eb4254fbe76540d72c337f3d7f985adf948
Parents:
b8610796eaca5ba7db8dc75f8bc88d698e077b365abb0e7fdca82a2bad9778e410148c74d7b49a0b
Message:
Merge pull request #162 from steenpass/libs

changes in LIBs from master
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/parallel.lib

    rb86107 rc10f46  
    33category="General purpose";
    44info="
    5 LIBRARY:   parallel.lib  An Interface for Parallelization
     5LIBRARY:   parallel.lib  Tools for Parallelization
    66AUTHOR:    Andreas Steenpass, e-mail: steenpass@mathematik.uni-kl.de
     7
     8OVERVIEW:
     9This library provides tools to do several computations in parallel. They
     10are aimed at ordinary Singular users as well as authors of Singular
     11libraries.
     12@* Even without this library, it is possible to do execute self-defined
     13Singular commands in parallel using @ref{links}, but the handling of
     14such links can be quite tedious. With the pocedures described below,
     15this can be done by one-line commands.
     16@* There are many parallel 'skeletons' (i.e. ways in which parallel
     17tasks rely upon and interact with each other). A few of them are already
     18implemented. Future plans include an abstraction layer for modular
     19techniques, 'worker farms', and parallel tests.
    720
    821SEE ALSO:  link, modstd_lib, assprimeszerodim_lib
     
    2639RETURN:  a list, containing the results of commands[i] applied to arg[i],
    2740         i = 1, ..., size(commands).
    28          @* The entries of the list commands must be strings.
    29          @* The entries of the list args must be lists.
    3041         @* The procedure waits for N jobs to finish.
    31          @* An optional timeout in ms can be provided. Default is 0 which
     42
     43         @* OPTIONAL PARAMETERS:
     44
     45            An optional timeout in ms can be provided. Default is 0 which
    3246            disables the timeout.
    33          @* Supported linktypes are up to now \"ssi\" and \"mp\", see
     47
     48            Supported linktypes are up to now \"ssi\" and \"mp\", see
    3449            @ref{Ssi links} and @ref{MP links}.
     50
     51            Servers:
    3552         @* Each server is given by a list containing the address of the server,
    3653            the number of cores to use on this server and the command to start
    37             Singular. If the address is \"localhost\", the processes will
    38             be generated on the same machine using forks. If the command to
    39             start Singular is \"\" (the empty string), \"Singular\" will be
    40             used. Default is @code{list(\"localhost\", system(\"cpu\"), \"\")}.
    41             There are some obvious shortcuts for servers, e.g. \"myserver\" is
     54            Singular.
     55         @* If the address is \"localhost\", the processes will be generated on
     56            the same machine using forks. If the command to start Singular is
     57            \"\" (the empty string), \"Singular\" will be used.
     58         @* Default is @code{list(\"localhost\", system(\"cpu\"), \"\")}.
     59         @* There are some obvious shortcuts for servers, e.g. \"myserver\" is
    4260            a shortcut for
    4361            @code{list(\"myserver\", [nb. of cores on myserver], \"\")}, or 3
    4462            for @code{list(\"localhost\", 3, \"\")}.
     63
     64            Memory limits:
    4565         @* If an intvec maxmemory of size @code{size(commands)} is given, the
    4666            i-th job will be killed if it uses more than maxmemory[i] MB of
    4767            memory. If maxmemory[i] is 0, there will be no restraint for the
    4868            i-th job. Default is @code{0:size(commands)}.
    49 NOTE:       The returned list may contain more than N results if several jobs
     69NOTE:       The entries of the list commands must be strings.
     70         @* The entries of the list args must be lists.
     71         @* The returned list may contain more than N results if several jobs
    5072            finished \"at the same time\". It may contain less than N results in
    5173            the case of timeout or errors occurring.
     
    368390    }
    369391    write(l(i), quote(execute("result = "+eval(commands[k])
    370                                     +"(currentargs[1..size(currentargs)]);")));
     392      +"("+argsToString("currentargs", size(currentargs))+");")));
    371393    assignment[i] = k;
    372394    k++;
     
    455477      }
    456478      write(l(wait), quote(execute("def result = "+eval(commands[k])
    457                                      +"(currentargs[1..size(currentargs)]);")));
     479        +"("+argsToString("currentargs", size(currentargs))+");")));
    458480      assignment[wait] = k;
    459481      k++;
     
    542564  ideal i = z8+z6+4z5+4z3+4z2+4, y-z2;
    543565  ideal j = 3x3y+x3+xy3+y2z2, 2x3z-xy-xz3-y4-z2, 2x2yz-2xy2+xz2-y4;
    544   list commands = list("std", "primdecGTZ", "primdecSY", "std", "primdecGTZ",
    545                        "primdecSY");
     566  list commands = list("std", "primdecGTZ", "primdecSY",
     567                       "std", "primdecGTZ", "primdecSY");
    546568  list args = list(list(i), list(i), list(i), list(j), list(j), list(j));
    547569  parallelWaitN(commands, args, 3);
     
    717739  return(i);
    718740}
     741
     742static proc argsToString(string name, int length)
     743{
     744  string arglist;
     745  if(length > 0) {
     746    arglist = name+"[1]";
     747  }
     748  int i;
     749  for(i = 2; i <= length; i++) {
     750    arglist = arglist+", "+name+"["+string(i)+"]";
     751  }
     752  return(arglist);
     753}
Note: See TracChangeset for help on using the changeset viewer.