conduit icon indicating copy to clipboard operation
conduit copied to clipboard

flang compiler error (encountred in amd clang env)

Open cyrush opened this issue 2 years ago • 4 comments

     ...

     753    F90-S-0450-Argument number 1 to assert_true: kind mismatch (/tmp/root/spack-stage/spack-stage-conduit-0.8.3-xopk6bhx4urgw6kox5dm6j32a2wmowv5/spack-src/src/tests/conduit/fortran/t_f_
            conduit_node_obj.f90: 834)
     754    F90-S-0450-Argument number 1 to assert_true: kind mismatch (/tmp/root/spack-stage/spack-stage-conduit-0.8.3-xopk6bhx4urgw6kox5dm6j32a2wmowv5/spack-src/src/tests/conduit/fortran/t_f_
            conduit_node_obj.f90: 835)
     755    F90-S-0450-Argument number 1 to assert_true: kind mismatch (/tmp/root/spack-stage/spack-stage-conduit-0.8.3-xopk6bhx4urgw6kox5dm6j32a2wmowv5/spack-src/src/tests/conduit/fortran/t_f_
            conduit_node_obj.f90: 837)
     756    F90-S-0450-Argument number 1 to assert_true: kind mismatch (/tmp/root/spack-stage/spack-stage-conduit-0.8.3-xopk6bhx4urgw6kox5dm6j32a2wmowv5/spack-src/src/tests/conduit/fortran/t_f_
            conduit_node_obj.f90: 838)
     757    F90-S-0450-Argument number 1 to assert_true: kind mismatch (/tmp/root/spack-stage/spack-stage-conduit-0.8.3-xopk6bhx4urgw6kox5dm6j32a2wmowv5/spack-src/src/tests/conduit/fortran/t_f_
            conduit_node_obj.f90: 851)
     758      0 inform,   0 warnings,   5 severes, 0 fatal for t_node_obj_names_embedded_slashes
``

cyrush avatar Jul 19 '22 15:07 cyrush

flang doesn't like statements like this:

call assert_true( conduit_node_is_root(n) .eqv. .true.)

F90-S-0450-Argument number 1 to assert_true: kind mismatch

The return type of conduit_node_is_root is logical(C_BOOL)

I also tried:

call assert_equals( conduit_node_is_root(n) , .true.)

cyrush avatar Jul 19 '22 18:07 cyrush

@aaroncblack Wondering if you have seen anything like this with flang before?

cyrush avatar Aug 13 '22 18:08 cyrush

It looks like flang is complaining that 'logical' ( the type of .TRUE. ) and logical(kind=c_bool) are different sizes. Maybe flang is picking a 1 or 2 byte representation for logical as its default, and c_bool is probably int size.

Easiest workaround is to make your own logical to compare against. Or add a flag to suppress the warning ( since the compiler can safely upcast or downcast to make the comparison )

logical(kind=c_bool), parameter :: my_true = .TRUE.
call assert_equals( conduit_node_is_root(n) , my_true)

aaroncblack avatar Aug 15 '22 16:08 aaroncblack

thanks @aaroncblack !

cyrush avatar Aug 15 '22 16:08 cyrush

still lost in the fortran jungle -- I think the issue is with what fruit expects for its functions params (assert_true, etc)

logical(kind=c_bool), parameter :: t_true = .TRUE.
call assert_true(conduit_node_is_root(cnode) .eqv. t_true )
F90-S-0450-Argument number 1 to assert_true: kind mismatch (/conduit/src/tests/conduit/fortran/t_f_conduit_node.f90: 46)
  0 inform,   0 warnings,   1 severes, 0 fatal for t_node_create

I also tried assert_equals, but it can't resolve the proper type

logical(kind=c_bool), parameter :: t_true = .TRUE.
call assert_equals(conduit_node_is_root(cnode), t_true )
F90-S-0155-Could not resolve generic procedure assert_equals (/conduit/src/tests/conduit/fortran/t_f_conduit_node.f90: 46)
  0 inform,   0 warnings,   1 severes, 0 fatal for t_node_create

Flags might help, but I expect some trouble with using them across compilers. It would be nice if we could find how we can construct the proper fruit asserts.

cyrush avatar Aug 16 '22 02:08 cyrush

I think this is a path to victory:

call assert_true(LOGICAL(conduit_node_is_root(cnode) .eqv. .true.))

I'll use this approach for all of our tests.

cyrush avatar Aug 16 '22 02:08 cyrush