Page MenuHomePhabricator

[OpenMP] Use C++11 Atomics - barrier, tasking, and lock code
ClosedPublic

Authored by jlpeyton on Jun 7 2018, 1:14 PM.

Details

Summary

These are preliminary changes that attempt to use C++11 Atomics in the runtime.
We are expecting better portability with this change across architectures/OSes.
Here is the summary of the changes.

  • Most variables that need synchronization operation were converted to generic atomic variables (std::atomic<T>)
  • Variables that are updated with combined CAS are packed into a single atomic variable, and partial read/write is done through unpacking/packing

Patch by Hansang Bae

Diff Detail

Repository
rL LLVM

Event Timeline

jlpeyton created this revision.Jun 7 2018, 1:14 PM
protze.joachim added inline comments.
runtime/src/kmp_runtime.cpp
3393 ↗(On Diff #150396)

Is there a reason, why this does not use a macro?

runtime/src/kmp_tasking.cpp
2988 ↗(On Diff #150396)

Same here

jlpeyton updated this revision to Diff 150574.Jun 8 2018, 2:58 PM

Updated load() calls to use KMP_ATOMIC_LD_RLX() macro instead

runtime/src/kmp_taskdeps.cpp
43 ↗(On Diff #150574)

This store can be relaxed I think.

runtime/src/kmp_tasking.cpp
1984 ↗(On Diff #150574)

This assignment also can be relaxed I think.

jlpeyton updated this revision to Diff 154453.Jul 6 2018, 2:09 PM

Updated to address Andrey's comments.

kkwli0 added a subscriber: kkwli0.Jul 7 2018, 8:10 PM
This revision is now accepted and ready to land.Jul 9 2018, 8:56 AM
This revision was automatically updated to reflect the committed changes.

Hello.
This broke the build:

$ ninja
[0/17] Performing build step for 'libcxx_fuzzer_x86_64'
ninja: no work to do.
[2/17] Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o
FAILED: projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o 
/usr/bin/clang++-6.0  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Domp_EXPORTS -Iprojects/openmp/runtime/src -I/build/openmp/runtime/src -I/usr/include/libxml2 -Iinclude -I/build/llvm/include -I/build/openmp/runtime/src/i18n -I/build/openmp/runtime/src/include/50 -I/build/openmp/runtime/src/thirdparty/ittnotify -g0 -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -std=c++11 -O3 -g0  -fPIC   -UNDEBUG -D _GNU_SOURCE -D _REENTRANT -fno-exceptions -fno-rtti -Wno-sign-compare -Wno-unused-function -Wno-unused-local-typedef -Wno-unused-value -Wno-unused-variable -Wno-switch -Wno-covered-switch-default -Wno-deprecated-register -Wno-gnu-anonymous-struct -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-missing-braces -Wno-comment -Wno-self-assign -Wno-vla-extension -Wno-format-pedantic -MD -MT projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o -MF projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o.d -o projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o -c /build/openmp/runtime/src/kmp_wait_release.cpp
In file included from /build/openmp/runtime/src/kmp_wait_release.cpp:14:
/build/openmp/runtime/src/kmp_wait_release.h:175:29: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
    KMP_FSYNC_SPIN_ACQUIRED(spin);
                            ^
/build/openmp/runtime/src/kmp_wait_release.h:346:28: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
    KMP_FSYNC_SPIN_PREPARE(spin);
                           ^
/build/openmp/runtime/src/kmp_wait_release.h:453:27: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
  KMP_FSYNC_SPIN_ACQUIRED(spin);
                          ^
/build/openmp/runtime/src/kmp_wait_release.h:175:29: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
    KMP_FSYNC_SPIN_ACQUIRED(spin);
                            ^

and several more pages of this.
If this can't be fixed soon (a hour?), *please* revert.

Hello.
This broke the build:

$ ninja
[0/17] Performing build step for 'libcxx_fuzzer_x86_64'
ninja: no work to do.
[2/17] Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o
FAILED: projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o 
/usr/bin/clang++-6.0  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Domp_EXPORTS -Iprojects/openmp/runtime/src -I/build/openmp/runtime/src -I/usr/include/libxml2 -Iinclude -I/build/llvm/include -I/build/openmp/runtime/src/i18n -I/build/openmp/runtime/src/include/50 -I/build/openmp/runtime/src/thirdparty/ittnotify -g0 -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -std=c++11 -O3 -g0  -fPIC   -UNDEBUG -D _GNU_SOURCE -D _REENTRANT -fno-exceptions -fno-rtti -Wno-sign-compare -Wno-unused-function -Wno-unused-local-typedef -Wno-unused-value -Wno-unused-variable -Wno-switch -Wno-covered-switch-default -Wno-deprecated-register -Wno-gnu-anonymous-struct -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-missing-braces -Wno-comment -Wno-self-assign -Wno-vla-extension -Wno-format-pedantic -MD -MT projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o -MF projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o.d -o projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o -c /build/openmp/runtime/src/kmp_wait_release.cpp
In file included from /build/openmp/runtime/src/kmp_wait_release.cpp:14:
/build/openmp/runtime/src/kmp_wait_release.h:175:29: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
    KMP_FSYNC_SPIN_ACQUIRED(spin);
                            ^
/build/openmp/runtime/src/kmp_wait_release.h:346:28: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
    KMP_FSYNC_SPIN_PREPARE(spin);
                           ^
/build/openmp/runtime/src/kmp_wait_release.h:453:27: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
  KMP_FSYNC_SPIN_ACQUIRED(spin);
                          ^
/build/openmp/runtime/src/kmp_wait_release.h:175:29: error: cast from 'volatile void *' to 'void *' drops volatile qualifier [-Werror,-Wcast-qual]
    KMP_FSYNC_SPIN_ACQUIRED(spin);
                            ^

and several more pages of this.
If this can't be fixed soon (a hour?), *please* revert.

I just committed 336586 which should fix this.