Skip to content

AOCC Fails at constexpr check for MPI type #3254

@yizeyi18

Description

@yizeyi18

Describe the bug

When compiling ABACUS using AOCC-4.1, error below occurs:

In file included from /home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/transfer.cpp:1:
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:157:35: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    static constexpr MPI_Datatype datatype()
                                  ^
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:159:16: note: cast from 'void *' is not allowed in a constant expression
        return MPI_INT;
               ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:1188:17: note: expanded from macro 'MPI_INT'
#define MPI_INT OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_int)
                ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:400:47: note: expanded from macro 'OMPI_PREDEFINED_GLOBAL'
#define OMPI_PREDEFINED_GLOBAL(type, global) (static_cast<type> (static_cast<void *> (&(global))))
                                              ^
In file included from /home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/transfer.cpp:1:
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:166:35: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    static constexpr MPI_Datatype datatype()
                                  ^
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:168:16: note: cast from 'void *' is not allowed in a constant expression
        return MPI_DOUBLE;
               ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:1191:20: note: expanded from macro 'MPI_DOUBLE'
#define MPI_DOUBLE OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_double)
                   ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:400:47: note: expanded from macro 'OMPI_PREDEFINED_GLOBAL'
#define OMPI_PREDEFINED_GLOBAL(type, global) (static_cast<type> (static_cast<void *> (&(global))))
                                              ^
In file included from /home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/transfer.cpp:1:
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:175:35: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    static constexpr MPI_Datatype datatype()
                                  ^
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:177:16: note: cast from 'void *' is not allowed in a constant expression
        return MPI_DOUBLE_COMPLEX;
               ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:1266:28: note: expanded from macro 'MPI_DOUBLE_COMPLEX'
#define MPI_DOUBLE_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_dblcplex)
                           ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:400:47: note: expanded from macro 'OMPI_PREDEFINED_GLOBAL'
#define OMPI_PREDEFINED_GLOBAL(type, global) (static_cast<type> (static_cast<void *> (&(global))))
                                              ^
[ 13%] Building CXX object source/module_base/CMakeFiles/base.dir/formatter_contextfmt.cpp.o
In file included from /home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/func_transfer.cpp:2:
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:157:35: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    static constexpr MPI_Datatype datatype()
                                  ^
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:159:16: note: cast from 'void *' is not allowed in a constant expression
        return MPI_INT;
               ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:1188:17: note: expanded from macro 'MPI_INT'
#define MPI_INT OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_int)
                ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:400:47: note: expanded from macro 'OMPI_PREDEFINED_GLOBAL'
#define OMPI_PREDEFINED_GLOBAL(type, global) (static_cast<type> (static_cast<void *> (&(global))))
                                              ^
In file included from /home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/func_transfer.cpp:2:
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:166:35: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    static constexpr MPI_Datatype datatype()
                                  ^
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:168:16: note: cast from 'void *' is not allowed in a constant expression
        return MPI_DOUBLE;
               ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:1191:20: note: expanded from macro 'MPI_DOUBLE'
#define MPI_DOUBLE OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_double)
                   ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:400:47: note: expanded from macro 'OMPI_PREDEFINED_GLOBAL'
#define OMPI_PREDEFINED_GLOBAL(type, global) (static_cast<type> (static_cast<void *> (&(global))))
                                              ^
In file included from /home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/func_transfer.cpp:2:
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:175:35: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    static constexpr MPI_Datatype datatype()
                                  ^
/home/yizeyi18/soft/abacus-develop-3.4.3/source/module_hamilt_lcao/module_hcontainer/./transfer.h:177:16: note: cast from 'void *' is not allowed in a constant expression
        return MPI_DOUBLE_COMPLEX;
               ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:1266:28: note: expanded from macro 'MPI_DOUBLE_COMPLEX'
#define MPI_DOUBLE_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_dblcplex)
                           ^
/home/yizeyi18/soft/spack/opt/spack/linux-ubuntu22.04-zen3/aocc-4.0.0/openmpi-4.1.5-tbilqgadlyp2c7z2zjeycbmascep3xfy/include/mpi.h:400:47: note: expanded from macro 'OMPI_PREDEFINED_GLOBAL'
#define OMPI_PREDEFINED_GLOBAL(type, global) (static_cast<type> (static_cast<void *> (&(global))))
                                              ^
3 errors generated.
make[2]: *** [source/module_hamilt_lcao/module_hcontainer/CMakeFiles/hcontainer.dir/build.make:146:source/module_hamilt_lcao/module_hcontainer/CMakeFiles/hcontainer.dir/transfer.cpp.o] 错误 1
make[2]: *** 正在等待未完成的任务....

Expected behavior

The code should pass compile.

To Reproduce

Build use AOCC-4.0 or 4.1.

Environment

OS: Ubuntu 22.04 LTS on linux-6.2.0-34-generic

Compiler: aocc-4.1

Dependencies: OpenBLAS-0.3.24, openmpi-4.1.5

Additional Context

This patch may fix, though breaks some safety check performed by the compiler:
aocc-mpi.patch

Task list for Issue attackers (only for developers)

  • Verify the issue is not a duplicate.
  • Describe the bug.
  • Steps to reproduce.
  • Expected behavior.
  • Error message.
  • Environment details.
  • Additional context.
  • Assign a priority level (low, medium, high, urgent).
  • Assign the issue to a team member.
  • Label the issue with relevant tags.
  • Identify possible related issues.
  • Create a unit test or automated test to reproduce the bug (if applicable).
  • Fix the bug.
  • Test the fix.
  • Update documentation (if necessary).
  • Close the issue and inform the reporter (if applicable).

Metadata

Metadata

Assignees

Labels

BugsBugs that only solvable with sufficient knowledge of DFT

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions