On Wednesday, November 13, 2024 at 11:06:46 PM UTC+9 Michael Orlitzky wrote:

On 2024-11-13 01:12:25, Kwankyu Lee wrote: 
> Hi, 
> 
> According to our installation guide: 
> 
> *One useful setting for this variable when building Sage is MAKE='make 
> -jNUM' to tell the make program to run NUM jobs in parallel when 
building. 
> Note that some Sage packages may not support this variable.* 
> 
> and our main build scripts are sprinkled with $(MAKE) instead of invoking 
> "make" directly. 
> 
> But as I understand the jobserver 
> (https://www.gnu.org/software/make/manual/html_node/Job-Slots.html), only 
> the top-level make command should get "-jNUM" flag and sub make commands 
> should not get "-jNUM flag, for the jobserver to work across all make 
> commands. 
> 
> Hence we should revise the paragraph in the installation guide to not 
> recommend to define *MAKE='make -jNUM', but to build sage by make -jNUM 
at 
> the top-level.* 
> 
> *Am I right?* 

Sub-invocations of $(MAKE) within a Makefile coordinate the number of 
jobs by passing information around through the MAKEFLAGS variable. So 
inside Sage's own Makefiles, either should work. 

I think where the difference becomes important is in the 
sage-the-distro packages, under build/pkgs. These are built with 
scripts that run $MAKE, but not as part of another Makefile -- so I 
doubt that the jobserver/number-of-jobs information gets relayed 
unless you put it in the $MAKE variable yourself. (But if you are 
thinking that this would ultimately start too many jobs, you are 
probably right.)


Right. I think package build scripts should relay  the MAKEFLAGS variable 
so that the jobserver initiated by the top-level make run by a user controls
the number of jobs across the whole build process. 
Defining MAKE='make -jNUM' disables the jobserver, and hence seems to be a 
bad practice. 
 

> Moreover I think SAGE_NUM_THREADS environment variable should be used if 
a 
> sage package wants to run parallel jobs, instead of relying on 
*MAKE='make 
> -jNUM'.* 

The doctest runner is capable of coordinating with the GNU Make 
jobserver so that, for example, "make -j4 test" will start the correct 
number of parallel test threads. This is akin to how "make -j4 test" 
works in a typical autotools package; it will run up to four tests at 
the same time. In short it is a way to pass sage-the-distro 
information down to sage-the-library. 


OK.
 

Otherwise, users who are 
familiar with "make -j" would also need to know about the sage-only 
SAGE_NUM_THREADS variable, and set it redundantly.


If defined, SAGE_NUM_THREADS may be used to overrule the jobserver.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/sage-devel/8636fac4-5797-458f-9cbd-f005daa8ececn%40googlegroups.com.

Reply via email to