Teuchos: initializeKokkos' use of call_once requires TPL_ENABLE_Pthread=ON for serial g++ builds
Created by: kddevin
@trilinos/teuchos @trilinos/tpetra
Expectations and Current behavior
Serial builds with g++ and TPL_ENABLE_Pthread=OFF used to work. Now, with gnu compilers and TPL_ENABLE_Pthread=OFF, I can build in serial but Teuchos' initializeKokkos throws an error.
It appears that g++ requires Pthread to correctly execute std::call_once, which is used in initializeKokkos. Thus, TPL_ENABLE_Pthread=OFF leads to an error.
The attached program demonstrates the std::call_once behavior. Here are the compilations and test results. I've seen the same behavior with gcc 4.9.3, 6.3.1 and 7.2.1.
g++ -std=c++11 callOnce.cpp a.out In initialize 0 terminate called after throwing an instance of 'std::system_error' what(): Unknown error 18446744073709551615 Abort (core dumped) g++ -std=c++11 -pthread callOnce.cpp a.out In initialize 0 In initializeOnce 0 In initialize 1 In initialize 2 In initialize 3 In initialize 4 In initialize 5 In initialize 6 In initialize 7 In initialize 8 In initialize 9 Done: callCnt = 10; initCnt = 1
Motivation and Context
Serial builds of Zoltan2 tests with TPL_ENABLE_Pthread=OFF build but do not execute. Discovered trying to diagnose #3033 (closed)
Definition of Done
Possible Solution
Can the use of call_once be safely removed, with initializeKokkos just testing Kokkos' initialization status? Or is call_once really needed for threading?
Steps to Reproduce
Build serial Zoltan2 with gnu compilers and -DTPL_ENABLE_Pthread=OFF; make test.
Your Environment
module purge
module load sems-env
module load sems-gcc/4.9.3
cmake
-DTPL_ENABLE_Pthread:BOOL=OFF
-DTrilinos_ENABLE_SECONDARY_TESTED_CODE:BOOL=ON
-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=OFF
-DTrilinos_ENABLE_TESTS:BOOL=OFF
-DTrilinos_ENABLE_EXPLICIT_INSTANTIATION:BOOL=ON
-DTrilinos_ENABLE_Zoltan2:BOOL=ON
-DZoltan2_ENABLE_TESTS:BOOL=ON
..
Related Issues
- Blocks
- Is blocked by
- Follows
- Precedes
- Related to
- Part of
- Composed of