/* This is a sample of how to call geng as a procedure in multiple threads. * Usage: callgeng2 [-N#] geng_args * The argument of -N is the number of threads (default 10, maximum 100). * It must be linked with a version of geng and nauty that has been compiled * with the thread-local attribute. * The way to compile this program per the Posix standard and recent gcc compilers * is like this: gcc -o callgeng2 -O3 -march=native -pthread -DMAXN=WORDSIZE -DWORDSIZE=32 \ -DUSE_TLS -DGENG_MAIN=geng_main -DSUMMARY=geng_summary \ callgeng2.c geng.c nautyW1.a * You might also need to add -lpthread or -lpthreads to the compilation. * On some systems these instructions will need modification. * * If output is not turned off using -u, graphs are written to stdout. Each graph * is written using a single fwrite() call, which is atomic on Linux for such * short strings but there is no guarantee that the output won't get mixed together * on other systems. Since this is only a short demonstration, I won't try to * fix that, but if you know thread programming you can figure out a way to have * a single thread do all the writing (use the hook OUTPROC, see callgeng.c). * Meanwhile, if you just want to count and not write, you don't need to worry * about that.
*/
static nauty_counter count[MAXTHREADS]; /* Thread i only writes to count[i]. */ static TLS_ATTR int threadnumber; typedefstruct params { int res,mod; char **args; } params;
void SUMMARY(nauty_counter num, double cpu) /* This will be called from each geng thread as it finishes. */
{
count[threadnumber] = num;
}
/* Declare the main procedure of geng (usually main()) */ int GENG_MAIN(int argc, char *argv[]);
staticvoid*
runit(void *threadarg) /* Main routine for one thread */
{
params *par; int geng_argc; char resmod[30]; /* string to put res/mod into */ char *geng_argv[MAXGENGARGS+2]; /* At least one bigger than geng_argc. */ char **args;
par = (params*)(threadarg);
threadnumber = par->res;
args = par->args;
/* Set up geng argument list. The 0-th argument is the command name.
* There must be a NULL at the end. */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.