vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
1.14k stars 136 forks source link

NTHREADS_ in form and parform? #159

Closed tueda closed 7 years ago

tueda commented 7 years ago

What it the actual meaning of NTHREADS_ in FORM and ParFORM? It just gives the number set by -w plus 1:

$ form -w100 1
FORM 4.1 (Nov 29 2016, v4.1-20131025-272-gb993ca7) 64-bits  Run: Tue Dec 13 19:41:18 2016
    #show
#The preprocessor variables:
13: NPARALLELTASKS_ = "1"
15: NTHREADS_ = "101"

But should it be always 1?

I'm trying to write a sort of canonicalization, and it has a structure like

#call CanonicalizeInEachWorker()
#call CanonicalizeOnMaster()

such that the first one has benefit from parallelization, while the second one guarantees the uniqueness. But in the sequential mode, it performs the same thing twice. So I would skip one of them if there is no benefit from parallelization, determined from the values of NPARALLELTASKS_ and NTHREADS_. (Or other methods?)

vermaseren commented 7 years ago

Hi Takahiro,

I think you ran into another dinosaur. After the sortbots were introduced there can be more threads. Also in various versions of linux, (older ones) there was even one more thread that sat above the master thread. That was somehow sneaked in by the OS. I had no control over that. I am not sure what you want exactly. Just make it such that it performs as you need it to perform, and then, most likely nobody will complain. Very likely this is hardly ever used, and if people use it, they will let it be known and then we have to figure out how to combine the old and the new. These variable were made because it might or might not be useful. Often I guessed right and often I guessed wrong.

Cheers

Jos

On 13 dec. 2016, at 19:46, Takahiro Ueda notifications@github.com wrote:

What it the actual meaning of NTHREADS_ in FORM and ParFORM? It just gives the number set by -w plus 1:

$ form -w100 1 FORM 4.1 (Nov 29 2016, v4.1-20131025-272-gb993ca7) 64-bits Run: Tue Dec 13 19:41:18 2016

show

The preprocessor variables:

13: NPARALLELTASKS = "1" 15: NTHREADS = "101" But should it be always 1?

I'm trying to write a sort of canonicalization, and it has a structure like

call CanonicalizeInEachWorker()

call CanonicalizeOnMaster()

such that the first one has benefit from parallelization, while the second one guarantees the uniqueness. But in the sequential mode, it performs the same thing twice. So I would skip one of them if there is no benefit from parallelization, determined from the values of NPARALLELTASKS and NTHREADS.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/159, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEpeNA0Kfj7zIupC3Zttq1W8RgAgoks5rHugPgaJpZM4LMFgO.

tueda commented 7 years ago

Hi Jos,

What I want to do is to know from a FORM program which version (say, FORM or TFORM) the user is running. At first I thought NTHREDS_ can distinguish TFORM from FORM, but if the user (mistakenly) runs the program with form -w8, then NTHREADS_ becomes 9 even though the sequential FORM can't utilize 8 (+1 or more) cores.

vermaseren commented 7 years ago

Hi Takahiro,

That form -w8 looks indeed like an error if it gives NTHREADS_ as 9. When you are busy at it, you can change that.

Cheers

Jos

On 13 dec. 2016, at 20:08, Takahiro Ueda notifications@github.com wrote:

Hi Jos,

What I want to do is to know from a FORM program which version (say, FORM or TFORM) the user is running. At first I thought NTHREDS can distinguish TFORM from FORM, but if the user (mistakenly) runs the program with form -w8, then NTHREADS becomes 9 even though the sequential FORM can't utilize 8 (+1 or more) cores.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/159#issuecomment-266831406, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEg6ywvSYg1_41lWuCy7upOwEq9uJks5rHu0ugaJpZM4LMFgO.

tueda commented 7 years ago

OK. I will make a change such that NTHREADS_ gets 1 in the sequential FORM and ParFORM.