dace icon indicating copy to clipboard operation
dace copied to clipboard

Codegen: Invalid const reference generated

Open phschaad opened this issue 4 years ago • 0 comments

Description Invalid const references generated for left hand of assignments.

Steps to reproduce:

  1. Run the BFS sample (python samples/graph/bfs_bsp.py)
  2. Sample does not compile, gcc fails with binding reference of type 'unsigned int* const&' to 'unsigned int* __restrict__' discards qualifiers

Expected behavior Sample should compile and run.

Compilation output

python samples/graph/bfs_bsp.py

Data loaded
Breadth-First Search E=128, V=64
WARNING: Shadowing variable fsz0 from type (<DefinedType.Scalar: 2>, 'unsigned int') to DefinedType.Scalar
WARNING: Shadowing variable rowb0 from type (<DefinedType.Scalar: 2>, 'unsigned int') to DefinedType.Scalar
WARNING: Shadowing variable rowe0 from type (<DefinedType.Scalar: 2>, 'unsigned int') to DefinedType.Scalar
WARNING: Shadowing variable fsz1 from type (<DefinedType.Scalar: 2>, 'unsigned int') to DefinedType.Scalar
WARNING: Shadowing variable rowb1 from type (<DefinedType.Scalar: 2>, 'unsigned int') to DefinedType.Scalar
WARNING: Shadowing variable rowe1 from type (<DefinedType.Scalar: 2>, 'unsigned int') to DefinedType.Scalar
Traceback (most recent call last):
  File "dace/codegen/compiler.py", line 300, in configure_and_compile
    _run_liveoutput("cmake --build . --config %s" %
  File "dace/codegen/compiler.py", line 402, in _run_liveoutput
    raise subprocess.CalledProcessError(process.returncode, command,
subprocess.CalledProcessError: Command 'cmake --build . --config RelWithDebInfo' returned non-zero exit status 2.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "samples/graph/bfs_bsp.py", line 326, in <module>
    sdfg(G_row=G_row, G_col=G_col, depth=depth, srcnode=srcnode, E=E, V=V)
  File "dace/sdfg/sdfg.py", line 1829, in __call__
    binaryobj = sdfg.compile()
  File "dace/sdfg/sdfg.py", line 1709, in compile
    shared_library = compiler.configure_and_compile(program_folder,
  File "dace/codegen/compiler.py", line 310, in configure_and_compile
    raise cgx.CompilationError('Compiler failure:\n' + ex.output)
dace.codegen.exceptions.CompilationError: Compiler failure:
[ 50%] Built target dacestub_bfs_bsp
Scanning dependencies of target bfs_bsp
make[2]: Warning: File 'CMakeFiles/bfs_bsp.dir/depend.make' has modification time 0.21 s in the future
[ 75%] Building CXX object CMakeFiles/bfs_bsp.dir/.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp.o
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp: In function ‘void __program_bfs_bsp_internal(bfs_bsp_t*, unsigned int*, unsigned int*, unsigned int*, int, int, unsigned int)’:
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:12:49: warning: ‘new’ of type ‘unsigned int’ with extended alignment 64 [-Waligned-new=]
   12 |     frontier = new unsigned int DACE_ALIGN(64)[V];
      |                                                 ^
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:12:49: note: uses ‘void* operator new [](std::size_t)’, which does not have an alignment parameter
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:12:49: note: use ‘-faligned-new’ to enable C++17 over-aligned new support
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:14:50: warning: ‘new’ of type ‘unsigned int’ with extended alignment 64 [-Waligned-new=]
   14 |     frontier2 = new unsigned int DACE_ALIGN(64)[V];
      |                                                  ^
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:14:50: note: uses ‘void* operator new [](std::size_t)’, which does not have an alignment parameter
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:14:50: note: use ‘-faligned-new’ to enable C++17 over-aligned new support
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:63:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
   63 |             for (auto f = 0; f < fsz0; f += 1) {
      |                              ~~^~~~~~
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:86:59: error: binding reference of type ‘unsigned int* const&’ to ‘unsigned int* __restrict__’ discards qualifiers
   86 |                             unsigned int* const &in_col = &G_col[0];
      |                                                           ^~~~~~~~~
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:87:61: error: binding reference of type ‘unsigned int* const&’ to ‘unsigned int* __restrict__’ discards qualifiers
   87 |                             unsigned int* const &in_depth = &depth[0];
      |                                                             ^~~~~~~~~
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:133:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
  133 |             for (auto f = 0; f < fsz1; f += 1) {
      |                              ~~^~~~~~
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:156:59: error: binding reference of type ‘unsigned int* const&’ to ‘unsigned int* __restrict__’ discards qualifiers
  156 |                             unsigned int* const &in_col = &G_col[0];
      |                                                           ^~~~~~~~~
.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp:157:61: error: binding reference of type ‘unsigned int* const&’ to ‘unsigned int* __restrict__’ discards qualifiers
  157 |                             unsigned int* const &in_depth = &depth[0];
      |                                                             ^~~~~~~~~
make[2]: *** [CMakeFiles/bfs_bsp.dir/build.make:82: CMakeFiles/bfs_bsp.dir/.dacecache/bfs_bsp/src/cpu/bfs_bsp.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:124: CMakeFiles/bfs_bsp.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

Environment:

  • OS: Windows 10 with WSL2 (Ubuntu20.04)

phschaad avatar Jan 21 '21 13:01 phschaad