Compile error after last updates

320 views
Skip to first unread message

jose.lopez...@gmail.com

unread,
Jan 10, 2022, 11:44:30 AM1/10/22
to basilisk-fr

Hi all,

I am having problems compiling a code I did already a couple of months ago. The error I get is with the last update of basilisik is:

%qcc -Wall -O2 -o deriv derivative.c -lm

derivative.c: In function ‘defaults_1’:

derivative.c:112:8: error: invalid operands to binary != (have ‘coord {aka struct <anonymous>}’ and ‘coord {aka struct <anonymous>}’)

derivative.c:116:8: error: invalid operands to binary != (have ‘coord {aka struct <anonymous>}’ and ‘coord {aka struct <anonymous>}’)


However if I take back basilisk to a little bit older version by doing


%darcs obliterate --from-tag '21-12-12'

%make clean

%make

The code compiles and run perfectly well.

Shall I presume it would be a bug?


Cheers (and a happy new year)


Jose


PS: I am taking apart the code little by little to prepare a proper simplified bug code.

j.a.v...@gmail.com

unread,
Jan 11, 2022, 4:49:12 AM1/11/22
to basilisk-fr
Hallo Jose,

The new version of qcc appears to be extra pedantic about code that is unsafe to run with openMP.

Something like

~~~
coord n;
foreach()  {
    .... // compute/modify n
 }
~~~

should be avoided. See also:

But I believe you do have uncovered a bug, as the error message is not useful, and qcc assumed a wrong type for `n`.

If you want to deal with your issue using the current version, you should ensure to declare your variables in the inner most scope.

A bad second option would be to fool qcc and indicate that you want to reduce n.

Antoon

Op maandag 10 januari 2022 om 17:44:30 UTC+1 schreef jose.lopez...@gmail.com:

Stephane Popinet

unread,
Jan 11, 2022, 8:59:07 AM1/11/22
to basil...@googlegroups.com
Dear Pepe, Antoon and all,

The latest release indeed includes major changes to qcc, which explains
the warning/errors you may get.

This is to do with 'automatic boundary conditions', which I had promised
(if you recall) back in 2017, during the Basilisk meeting in Princeton.

The good thing is that call to 'boundary()' are now unnecessary, since
the best time to apply boundary conditions is now automatically
determined by qcc.

Beyond automatic boundary conditions, the deeper code analysis performed
by qcc also opens new possibilities such as automatic code generation
for GPUs, on which I am working at the moment.

The bad (and good) thing is that qcc is now indeed "more pedantic" about
code and this may generate warnings and/or errors on existing code.
"Pedantic" is not really the correct description, since fixing code to
remove these warnings will ensure that the code will run properly in
parallel (which is not useless/pedantic). It may also ensure that your
code will eventually be portable to GPUs (which have much stronger code
complexity limitations than CPUs)

That said, this new code almost certainly contains limitations/bugs (and
Pepe you probably found one), so any testing that people can do and bugs
they can report will be very valuable.

cheers,

Stephane

Stephane Popinet

unread,
Jan 11, 2022, 9:38:43 AM1/11/22
to basil...@googlegroups.com
This is indeed a qcc bug, but it will be fixed in the next release.

That said, as pointed out by Antoon, your code should use local
variables. If you do, then the error does not appear (see also my
comments in the file).

cheers,

Stephane

PS: and thanks for the bug report. Please keep on testing the new version!

jose.lopez...@gmail.com

unread,
Jan 11, 2022, 9:58:02 AM1/11/22
to basilisk-fr
Dear Antoon and Stephane,

Thanks both for your detailed answer. I suspected something of the type you refers related the huge update behind the  'automatic boundary conditions'.
I hope  I will recall your wisdom next time and not bother you...

Cheers

Pepe

limarea...@gmail.com

unread,
Jun 8, 2022, 12:27:27 PM6/8/22
to basilisk-fr
Hello everyone,

I'm coming back to my sandbox and did some updates. I have an issue probably linked to what Jose has described. I did a small debug case:

double geometry(coord size){
    return size.x;
}

int main(){
    init_grid (64);
    vertex scalar a[];
    coord size = {0.1 , 0.1};
    foreach_vertex(){
        // a[] = geometry(size); // <-- compilation error
        a[] = size.x; // not what I want to do
    }
}

The function geometry can be called if size is of type double but not coord.
If I uncomment my line, I get:
"debug.c:13:18: error: invalid operands to binary != (have ‘coord’ and ‘coord’)"

I have trouble understanding the issue here, I guess this is expected behaviour due to new safeguards. What's happening ?

Regards,
Alex

j.a.v...@gmail.com

unread,
Jun 9, 2022, 5:54:39 AM6/9/22
to basilisk-fr
Hallo Alex,

> What's happening ?

To verify there are no missing `reduction` clauses, qcc
implements a check on `n` and examines if it is modified in the
foreach loop.  However, this check, -involving a `!=`
comparison-, only works for int, double, etc but is not
applicable to structures like `coord`s.

Antoon
Op woensdag 8 juni 2022 om 18:27:27 UTC+2 schreef limarea...@gmail.com:

Stephane Popinet

unread,
Jun 9, 2022, 7:59:16 AM6/9/22
to basil...@googlegroups.com
I have been working on a completely new implementation of qcc for the
past few months, but haven't had the time to release it yet.

It should be much more robust/clever that the current implementation and
will avoid this issue and other similar issues.

I will try to release it soon.

cheers,

Stephane

On 6/9/22 11:54, j.a.v...@gmail.com wrote:
> Hallo Alex,
>
> > What's happening ?
>
> To verify there are no missing `reduction` clauses, qcc
> implements a check on `n` and examines if it is modified in the
> foreach loop.  However, this check, -involving a `!=`
> comparison-, only works for int, double, etc but is not
> applicable to structures like `coord`s.
>
> Antoon
> Op woensdag 8 juni 2022 om 18:27:27 UTC+2 schreef limarea...@gmail.com:
>
> Hello everyone,
>
> I'm coming back to my sandbox and did some updates. I have an issue
> probably linked to what Jose has described. I did a small debug case:
>
> double geometry(coord size){
>     return size.x;
> }
>
> int main(){
>     init_grid (64);
>     vertex scalar a[];
>     coord size = {0.1 , 0.1};
>     foreach_vertex(){
>         // a[] = geometry(size); // <-- compilation error
>         a[] = size.x; // not what I want to do
>     }
> }
>
> The function /geometry/ can be called if *size* is of type /double/
> but not /coord/.
> If I uncomment my line, I get:
> /"debug.c:13:18: error: invalid operands to binary != (have ‘coord’
> and ‘coord’)"/
> --
> You received this message because you are subscribed to the Google
> Groups "basilisk-fr" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to basilisk-fr...@googlegroups.com
> <mailto:basilisk-fr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/basilisk-fr/02ef95dc-f0ef-4877-827d-dd05ea90a5f4n%40googlegroups.com
> <https://groups.google.com/d/msgid/basilisk-fr/02ef95dc-f0ef-4877-827d-dd05ea90a5f4n%40googlegroups.com?utm_medium=email&utm_source=footer>.

limarea...@gmail.com

unread,
Jun 9, 2022, 10:36:18 AM6/9/22
to basilisk-fr
Ok. Thank you for your answers.

Cheers,
Alex
Reply all
Reply to author
Forward
0 new messages