diff options
author | ro <ro@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-12-01 14:48:49 +0000 |
---|---|---|
committer | ro <ro@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-12-01 14:48:49 +0000 |
commit | 86ca8e68af993525fbeec99801ab0ae13ec01ab9 (patch) | |
tree | 83c3b77cae05a0c182a00cf464001b9a46b07c78 /libcilkrts | |
parent | 966eb906bca63d4298a66b6807cf7503078e7289 (diff) | |
download | gcc-86ca8e68af993525fbeec99801ab0ae13ec01ab9.tar.gz |
Import libcilkrts Build 4467 (PR target/68945)
PR target/68945
Merge from upstream, version 2.0.4467.0.
Fix typo in git URL.
* aclocal.m4, configure, Makefile.in: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243112 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcilkrts')
29 files changed, 530 insertions, 68 deletions
diff --git a/libcilkrts/ChangeLog b/libcilkrts/ChangeLog index 68ca82a76ee..443f0a2e2a9 100644 --- a/libcilkrts/ChangeLog +++ b/libcilkrts/ChangeLog @@ -1,3 +1,10 @@ +2016-12-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + PR target/68945 + Merge from upstream, version 2.0.4467.0. + Fix typo in git URL. + * aclocal.m4, configure, Makefile.in: Regenerate. + 2016-11-15 Matthias Klose <doko@ubuntu.com> * configure: Regenerate. diff --git a/libcilkrts/Makefile.am b/libcilkrts/Makefile.am index 3736a636fb1..1dec6aa25a1 100644 --- a/libcilkrts/Makefile.am +++ b/libcilkrts/Makefile.am @@ -54,7 +54,7 @@ GENERAL_FLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/runtime -I$(top_srcdir)/ # Enable Intel Cilk Plus extension GENERAL_FLAGS += -fcilkplus -# Always generate unwind tables +#Always generate unwind tables GENERAL_FLAGS += -funwind-tables AM_CFLAGS = $(XCFLAGS) $(GENERAL_FLAGS) -std=c99 diff --git a/libcilkrts/Makefile.in b/libcilkrts/Makefile.in index ff88e9dab89..6520b16012c 100644 --- a/libcilkrts/Makefile.in +++ b/libcilkrts/Makefile.in @@ -396,7 +396,7 @@ ACLOCAL_AMFLAGS = -I .. -I ../config # Enable Intel Cilk Plus extension -# Always generate unwind tables +#Always generate unwind tables GENERAL_FLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/runtime \ -I$(top_srcdir)/runtime/config/$(config_dir) \ -I$(top_srcdir)/runtime/sslib -DIN_CILK_RUNTIME=1 -fcilkplus \ @@ -455,7 +455,7 @@ libcilkrts_la_SOURCES = \ runtime/sysdep-unix.c \ runtime/worker_mutex.c -CILK_REVISION = 4420 +CILK_REVISION = 4467 # Load the $(REVISION) value. diff --git a/libcilkrts/README b/libcilkrts/README index d3503f44e34..54f8b044294 100644 --- a/libcilkrts/README +++ b/libcilkrts/README @@ -1,14 +1,16 @@ -Intel(R) Cilk(TM) Plus runtime library +Intel(R) Cilk(TM) Plus Runtime Library Index: -1. BUILDING -2. USING -3. DOXYGEN DOCUMENTATION -4. QUESTIONS OR BUGS -5. CONTRIBUTIONS +1. BUILDING WITH AUTOMAKE +2. BUILDING WITH CMAKE +3. INSTALLING TO VXWORKS +4. USING +5. DOXYGEN DOCUMENTATION +6. QUESTIONS OR BUGS +7. CONTRIBUTIONS # -# 1. BUILDING: +# 1. BUILDING WITH AUTOMAKE: # To distribute applications that use the Intel Cilk Plus language @@ -40,22 +42,87 @@ configure script: % ./configure --prefix=/your/path/to/lib -It is also possible to use CMake if the above method does not apply -well in your environment. Instruction is available in CMakeLists.txt. +# +# 2. BUILDING WITH CMAKE: +# + +To distribute applications that use the Intel Cilk Plus language +extensions to non-development systems, you need to build the Intel +Cilk Plus runtime library and distribute it with your application. +This instruction describes the build process using CMake*, which +supports Linux*, Windows*, and OS X*. It is fine to use this process +to build a Linux library, but it is highly recommended to use the +more mature build process described above when building on Linux. + +You need the CMake tool and a C/C++ compiler that supports the Intel +Cilk Plus language extensions, and the requirements for each operating +systems are: + +Common: + CMake 3.0.0 or later + Make tools such as make (Linux, OS X) or nmake (Windows) +Linux: + GCC* 4.9.2 or later, or Intel(R) C++ Compiler v12.1 or later +Windows: + Intel C++ Compiler v12.1 or later + Visual Studio* 2010 or later +OS X: + Cilk-enabled branch of Clang*/LLVM* (http://cilkplus.github.io), + or Intel C++ Compiler v12.1 or later + +The common steps to build the libraries are 1) invoke cmake with +appropriate options, 2) invoke a make tool available on the system. +The following examples show build processes on OS X and Windows. + +OS X: + % mkdir ./build && cd ./build + % cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_INSTALL_PREFIX=./install .. + % make && make install + +Windows: + % mkdir .\build && cd .\build + % cmake -G "NMake Makefiles" -DCMAKE_C_COMPILER=icl \ + -DCMAKE_CXX_COMPILER=icl -DCMAKE_INSTALL_PREFIX=.\install .. + % nmake && nmake install + +# +# 3. INSTALLING TO VXWORKS OS +# + +For Windows host, run VxWorks_Install.bat. +For Linux host, run VxWorks_Install.sh. + +You may need to give environment variable WIND_BASE to indicate VxWorks +installation path. + +Create a VSB project, and you will see a layer named "CILKPLUS_KERNEL". +Enable it and build the project. + +Create a VIP project with ICC and add component INCLUDE_CILKPLUS, then you +will get support of Intel Cilk Plus features in VxWorks. # -# 2. USING: +# 4. USING: # The Intel(R) C++ Compiler will automatically try to bring in the Intel Cilk Plus runtime in any program that uses the relevant -features. GCC requires explicit linking of both the library and -its dependencies (libpthread, libdl). For example: +features. GCC and Clang requires an explicit compiler option, +-fcilkplus, to enable Intel Cilk Plus language extensions. +For example, + +% gcc -fcilkplus -o foo.exe foo.c +% clang -fcilkplus -o foo.exe foo.c + +Older GCC versions (e.g., 4.8 cilkplus branch) requires explicit linking +of both the library and its dependencies (libpthread, libdl). +For example: % gcc foo.c -lcilkrts -lpthread -ldl # -# 3. DOXYGEN DOCUMENTATION: +# 5. DOXYGEN DOCUMENTATION: # The library source has Doxygen markup. Generate HTML documentation @@ -64,7 +131,7 @@ based on the markup by changing directory into runtime and running: % doxygen doxygen.cfg # -# 4. QUESTIONS OR BUGS: +# 6. QUESTIONS OR BUGS: # Issues with the Intel Cilk Plus runtime can be addressed in the Intel @@ -72,7 +139,7 @@ Cilk Plus forums: http://software.intel.com/en-us/forums/intel-cilk-plus/ # -# 5. CONTRIBUTIONS: +# 7. CONTRIBUTIONS: # The Intel Cilk Plus runtime library is dual licensed. The upstream copy @@ -85,6 +152,13 @@ contributed to the upstream version via http://cilkplus.org/. Thanks to Tobias Burnus for showing us the magic to make gcc and g++ automatically include the Cilk Plus runtime. +Thanks to Eric Olson for sharing his patch for Raspberry Pi* with us. + +Thanks to Rainer Orth for submitting patches for exception handling and +enabling Cilk Plus on the SPARC* architecture. + ------------------------ Intel and Cilk are trademarks of Intel Corporation in the U.S. and/or other countries. + +*Other names and brands may be claimed as the property of others. diff --git a/libcilkrts/configure b/libcilkrts/configure index c04df2bafba..ecf88eee2a9 100644 --- a/libcilkrts/configure +++ b/libcilkrts/configure @@ -5676,6 +5676,50 @@ _ACEOF fi +# Check for dl functions +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dladdr in -ldl" >&5 +$as_echo_n "checking for dladdr in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dladdr+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dladdr (); +int +main () +{ +return dladdr (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dladdr=yes +else + ac_cv_lib_dl_dladdr=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dladdr" >&5 +$as_echo "$ac_cv_lib_dl_dladdr" >&6; } +if test "x$ac_cv_lib_dl_dladdr" = x""yes; then : + +$as_echo "#define HAVE_DLADDR 1" >>confdefs.h + +fi + + # Check whether the target supports protected visibility. save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" @@ -5766,11 +5810,7 @@ esac # contains information on what's needed case "${target}" in - x86_64-*-*) - config_dir="x86" - ;; - - i?86-*-*) + i?86-*-* | x86_64-*-*) config_dir="x86" ;; @@ -5778,6 +5818,10 @@ case "${target}" in config_dir="arm" ;; + sparc*-*-*) + config_dir="sparc" + ;; + *) config_dir="generic" ;; @@ -11893,7 +11937,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11896 "configure" +#line 11940 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11999,7 +12043,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12002 "configure" +#line 12046 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/libcilkrts/configure.ac b/libcilkrts/configure.ac index 39efeb4f532..8270e0b8bd9 100644 --- a/libcilkrts/configure.ac +++ b/libcilkrts/configure.ac @@ -69,6 +69,10 @@ AC_PROG_CXX AC_CONFIG_FILES([Makefile libcilkrts.spec]) AC_FUNC_ALLOCA +# Check for dl functions +AC_CHECK_LIB(dl, dladdr, + [AC_DEFINE(HAVE_DLADDR, 1, [Define if you have dladdr()])]) + # Check whether the target supports protected visibility. save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" @@ -141,11 +145,7 @@ esac # contains information on what's needed case "${target}" in - x86_64-*-*) - config_dir="x86" - ;; - - i?86-*-*) + i?86-*-* | x86_64-*-*) config_dir="x86" ;; @@ -153,6 +153,10 @@ case "${target}" in config_dir="arm" ;; + sparc*-*-*) + config_dir="sparc" + ;; + *) config_dir="generic" ;; diff --git a/libcilkrts/configure.tgt b/libcilkrts/configure.tgt index 7f0befc870c..71f69b0840a 100644 --- a/libcilkrts/configure.tgt +++ b/libcilkrts/configure.tgt @@ -44,12 +44,12 @@ # Disable Cilk Runtime library for unsupported architectures. case "${target}" in - x86_64-*-*) - ;; - i?86-*-*) + i?86-*-* | x86_64-*-*) ;; arm-*-*) ;; + sparc*-*-*) + ;; *-*-*) UNSUPPORTED=1 ;; diff --git a/libcilkrts/include/cilk/cilk_undocumented.h b/libcilkrts/include/cilk/cilk_undocumented.h index 5f4a8c5dff1..71a51ec52d6 100644 --- a/libcilkrts/include/cilk/cilk_undocumented.h +++ b/libcilkrts/include/cilk/cilk_undocumented.h @@ -106,9 +106,6 @@ size_t __cilkrts_get_stack_size(void); CILK_EXPORT __CILKRTS_NOTHROW void __cilkrts_dump_stats(void); -CILK_EXPORT __CILKRTS_NOTHROW -int __cilkrts_irml_version(void); - struct __cilk_tbb_unwatch_thunk; struct __cilk_tbb_stack_op_thunk; diff --git a/libcilkrts/include/internal/cilk_version.h b/libcilkrts/include/internal/cilk_version.h index 95e1f2ec544..c997b026f9d 100644 --- a/libcilkrts/include/internal/cilk_version.h +++ b/libcilkrts/include/internal/cilk_version.h @@ -49,10 +49,10 @@ #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_BUILD 4420 +#define VERSION_BUILD 4467 #define VERSION_REV 0 -#define VERSION_STRING "2,0,4420,0" -#define VERSION_HASH "3b2d6aa9059c" +#define VERSION_STRING "2,0,4467,0" +#define VERSION_HASH "b7e54d87bd17" #define VERSION_BRANCH "eng" -#define TBB_REV_NUMBER "14788" -#define VERSION_YEAR "2015" +#define TBB_REV_NUMBER "" +#define VERSION_YEAR "2016" diff --git a/libcilkrts/include/internal/rev.mk b/libcilkrts/include/internal/rev.mk index 96ffdc4aa4e..cd78865739b 100644 --- a/libcilkrts/include/internal/rev.mk +++ b/libcilkrts/include/internal/rev.mk @@ -49,4 +49,4 @@ # # It was automatically generated by cilkrts/include/internal/Makefile -CILK_REVISION = 4420 +CILK_REVISION = 4467 diff --git a/libcilkrts/runtime/cilk-abi.c b/libcilkrts/runtime/cilk-abi.c index 35bb413bf0a..8487873f00e 100644 --- a/libcilkrts/runtime/cilk-abi.c +++ b/libcilkrts/runtime/cilk-abi.c @@ -709,7 +709,6 @@ __cilkrts_watch_stack(__cilk_tbb_unwatch_thunk *u, return 0; /* Success! */ } - // This function must be called only within a continuation, within the stack // frame of the continuation itself. CILK_API_INT __cilkrts_synched(void) diff --git a/libcilkrts/runtime/cilk_fiber-unix.cpp b/libcilkrts/runtime/cilk_fiber-unix.cpp index d59bfcae4cb..c38c49f5538 100644 --- a/libcilkrts/runtime/cilk_fiber-unix.cpp +++ b/libcilkrts/runtime/cilk_fiber-unix.cpp @@ -220,7 +220,7 @@ NORETURN cilk_fiber_sysdep::run() // enough extra space from the top of the stack we are // switching to for any temporaries required for this run() // function. - JMPBUF_SP(m_resume_jmpbuf) = m_stack_base - frame_size; + JMPBUF_SP(m_resume_jmpbuf) = CILK_ADJUST_SP(m_stack_base - frame_size); // GCC doesn't allow us to call __builtin_longjmp in the same function // that calls __builtin_setjmp, so it's been moved into it's own diff --git a/libcilkrts/runtime/cilk_fiber.h b/libcilkrts/runtime/cilk_fiber.h index d91687aa57a..43057f22a15 100644 --- a/libcilkrts/runtime/cilk_fiber.h +++ b/libcilkrts/runtime/cilk_fiber.h @@ -73,9 +73,12 @@ * * A value of 0 means no debugging. * Higher values generate more debugging output. + * */ -#define FIBER_DEBUG 0 +#ifndef FIBER_DEBUG +#define FIBER_DEBUG 0 +#endif /** * @brief Flag for validating reference counts. * diff --git a/libcilkrts/runtime/config/arm/os-fence.h b/libcilkrts/runtime/config/arm/os-fence.h index 67e157a19e5..779a2dc0485 100644 --- a/libcilkrts/runtime/config/arm/os-fence.h +++ b/libcilkrts/runtime/config/arm/os-fence.h @@ -47,6 +47,14 @@ * for your assistance in helping us improve Cilk Plus. **************************************************************************/ +// __atomic_* intrinsics are available since GCC 4.7. +#define HAVE_ATOMIC_INTRINSICS defined(__GNUC__) && \ + (__GNUC__ * 10 + __GNUC_MINOR__ >= 47) + +// GCC before 4.4 does not implement __sync_synchronize properly +#define HAVE_SYNC_INTRINSICS defined(__GNUC__) && \ + (__GNUC__ * 10 + __GNUC_MINOR__ >= 44) + /* * void __cilkrts_fence(void) * @@ -60,5 +68,12 @@ * the CPUID instruction). */ -// COMMON_SYSDEP void __cilkrts_fence(void); ///< MFENCE instruction -# define __cilkrts_fence() __asm__ __volatile__ ("mcr p15,0,%[t],c7,c10,4\n" :: [t] "r" (0) : "memory"); +#if HAVE_ATOMIC_INTRINSICS +# define __cilkrts_fence() __atomic_thread_fence(__ATOMIC_SEQ_CST) +#elif HAVE_SYNC_INTRINSICS +# define __cilkrts_fence() __sync_synchronize() +#else +# define __cilkrts_fence() +// Leaving this code just in case. +//# define __cilkrts_fence() __asm__ __volatile__ ("mcr p15,0,%[t],c7,c10,4\n" :: [t] "r" (0) : "memory"); +#endif diff --git a/libcilkrts/runtime/config/sparc/cilk-abi-vla.c b/libcilkrts/runtime/config/sparc/cilk-abi-vla.c new file mode 100644 index 00000000000..cf88d997046 --- /dev/null +++ b/libcilkrts/runtime/config/sparc/cilk-abi-vla.c @@ -0,0 +1,115 @@ +/* cilk-abi-vla.cpp -*-C++-*- + * + ************************************************************************* + * + * Copyright (C) 2013-2016, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * ********************************************************************* + * + * PLEASE NOTE: This file is a downstream copy of a file mainitained in + * a repository at cilkplus.org. Changes made to this file that are not + * submitted through the contribution process detailed at + * http://www.cilkplus.org/submit-cilk-contribution will be lost the next + * time that a new version is released. Changes only submitted to the + * GNU compiler collection or posted to the git repository at + * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are + * not tracked. + * + * We welcome your contributions to this open source project. Thank you + * for your assistance in helping us improve Cilk Plus. + * + **************************************************************************/ + +/* + * Implementation of Variable Length Array (VLA) ABI. + * + * The compiler calls these functions to allocate Variable Length Arrays + * at runtime. The compiler must guarantee that __cilkrts_stack_free() is + * called to cleanup any memory allocated by __cilkrts_stack_alloc(). + * + * This generic implementation always allocates the memory from the heap. + * Optimally, the implementation should expand the frame of the calling + * function if possible, since that will be faster. See the x86 version + * for one possible implementation. + */ + +#include <assert.h> +#include <stdlib.h> +#include <stdint.h> + +#include "internal/abi.h" +#include "cilk-abi-vla-internal.h" + +// Allocate space for a variable length array +CILK_ABI(__cilkrts_void_ptr) +__cilkrts_stack_alloc( + __cilkrts_stack_frame *sf, + size_t size, + size_t distance_from_sp_to_alloca_area, + uint32_t align, // align is always >= minimum stack alignment and + // >= ptr_size as well, and must be a power of 2. + uint32_t needs_tag // non-zero if the pointer being returned needs to + // be tagged +) +{ + // full_size will be a multiple of align, and contains + // enough extra space to allocate a marker. + size_t full_size = (size + align - 1) & ~(align - 1); + + // Allocate memory from the heap. The compiler is responsible + // for guaranteeing us a chance to free it before the function + // exits + + return (void *)vla_internal_heap_alloc(sf, full_size, align); +} + +// Free the space allocated for a variable length array. +CILK_ABI(void) +__cilkrts_stack_free( + __cilkrts_stack_frame *sf, + void *p, + size_t size, + size_t distance_from_sp_to_alloca_area, + uint32_t align, // same requirements as for align in allocation, + // and must match alignment that was passed when + // doing the allocation + uint32_t known_from_stack // non-zero if this is known to be allocated + // on the stack, and therefore has no tag +) +{ + // full_size will be a multiple of align, and contains + // enough extra space to allocate a marker if one was needed. + size_t full_size = (size + align - 1) & ~(align - 1); + + // Just free the allocated memory to the heap since we don't know + // how to expand/contract the calling frame + vla_internal_heap_free(p, full_size); +} diff --git a/libcilkrts/runtime/config/sparc/os-fence.h b/libcilkrts/runtime/config/sparc/os-fence.h new file mode 100644 index 00000000000..24e7993e453 --- /dev/null +++ b/libcilkrts/runtime/config/sparc/os-fence.h @@ -0,0 +1,64 @@ +/* os.h -*-C++-*- + * + ************************************************************************* + * + * Copyright (C) 2009-2016, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * ********************************************************************* + * + * PLEASE NOTE: This file is a downstream copy of a file mainitained in + * a repository at cilkplus.org. Changes made to this file that are not + * submitted through the contribution process detailed at + * http://www.cilkplus.org/submit-cilk-contribution will be lost the next + * time that a new version is released. Changes only submitted to the + * GNU compiler collection or posted to the git repository at + * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are + * not tracked. + * + * We welcome your contributions to this open source project. Thank you + * for your assistance in helping us improve Cilk Plus. + **************************************************************************/ + +// GCC before 4.4 does not implement __sync_synchronize properly +#define HAVE_SYNC_INTRINSICS defined(__GNUC__) && \ + (__GNUC__ * 10 + __GNUC_MINOR__ >= 44) + +/* + * void __cilkrts_fence(void) + */ + +#if HAVE_SYNC_INTRINSICS +# define __cilkrts_fence() __sync_synchronize() +#elif defined(__GNUC__) +# define __cilkrts_fence() __asm__ volatile ("membar #StoreLoad" ::: "memory") +#else +COMMON_SYSDEP void __cilkrts_fence(void); +#endif diff --git a/libcilkrts/runtime/config/sparc/os-unix-sysdep.c b/libcilkrts/runtime/config/sparc/os-unix-sysdep.c new file mode 100644 index 00000000000..997e9f6892f --- /dev/null +++ b/libcilkrts/runtime/config/sparc/os-unix-sysdep.c @@ -0,0 +1,115 @@ +/* os-unix-sysdep.c -*-C-*- + * + ************************************************************************* + * + * Copyright (C) 2009-2016, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * ********************************************************************* + * + * PLEASE NOTE: This file is a downstream copy of a file mainitained in + * a repository at cilkplus.org. Changes made to this file that are not + * submitted through the contribution process detailed at + * http://www.cilkplus.org/submit-cilk-contribution will be lost the next + * time that a new version is released. Changes only submitted to the + * GNU compiler collection or posted to the git repository at + * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are + * not tracked. + * + * We welcome your contributions to this open source project. Thank you + * for your assistance in helping us improve Cilk Plus. + ************************************************************************* + * + * This file contains system-specific code for sparc-based systems + */ + +#include "os.h" +#include "sysdep.h" + +/* + * The cycle counter is used for debugging. This function is only called if + * CILK_PROFILE is defined when the runtime is built. + */ +COMMON_SYSDEP unsigned long long __cilkrts_getticks(void) +{ + unsigned long long tick; +#ifdef __sparcv9 + __asm__ volatile("rd %%tick, %0" : "=r"(tick)); +#else + __asm__ volatile("rd %%tick, %L0\n" + "srlx %L0, 32, %H0" + : "=r"(tick)); +#endif + return tick; +} + +/* + * A "short pause" - called from the Cilk runtime's spinloops. + */ +COMMON_SYSDEP void __cilkrts_short_pause(void) +{ + /* Spin around for 8 cycles. */ + __asm__ volatile("rd %ccr, %g0"); + __asm__ volatile("rd %ccr, %g0"); + __asm__ volatile("rd %ccr, %g0"); + __asm__ volatile("rd %ccr, %g0"); +} + +/* + * Interlocked exchange - used to implement the Cilk runtime's spinloops + */ +COMMON_SYSDEP int __cilkrts_xchg(volatile int *ptr, int x) +{ + x = __sync_lock_test_and_set(ptr, x); + return x; +} + + +/* + * Restore the floating point state that is stored in a stack frame at each + * spawn. This should be called each time a frame is resumed. + * + * Only valid for IA32 and Intel64 processors. + */ +void restore_x86_fp_state (__cilkrts_stack_frame *sf) +{ +} + + +/* + * Save the floating point state to the __cilkrts_stack_frame at each spawn. + * + * Architecture-specific - Should only be needed on IA32 and Intel64 + * processors. + */ +void sysdep_save_fp_ctrl_state(__cilkrts_stack_frame *sf) +{ +} + diff --git a/libcilkrts/runtime/except-gcc.cpp b/libcilkrts/runtime/except-gcc.cpp index 4940acb41f7..7fc6e6b79b0 100644 --- a/libcilkrts/runtime/except-gcc.cpp +++ b/libcilkrts/runtime/except-gcc.cpp @@ -60,7 +60,9 @@ #include <stdint.h> #include <typeinfo> +#ifndef DEBUG_EXCEPTIONS #define DEBUG_EXCEPTIONS 0 +#endif struct pending_exception_info { diff --git a/libcilkrts/runtime/global_state.cpp b/libcilkrts/runtime/global_state.cpp index 2af6697b27a..6c77b5f766a 100644 --- a/libcilkrts/runtime/global_state.cpp +++ b/libcilkrts/runtime/global_state.cpp @@ -579,7 +579,6 @@ global_state_t* cilkg_init_global_state() g->stack_size = cilkos_validate_stack_size(g->stack_size); g->failure_to_allocate_stack = 0; - return g; } diff --git a/libcilkrts/runtime/global_state.h b/libcilkrts/runtime/global_state.h index 527a4b54e45..f5937b89c7b 100644 --- a/libcilkrts/runtime/global_state.h +++ b/libcilkrts/runtime/global_state.h @@ -215,7 +215,6 @@ struct global_state_t { /* COMMON_PORTABLE */ /// Global fiber pool cilk_fiber_pool fiber_pool; - /** * @brief Track whether the runtime has failed to allocate a * stack. diff --git a/libcilkrts/runtime/jmpbuf.h b/libcilkrts/runtime/jmpbuf.h index 0ce7ff8dbb2..9ae2fd24bd3 100644 --- a/libcilkrts/runtime/jmpbuf.h +++ b/libcilkrts/runtime/jmpbuf.h @@ -107,6 +107,18 @@ */ #define SP(SF) JMPBUF_SP((SF)->ctx) +/** + * @brief Some architecture-dependent stack adjustment. + */ +#if defined(__sparcv9) + // Subtract sparc v9 stack bias so the actual stack starts at the + // allocated area. +# define CILK_ADJUST_SP(SP) ((SP) - 2047) +# define CILK_UNADJUST_SP(SP) ((SP) + 2047) +#else +# define CILK_ADJUST_SP(SP) (SP) +# define CILK_UNADJUST_SP(SP) (SP) +#endif __CILKRTS_BEGIN_EXTERN_C @@ -120,7 +132,7 @@ __CILKRTS_BEGIN_EXTERN_C */ inline char *__cilkrts_get_sp(__cilkrts_stack_frame *sf) { - return (char *)SP(sf); + return (char *)CILK_UNADJUST_SP(SP(sf)); } /** diff --git a/libcilkrts/runtime/linux-symbols.ver b/libcilkrts/runtime/linux-symbols.ver index d6568421a50..57b4e8a08a9 100644 --- a/libcilkrts/runtime/linux-symbols.ver +++ b/libcilkrts/runtime/linux-symbols.ver @@ -71,7 +71,6 @@ CILKABI0 __cilkrts_hyperobject_dealloc; __cilkrts_hyperobject_noop_destroy; __cilkrts_init; - __cilkrts_irml_version; __cilkrts_leave_frame; __cilkrts_metacall; __cilkrts_rethrow; diff --git a/libcilkrts/runtime/local_state.h b/libcilkrts/runtime/local_state.h index d16599f1add..9b286853d03 100644 --- a/libcilkrts/runtime/local_state.h +++ b/libcilkrts/runtime/local_state.h @@ -360,6 +360,13 @@ struct local_state /* COMMON_PORTABLE */ unsigned int steal_failure_count; /** + * Record indicating that the worker stole work at least once. + * + * [local read/write] + */ + int has_stolen; + + /** * 1 if work was stolen from another worker. When true, this will flag * setup_for_execution_pedigree to increment the pedigree when we resume * execution to match the increment that would have been done on a return diff --git a/libcilkrts/runtime/mac-symbols.txt b/libcilkrts/runtime/mac-symbols.txt index efec3e984fd..29bf4817a66 100644 --- a/libcilkrts/runtime/mac-symbols.txt +++ b/libcilkrts/runtime/mac-symbols.txt @@ -33,7 +33,6 @@ ___cilkrts_hyperobject_alloc ___cilkrts_hyperobject_dealloc ___cilkrts_hyperobject_noop_destroy ___cilkrts_init - ___cilkrts_leave_frame ___cilkrts_metacall ___cilkrts_resume diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c index d339daf7026..c419fb68abf 100644 --- a/libcilkrts/runtime/os-unix.c +++ b/libcilkrts/runtime/os-unix.c @@ -432,7 +432,9 @@ COMMON_SYSDEP void __cilkrts_idle(void) #elif defined(__MIC__) _mm_delay_32(1024); #elif defined(__linux__) || \ - defined(__APPLE__) + defined(__APPLE__) || \ + defined(__CYGWIN__) + usleep(10000); #else # error "Unsupported architecture" @@ -452,6 +454,7 @@ COMMON_SYSDEP void __cilkrts_yield(void) { #if defined(__ANDROID__) || \ defined(__APPLE__) || \ + defined(__CYGWIN__) || \ defined(__FreeBSD__) || \ defined(__VXWORKS__) || \ (defined(__sun__) && defined(__svr4__)) diff --git a/libcilkrts/runtime/record-replay.cpp b/libcilkrts/runtime/record-replay.cpp index 293c99ae65f..d92d28fc233 100644 --- a/libcilkrts/runtime/record-replay.cpp +++ b/libcilkrts/runtime/record-replay.cpp @@ -262,7 +262,7 @@ char * walk_pedigree_nodes(char *p, const __cilkrts_pedigree *pnode) if (pnode->parent) { p = walk_pedigree_nodes(p, pnode->parent); - p += cilk_snprintf_s(p, PEDIGREE_BUFF_SIZE, "%s", (char *) "_"); + p += cilk_snprintf_s(p, PEDIGREE_BUFF_SIZE, "%s", (char *)"_"); } return p + cilk_snprintf_l(p, PEDIGREE_BUFF_SIZE, "%" PRIu64, pnode->rank); } diff --git a/libcilkrts/runtime/scheduler.c b/libcilkrts/runtime/scheduler.c index 538c43104f3..82c9e02af08 100644 --- a/libcilkrts/runtime/scheduler.c +++ b/libcilkrts/runtime/scheduler.c @@ -1789,20 +1789,27 @@ static full_frame* check_for_work(__cilkrts_worker *w) if (NULL == ff) { // Punish the worker for failing to steal. // No quantum for you! - if (w->l->steal_failure_count > 30000) { - // Punish more if the worker has been doing unsuccessful steals - // for a long time. After return from the idle state, it will - // be given a grace period to react quickly. + unsigned int max_fails = w->g->max_steal_failures << 1; + if (w->l->has_stolen == 0 && + w->l->steal_failure_count % max_fails == max_fails - 1) { + // Idle briefly if the worker has never stolen anything for + // the given grace period __cilkrts_idle(); - w->l->steal_failure_count -= 300; } else { __cilkrts_yield(); } w->l->steal_failure_count++; + if (w->l->steal_failure_count > (max_fails << 8)) { + // Reset the flag after certain amount of failures + // - This will reduce cpu time in top-level synched regions + // - max_fails can be controlled by user (CILK_STEAL_FAILURES) + w->l->has_stolen = 0; + } } else { // Reset steal_failure_count since there is obviously still work to // be done. w->l->steal_failure_count = 0; + w->l->has_stolen = 1; } } return ff; @@ -2912,6 +2919,7 @@ __cilkrts_worker *make_worker(global_state_t *g, w->l->stats = NULL; #endif w->l->steal_failure_count = 0; + w->l->has_stolen = 0; w->l->work_stolen = 0; diff --git a/libcilkrts/runtime/scheduler.h b/libcilkrts/runtime/scheduler.h index 74c45096fca..9546001bdeb 100644 --- a/libcilkrts/runtime/scheduler.h +++ b/libcilkrts/runtime/scheduler.h @@ -85,7 +85,10 @@ __CILKRTS_BEGIN_EXTERN_C * Print debugging messages and assertions for parallel reducers. 0 is * no debugging. A higher value generates more output. */ + +#ifndef REDPAR_DEBUG #define REDPAR_DEBUG 0 +#endif /** * @brief Lock the worker mutex to allow exclusive access to the diff --git a/libcilkrts/runtime/sysdep-unix.c b/libcilkrts/runtime/sysdep-unix.c index 611934a9bbf..0b99008b82b 100644 --- a/libcilkrts/runtime/sysdep-unix.c +++ b/libcilkrts/runtime/sysdep-unix.c @@ -465,7 +465,7 @@ char* sysdep_reset_jump_buffers_for_resume(cilk_fiber* fiber, CILK_ASSERT(fiber); void* sp = (void*)get_sp_for_executing_sf(cilk_fiber_get_stack_base(fiber), ff, sf); - SP(sf) = sp; + SP(sf) = CILK_ADJUST_SP(sp); /* Debugging: make sure stack is accessible. */ ((volatile char *)sp)[-1]; @@ -495,7 +495,7 @@ NORETURN sysdep_longjmp_to_sf(char* new_sp, #endif // Set the stack pointer. - SP(sf) = new_sp; + SP(sf) = CILK_ADJUST_SP(new_sp); #ifdef RESTORE_X86_FP_STATE if (CILK_FRAME_VERSION_VALUE(sf->flags) >= 1) { @@ -568,7 +568,7 @@ static const char *get_runtime_path () { // dladdr is a glibc extension. If it's available, use it to find the path // for libcilkrts.so -#ifdef _GNU_SOURCE +#if HAVE_DLADDR Dl_info info; if (0 != dladdr(dummy_function, &info)) return info.dli_fname; @@ -689,7 +689,6 @@ static void write_version_file (global_state_t *g, int n) // ================== // System cores: 8 // Cilk workers requested: 8 - // Thread creator: Private fprintf(fp, "\nThread information\n"); fprintf(fp, "==================\n"); @@ -699,11 +698,6 @@ static void write_version_file (global_state_t *g, int n) fprintf(fp, "System cores: %d\n", (int)sysconf(_SC_NPROCESSORS_ONLN)); #endif fprintf(fp, "Cilk workers requested: %d\n", n); -#if (PARALLEL_THREAD_CREATE) - fprintf(fp, "Thread creator: Private (parallel)\n"); -#else - fprintf(fp, "Thread creator: Private\n"); -#endif if (fp != stderr && fp != stdout) fclose(fp); else fflush(fp); // flush the handle buffer if it is stdout or stderr. |