IntelLabs / ParallelAccelerator.jl

The ParallelAccelerator package, part of the High Performance Scripting project at Intel Labs
BSD 2-Clause "Simplified" License
294 stars 32 forks source link

CGen-generated function `_toplength()` returns warnings #108

Closed jihoonseo closed 8 years ago

jihoonseo commented 8 years ago

Hi When I execute my code, I get warnings and it seems that the CGen-generated function int64_t _toplength(StepRangeInt64Int64) causes these warnings.

FYI: bi2de() is a function that converts a binary array that LSB (least significant bit) is on the left to a decimal number.

FYI: You may test bi2de() with [0 1 0 1], like bi2de([0 1 0 1]) -> 10.

Here is my code:

using ParallelAccelerator

@acc function bi2de(binaryArray)
  binaryArray = reshape(binaryArray, length(binaryArray));
  z = 2 .^ (0:1:length(binaryArray)-1);
  return sum(binaryArray .* z)
end

result = bi2de([0 1 1 1])
println(result)

And the warnings are:

/tmp/tmpBTdtGp/cgen_output9.cpp: In function ‘int64_t _toplength(StepRangeInt64Int64)’: /tmp/tmpBTdtGp/cgen_output9.cpp:92:103: warning: right shift count >= width of type [-Wshift-count-overflow] return (cgen_flipsign_int(((r.stop) - (r.start)) / (cgen_flipsign_int(GenSym0, GenSym0)), GenSym0) >> 63 == 0 ? cgen_flipsign_int(((r.stop) - (r.start)) / (cgen_flipsign_int(GenSym0, GenSym0)), GenSym0) : cgen_flipsign_int(((r.stop) - (r.start)) / (cgen_flipsign_int(GenSym0, GenSym0)), GenSym0)) + (1); ^ (<- In the Julia console, this hat is pointing the number 63)

/tmp/tmpBTdtGp/cgen_output9.cpp:97:103: warning: right shift count >= width of type [-Wshift-count-overflow] return (cgen_flipsign_int(((r.start) - (r.stop)) / (cgen_flipsign_int(GenSym1, GenSym1)), GenSym1) >> 63 == 0 ? cgen_flipsign_int(((r.start) - (r.stop)) / (cgen_flipsign_int(GenSym1, GenSym1)), GenSym1) : cgen_flipsign_int(((r.start) - (r.stop)) / (cgen_flipsign_int(GenSym1, GenSym1)), GenSym1)) + (1); ^ (<- In the Julia console, this hat is pointing the number 63)


According to #104 , this warnings are not displayed with the July 12th version of ParallelAccelerator.

I would appreciate your comments.


FYI: Here is the CGen-generated function int64_t _toplength(StepRangeInt64Int64)

int64_t _toplength(StepRangeInt64Int64 r)
{
        int64_t GenSym0;
        int64_t GenSym1;
        if (!((!((r.start == r.stop))) & (!(((0) < (r.step) == (r.start) < (r.stop)))))) goto label0;
        return 0;
label0 : ;
         if (!((1) < (r.step))) goto label1;
         GenSym0 = r.step;
         return (cgen_flipsign_int(((r.stop) - (r.start)) / (cgen_flipsign_int(GenSym0, GenSym0)), GenSym0) >> 63 == 0 ? cgen_flipsign_int(((r.stop) - (r.start)) / (cgen_flipsign_int(GenSym0, GenSym0)), GenSym0) : cgen_flipsign_int(((r.stop) - (r.start)) / (cgen_flipsign_int(GenSym0, GenSym0)), GenSym0)) + (1);
         goto label3;
label1 : ;
         if (!((r.step) < (-1))) goto label2;
         GenSym1 = -(r.step);
         return (cgen_flipsign_int(((r.start) - (r.stop)) / (cgen_flipsign_int(GenSym1, GenSym1)), GenSym1) >> 63 == 0 ? cgen_flipsign_int(((r.start) - (r.stop)) / (cgen_flipsign_int(GenSym1, GenSym1)), GenSym1) : cgen_flipsign_int(((r.start) - (r.stop)) / (cgen_flipsign_int(GenSym1, GenSym1)), GenSym1)) + (1);
         goto label3;
label2 : ;
         return (((r.stop) - (r.start)) / (r.step)) + (1);
label3 : ;

}
ninegua commented 8 years ago

Sorry for my late reply. The issue should have been fixed by 303c1b4. Thanks for reporting it!