Menu

#11 Integer conversion errors with PGI compiler

v1.0 (example)
open
seranian
PGI (1)
5
2021-01-08
2020-10-17
Carl Ponder
No

I'm able to build Perfmon2 4.11.0 using the PGI 20.9 compiler but I had to change the source code in a lot of places. The particular errors I see are

 error: integer conversion resulted in a change of sign
     .umask_ovfl_idx = -1,
                                                              ^
 error: integer conversion resulted in a change of sign
         return -1;
                               ^

which I believe comes from assigning the negative value to an unsigned integer type and may or may not involve re-sizing the bit-field. The PGI compiler is stricter than the GPU compiler so I expect the code is not compliant with the C/C++ standard in this respect.
I was able to sqelch the error by adding a cast everywhere

= (unsigned long) -1

but you might prefer to make the intent more explicit with something like

#define FULL_MASK 0xFFFFFFFFFFFFFFFFul
  .umask_ovfl_idx = FULL_MASK,
  return FULL_MASK

Discussion

  • Carl Ponder

    Carl Ponder - 2020-10-17

    These are the line locations I had edited in the file lib/events/perf_events.h :
    62
    74
    83
    161
    201
    236
    276
    316
    346
    376

     

    Last edit: Carl Ponder 2020-10-17
  • Carl Ponder

    Carl Ponder - 2020-10-18

    Here in lib/pfmlib_perf_event_pmu.c:
    388

    Here in perf_examples/perf_util.c:
    273
    283
    291
    574

     
  • Carl Ponder

    Carl Ponder - 2020-10-18

    There's a short-cast in lib/pfmlib_intel_nhm_unc.c:

    215c215
    <       ret = pfm_intel_x86_add_defaults(this, e, ugrpmsk, &umask, -1, -1);
    ---
    >       ret = pfm_intel_x86_add_defaults(this, e, ugrpmsk, &umask, (unsigned short) -1, -1);
    

    This is a little different from the previous, I don't think a casting of (unsigned long) worked in this case. Also my FULL_MASK suggestion probably would have to be defined differently for this case.

     

    Last edit: Carl Ponder 2020-10-18
  • Carl Ponder

    Carl Ponder - 2020-10-18

    The file perf_examples/notify_group.c casts the assignement of a function-pointer using it's return-type rather than the parameter list:

    125c125
    <   act.sa_sigaction = (void *)sigio_handler;
    ---
    >   act.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sigio_handler;
    

    The error message it gave was

    "notify_group.c", line 125: error: a value of type "void (*)(int, siginfo_t *,
              struct sigcontext *)" cannot be assigned to an entity of type "void
              (*)(int, siginfo_t *, void *)"
        act.sa_sigaction = sigio_handler;
                         ^
    
    1 error detected in the compilation of "notify_group.c".
    make[1]: *** [notify_group.o] Error 2
    make[1]: Leaving directory `/cm/extra/Utils/PerfMon2/4.11.0/PGI-20.9/distro/perf_examples'
    
     
  • seranian

    seranian - 2020-10-19

    HI Carl,

    Thanks for the bug report.
    Could you send me a patch to fix all the PGI compiler warnings. I will apply it.
    Thank you.

     
  • Carl Ponder

    Carl Ponder - 2021-01-08

    The original post should have said "GCC compiler" not "GPU compiler". It looks like I don't have the option to edit it in-place.

     
  • Carl Ponder

    Carl Ponder - 2021-01-08

    Sorry about that. I uploaded the full files to the bug-report

    https://sourceforge.net/p/perfmon2/bugs/11/


    Subject: Re: [perfmon2:bugs] #11 Integer conversion errors with PGI
    compiler
    Date: Thu, 7 Jan 2021 17:31:11 -0800
    From: Stephane Eranian eranian@googlemail.com
    Reply-To: eranian@gmail.com
    To: Carl Ponder CarlPonder@yahoo.com
    CC: seranian seranian@users.sourceforge.net, [perfmon2:bugs]
    11@bugs.perfmon2.p.re.sourceforge.net

    Hi,

    Two of the patches you attached are simply removing the files:
    perf_util.c and pfmlib_perf_event_pmu.c. Obviously something is wrong there.
    Thanks.

    On Mon, Oct 19, 2020 at 3:31 PM Carl Ponder <CarlPonder@yahoo.com
    CarlPonder@yahoo.com> wrote:

    Here are the patches I generated. The perf_util.c and
    pfmlib_perf_event_pmu.c patch-files are bigger than the originals,
    so maybe diff -Naur wasn't the best command to run.
    I can send you the modified files if that's any better....
    
              -- Carl
    
    
    ------------------------------------------------------------------------
    Subject:    [perfmon2:bugs] #11 Integer conversion errors with PGI
    compiler
    Date:   Mon, 19 Oct 2020 20:02:15 -0000
    From:   seranian <seranian@users.sourceforge.net>
    <mailto:seranian@users.sourceforge.net>
    Reply-To:   [perfmon2:bugs] <11@bugs.perfmon2.p.re.sourceforge.net>
    <mailto:11@bugs.perfmon2.p.re.sourceforge.net>
    To:     [perfmon2:bugs] <11@bugs.perfmon2.p.re.sourceforge.net>
    <mailto:11@bugs.perfmon2.p.re.sourceforge.net>
    
    
    
    HI Carl,
    
    Thanks for the bug report.
    Could you send me a patch to fix all the PGI compiler warnings. I
    will apply it.
    Thank you.
    
    ------------------------------------------------------------------------
    
    *[bugs:#11] <https://sourceforge.net/p/perfmon2/bugs/11/> Integer
    conversion errors with PGI compiler*
    
    *Status:* open
    *Group:* v1.0 (example)
    *Labels:* PGI
    *Created:* Sat Oct 17, 2020 11:00 PM UTC by Carl Ponder
    *Last Updated:* Sun Oct 18, 2020 10:34 AM UTC
    *Owner:* seranian
    
    I'm able to build Perfmon2 4.11.0 using the PGI 20.9 compiler but I
    had to change the source code in a lot of places. The particular
    errors I see are
    
      error:integer  conversion  resulted  in  a  change  of  sign
          .umask_ovfl_idx  =  -1,
                                                                   ^
      error:integer  conversion  resulted  in  a  change  of  sign
              return  -1;
                                    ^
    
    which I believe comes from assigning the negative value to an
    unsigned integer type and may or may not involve re-sizing the
    bit-field. The PGI compiler is stricter than the GPU compiler so I
    expect the code is not compliant with the C/C++ standard in this
    respect.
    I was able to sqelch the error by adding a cast everywhere
    
    =  (unsigned  long)  -1
    
    but you might prefer to make the intent more explicit with something
    like
    
    #define  FULL_MASK  0xFFFFFFFFFFFFFFFFul
       .umask_ovfl_idx  =  FULL_MASK,
       return  FULL_MASK
    
    ------------------------------------------------------------------------
    
    Sent from sourceforge.net <http://sourceforge.net> because you
    indicated interest in https://sourceforge.net/p/perfmon2/bugs/11/
    
    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/
    
     

Log in to post a comment.

MongoDB Logo MongoDB