Skip to content

Commit

Permalink
Add --single-thread option for HPC-GAP.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbehrends committed Oct 24, 2019
1 parent dba9007 commit 5d7dad6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hpcgap/lib/hpc/thread.g
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ BindGlobal("InstallHPCGAPSignalHandling", function()
fi;
end);

if IsHPCGAP and THREAD_UI() then
if IsHPCGAP and not SINGLE_THREAD_STARTUP() then
InstallHPCGAPSignalHandling();
fi;

Expand Down
4 changes: 3 additions & 1 deletion lib/system.g
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ if IsHPCGAP then
GAPInfo.TestData:= ThreadLocalRecord( rec() );
APPEND_LIST_INTR(GAPInfo.CommandLineOptionData, [
,
rec( short:= "S", default := false, help := ["enable/disable single-threaded startup"] ),
rec( short:= "S", default := false, help := ["disable/enable multi-threaded interface"] ),
rec( short:= "P", default := "0", arg := "<num>", help := ["set number of logical processors"] ),
rec( short:= "G", default := "0", arg := "<num>", help := ["set number of GC threads"] ),
rec( short:= "Z", default := false, help := ["enforce ordering of region locks"] ),
rec( long := "single-thread", default := false,
help := [ "enable/disable single-threaded startup" ]),
]);

MakeImmutable(GAPInfo.CommandLineOptionData);
Expand Down
13 changes: 12 additions & 1 deletion src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1391,9 +1391,19 @@ static Obj FuncBREAKPOINT(Obj self, Obj arg)

static Obj FuncTHREAD_UI(Obj self)
{
return ThreadUI ? True : False;
return (ThreadUI && !SingleThreadStartup) ? True : False;
}

/****************************************************************************
**
*F FuncSINGLE_THREAD_STARTUP . . whether to start up in single-threaded mode
**
*/

static Obj FuncSINGLE_THREAD_STARTUP(Obj self)
{
return SingleThreadStartup ? True : False;
}

#endif

Expand Down Expand Up @@ -1480,6 +1490,7 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC_0ARGS(KERNEL_INFO),
#ifdef HPCGAP
GVAR_FUNC_0ARGS(THREAD_UI),
GVAR_FUNC_0ARGS(SINGLE_THREAD_STARTUP),
#endif
GVAR_FUNC_1ARGS(MASTER_POINTER_NUMBER, ob),
GVAR_FUNC_1ARGS(BREAKPOINT, integer),
Expand Down
6 changes: 6 additions & 0 deletions src/hpc/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ UInt SyNumProcessors = 4;
*/
UInt SyNumGCThreads = 0;

/****************************************************************************
**
*V SingleThreadStartup . . . . . . . . . start HPC-GAP with just one thread
**
*/
UInt SingleThreadStartup = 0;

/****************************************************************************
**
Expand Down
7 changes: 7 additions & 0 deletions src/hpc/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ extern UInt SyNumProcessors;
*/
extern UInt SyNumGCThreads;

/****************************************************************************
**
*V SingleThreadStartup . . . . . . . . . start HPC-GAP with just one thread
**
*/
extern UInt SingleThreadStartup;

/****************************************************************************
**
*F MergeSort() . . . . . . . . . . . . . . . sort an array using mergesort.
Expand Down
7 changes: 4 additions & 3 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,10 @@ static const struct optInfo options[] = {
{ 'q', "", toggle, &SyQuiet, 0 }, /* ?? */
#ifdef HPCGAP
{ 'S', "", toggle, &ThreadUI, 0 }, /* Thread UI */
{ 'Z', "", toggle, &DeadlockCheck, 0 }, /* Thread UI */
{ 'P', "", storePosInteger, &SyNumProcessors, 1 }, /* Thread UI */
{ 'G', "", storePosInteger, &SyNumGCThreads, 1 }, /* Thread UI */
{ 'Z', "", toggle, &DeadlockCheck, 0 }, /* Deadlock prevention */
{ 'P', "", storePosInteger, &SyNumProcessors, 1 }, /* number of CPUs */
{ 'G', "", storePosInteger, &SyNumGCThreads, 1 }, /* number of GC threads */
{ 0 , "single-thread", toggle, &SingleThreadStartup, 0 }, /* startup with one thread only */
#endif
/* The following options must be handled in the kernel so they are set up before loading the library */
{ 0 , "prof", enableProfilingAtStartup, 0, 1}, /* enable profiling at startup */
Expand Down

0 comments on commit 5d7dad6

Please sign in to comment.