vermaseren / form

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

[tform] Crash in incrementing "maximum" $-variables #147

Open tueda opened 7 years ago

tueda commented 7 years ago

The following code should print the maximum number of terms that one thread got, but tform often crashes:

Auto S x;
L F = x1+...+x100;  * Ensure well-parallelized.
.sort
#$n = 0;
$n = $n + 1;
ModuleOption maximum $n;
.sort
#message `$n'
.end
TFORM 4.1 (Nov 15 2016, v4.1-20131025-263-g033e880) 64-bits 4 workers  Run: Wed Nov 23 16:19:56 2016
    Auto S x;
    L F = x1+...+x100;  * Ensure well-parallelized.
    .sort

Time =       0.00 sec    Generated terms =        100
               F         Terms in output =        100
                         Bytes used      =       2808
    #$n = 0;
    $n = $n + 1;
    ModuleOption maximum $n;
    .sort
Program terminating in thread 1 at 1.frm Line 6 --> 
  0.00 sec + 0.00 sec: 0.01 sec out of 0.00 sec

Is it not expected to use $n = $n + 1 for the maximum option?

vermaseren commented 7 years ago

Hi

That is where you are supposed to use sum. Maximum is for setting a fixed value.

Jos

On 23 nov. 2016, at 16:30, Takahiro Ueda notifications@github.com wrote:

The following code should print the maximum number of terms that one thread got, but tform often crashes:

Auto S x; L F = x1+...+x100; * Ensure well-parallelized. .sort

$n = 0;

$n = $n + 1; ModuleOption maximum $n; .sort

message `$n'

.end TFORM 4.1 (Nov 15 2016, v4.1-20131025-263-g033e880) 64-bits 4 workers Run: Wed Nov 23 16:19:56 2016 Auto S x; L F = x1+...+x100; * Ensure well-parallelized. .sort

Time = 0.00 sec Generated terms = 100 F Terms in output = 100 Bytes used = 2808

$n = 0;

$n = $n + 1;
ModuleOption maximum $n;
.sort

Program terminating in thread 1 at 1.frm Line 6 --> 0.00 sec + 0.00 sec: 0.01 sec out of 0.00 sec Is it not expected to use $n = $n + 1 for the maximum option?

— 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/147, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEg6jAg9lplY-0rq8wB272wYDyaJKks5rBFwSgaJpZM4K6uNx.

tueda commented 7 years ago

@vermaseren Do you mean the right-hand side of $-variable assignment for maximum/minimum should not depend on the variable itself? For example

$max = max_($max,$n);

is not allowed?

I see an example in the manual like

if ( count(a1,1) > $max ) $max = count_(a1,1);

for maximum. Is it guaranteed that $max has the same value both at the reading and writing? In other words, does the whole process of reading-comparison-writing acquire a lock? If this is not atomic, a data race occurs.

vermaseren commented 7 years ago

Actually you are probably right that the $error = $error+1; should have worked. It did work in convdia. Maybe there is just something going wrong.

Jos

On 23 nov. 2016, at 17:21, Takahiro Ueda notifications@github.com wrote:

@vermaseren https://github.com/vermaseren Do you mean the right-hand side of $-variable assignment for maximum/minimum should not depend on the variable itself? For example

$max = max_($max,$n); is not allowed?

I see an example in the manual like

if ( count(a1,1) > $max ) $max = count_(a1,1); for maximum. Is it guaranteed that $max has the same value both at the reading and writing? In other words, does the whole process of reading-comparison-writing acquire a lock? If this is not atomic, a data race occurs.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/147#issuecomment-262561750, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEknCKxSIU0Wnre6FAnbHKw9zIaJ2ks5rBGgYgaJpZM4K6uNx.