-
-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parallelism in Sage: just use value of 'MAKE' #12016
Comments
comment:1
We should remove |
This comment has been minimized.
This comment has been minimized.
Changed author from John Palmieri to John Palmieri, Jeroen Demeyer |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:6
John, with your solution there is a lot of code duplication (determining the number of threads is done in 3 places, potentially in 3 different ways). How about having code in |
comment:7
Replying to @jdemeyer:
Sounds okay.
If you run "sage -tp ", should you use 1 process or more than 1? The "-tp" option means "parallel", so perhaps the default should be more than 1 in this case. In other cases (like docbuilding, for example), the default should be 1. |
comment:8
For something like
but I don't see "16" anywhere in the listing of the environment variables. |
comment:9
Replying to @jhpalmieri:
Sure, that is what I meant. We should compute the value once, but in |
comment:10
Replying to @jhpalmieri:
You are right. I had not tried this before. So let's scrap that idea. |
Attachment: trac_12016-root.v2.patch.gz Attachment: trac_12016-sage.v2.patch.gz |
This comment has been minimized.
This comment has been minimized.
comment:11
Here are new patches. These use I don't know how to get the number of threads from
so I removed that from the "to do" list in the ticket description. In the file sage-ptest, I removed the "FIXME" comment in try:
# FIXME: Nice, but <NUMTHREADS> should immediately follow '-tp' etc.,
# i.e., be the next argument. We might have file or directory
# names that properly convert to an int...
numthreads = int(argv[1])
infiles = argv[2:]
except ValueError: # can't convert first arg to an integer: arg was probably omitted
numthreads = 1 The script sage-ptest doesn't get a "tp" argument; it is instead called by sage-sage, and the way it is called, the first argument to sage-ptest is precisely what ever came after "-tp". So I don't think anything needs fixing. If we ever rewrite sage-sage (#21) to properly parse arguments, we can make sure that "-tp" has a default numerical argument of zero. |
comment:12
Attachment: trac_12016-scripts.v2.patch.gz
1b) Alternatively: use 0 for automatic (as is sage -tp 0) and 999999 for unlimited. This would mean less special-case code, since a value like 999999 is more than what a user would normally specify (for the forseeable future).
to
in the
I am planning to work further on this, so don't change any code yet. But please give your opinion. |
comment:13
Replying to @jdemeyer:
Sounds good to me.
Okay.
I'm willing to try that, especially if you write the patch instead of me :)
That was a mistake.
Some of them I disagreed with, like the complete removal of the section "Beyond the Sage library". So I started from scratch, at which point I just put in the changes that I felt were relevant to the ticket or easy for me to change. Probably I should have started with your patch and added the section (with modifications) back in. It looks like #9739 broke doctesting of .sage files. We should fix that (not on this ticket). |
comment:14
Replying to @jhpalmieri:
See #12069. |
comment:15
Replying to @jhpalmieri:
I removed that because it totally didn't work. But this is probably #12069. How about we leave the last section of the documentation alone in this ticket but then change the documentation in #12069? |
comment:16
Replying to @jdemeyer:
Okay, sounds fine to me. |
comment:36
Replying to @jhpalmieri:
Since my patches properly implement parallel building, it also means that more packages are actually being built in parallel. So I think we are simply triggering bugs in the various packages. For example, I never had problems with Python before, but I did have problems with this patch (fixed in #12096). I cannot explain why "make -j -lN" would fail but "make -jN" would work. |
comment:37
Replying to @jhpalmieri:
Well, singular is in the list of fishy packages, see the ticket description. |
comment:38
Just for fun, I modified |
comment:39
I think it is truly a coincidence that "make -j -lN" fails. I managed to make singular fail with just "make -jN", hopefully fixed by #12138. |
comment:40
Replying to @jhpalmieri:
Are these about builds of the total Sage source in which these fail, or are these separate installs like |
comment:41
When testing with
|
comment:43
In the following lines from sage-spkg
do we also need to handle the long versions? (I don't think so, but I thought I would ask.) More importantly, on OpenSolaris, or at least on David Kirkby's machine hawk, the default 'grep' command doesn't take a |
comment:44
One reason is that |
comment:45
Replying to @jhpalmieri:
Well, this would only be needed if the user does something very silly like
Probably yes, but it might be safer to replace the leading space by a |
Attachment: 12016-scripts.patch.gz |
This comment has been minimized.
This comment has been minimized.
comment:46
Attachment: 12016-base.patch.gz |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:49
I'm happy with this except for a few small changes I want to make in sage-num-threads.py: we should use subprocess instead of popen, since popen has been deprecated. Also, we should catch errors if |
Attachment: trac_12016-scripts-ref.patch.gz scripts repo |
comment:50
Looks good to me. I am still slightly worried about the intermittent |
Merged: sage-4.8.alpha5 |
The various parallel aspects of Sage should be controlled by setting the
-j
(possible also-l
) flags inMAKE
orMAKEFLAGS
. That is, ifMAKE='make -j16'
, thenrunning
make
will build spkg's in parallel, using 16 processes (this was done in Remove the necessity to set SAGE_PARALLEL_SPKG_BUILD #11959). This is standardmake
behaviour, but we need to patchspkg/standard/deps
to ensure thatmake
recognizes that we are doing a recursive make.running
make ptestlong
orsage -tp 0 <files>
will doctest in parallel using 16 threads. If the-j
flag inMAKE
is not set, then determine the number of threads as before:min(8, cpu_count())
.running
./sage -b
will build the Sage library using 16 threads. If the-j
flag inMAKE
is not set, then use only 1 thread.Testing this ticket: you can set the environment variable
SAGE_NUM_CORES
to the number of cores you want to pretend to have. For example, runningshould run 8 threads (see
sage-num-threads.py
; this is undocumented because the only purpose I see is for testing this ticket).Notes:
With the patches applied, building spkgs in parallel works well, except for race conditions in:
and a "jobserver unavailable" warning in:
Apply:
SAGE_ROOT
repository.spkg/base
.SCRIPTS
repository.See also: #6495 to implement the same behavior for doc building.
Dependencies: sage-4.8.alpha4
CC: @jdemeyer @nexttime
Component: build
Author: John Palmieri, Jeroen Demeyer
Reviewer: John Palmieri, Jeroen Demeyer
Merged: sage-4.8.alpha5
Issue created by migration from https://trac.sagemath.org/ticket/12016
The text was updated successfully, but these errors were encountered: