diff options
Diffstat (limited to 'libcilkrts/runtime/sysdep-unix.c')
-rw-r--r-- | libcilkrts/runtime/sysdep-unix.c | 147 |
1 files changed, 56 insertions, 91 deletions
diff --git a/libcilkrts/runtime/sysdep-unix.c b/libcilkrts/runtime/sysdep-unix.c index 1f82b6288a1..611934a9bbf 100644 --- a/libcilkrts/runtime/sysdep-unix.c +++ b/libcilkrts/runtime/sysdep-unix.c @@ -3,11 +3,9 @@ * ************************************************************************* * - * @copyright - * Copyright (C) 2010-2013, Intel Corporation + * Copyright (C) 2010-2016, Intel Corporation * All rights reserved. * - * @copyright * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,7 +20,6 @@ * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * @copyright * 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 @@ -35,17 +32,24 @@ * 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. * ************************************************************************** */ -#ifdef __linux__ - // define _GNU_SOURCE before *any* #include. - // Even <stdint.h> will break later #includes if this macro is not - // already defined when it is #included. -# define _GNU_SOURCE -#endif - #include "sysdep.h" #include "os.h" #include "bug.h" @@ -80,24 +84,7 @@ #include <string.h> #include <pthread.h> #include <unistd.h> - -#if defined HAVE_ALLOCA_H -# include <alloca.h> -#elif defined __GNUC__ -# define alloca __builtin_alloca -#elif defined _AIX -# define alloca __alloca -#else -# include <stddef.h> -# ifdef __cplusplus -extern "C" -# endif -void *alloca (size_t); -#endif - -#ifdef __APPLE__ -//# include <scheduler.h> // Angle brackets include Apple's scheduler.h, not ours. -#endif +#include "declare-alloca.h" #ifdef __linux__ # include <sys/resource.h> @@ -205,11 +192,17 @@ NON_COMMON void* scheduler_thread_proc_for_system_worker(void *arg) __cilkrts_set_tls_worker(w); + START_INTERVAL(w, INTERVAL_IN_SCHEDULER); + START_INTERVAL(w, INTERVAL_IN_RUNTIME); + START_INTERVAL(w, INTERVAL_INIT_WORKER); + // Create a cilk fiber for this worker on this thread. START_INTERVAL(w, INTERVAL_FIBER_ALLOCATE_FROM_THREAD) { w->l->scheduling_fiber = cilk_fiber_allocate_from_thread(); cilk_fiber_set_owner(w->l->scheduling_fiber, w); } STOP_INTERVAL(w, INTERVAL_FIBER_ALLOCATE_FROM_THREAD); + + STOP_INTERVAL(w, INTERVAL_INIT_WORKER); internal_run_scheduler_with_exceptions(w); @@ -225,35 +218,11 @@ NON_COMMON void* scheduler_thread_proc_for_system_worker(void *arg) w->l->scheduling_fiber = NULL; } STOP_INTERVAL(w, INTERVAL_FIBER_DEALLOCATE_FROM_THREAD); + STOP_INTERVAL(w, INTERVAL_IN_RUNTIME); + STOP_INTERVAL(w, INTERVAL_IN_SCHEDULER); return 0; } - -/* - * __cilkrts_user_worker_scheduling_stub - * - * Routine for the scheduling fiber created for an imported user - * worker thread. This method is analogous to - * scheduler_thread_proc_for_system_worker. - * - */ -void __cilkrts_user_worker_scheduling_stub(cilk_fiber* fiber, void* null_arg) -{ - __cilkrts_worker *w = __cilkrts_get_tls_worker(); - - // Sanity check. - CILK_ASSERT(WORKER_USER == w->l->type); - - // Enter the scheduling loop on the user worker. - // This function will never return. - __cilkrts_run_scheduler_with_exceptions(w); - - // A WORKER_USER, at some point, will resume on the original stack and leave - // Cilk. Under no circumstances do we ever exit off of the bottom of this - // stack. - CILK_ASSERT(0); -} - /** * We are exporting a function with this name to Inspector? * What a confusing name... @@ -266,8 +235,6 @@ void* __cilkrts_worker_stub(void* arg) return scheduler_thread_proc_for_system_worker(arg); } - - // /* Return the lesser of the argument and the operating system // limit on the number of workers (threads) that may or ought // to be created. */ @@ -571,64 +538,51 @@ void __cilkrts_make_unrunnable_sysdep(__cilkrts_worker *w, } } -/* - * __cilkrts_sysdep_is_worker_thread_id - * - * Returns true if the thread ID specified matches the thread ID we saved - * for a worker. - */ - -int __cilkrts_sysdep_is_worker_thread_id(global_state_t *g, - int i, - void *thread_id) -{ -#if defined( __linux__) || defined(__VXWORKS__) - pthread_t tid = *(pthread_t *)thread_id; - if (i < 0 || i > g->total_workers) - return 0; - return g->sysdep->threads[i] == tid; -#else - // Needs to be implemented - return 0; -#endif -} - - - - /************************************************************* Version information: *************************************************************/ +#ifndef _WRS_KERNEL #include <dlfcn.h> +#endif #include "internal/cilk_version.h" #include <stdio.h> +#ifndef _WRS_KERNEL #include <sys/utsname.h> +#endif #ifdef __VXWORKS__ #include <version.h> -# endif +#endif /* (Non-static) dummy function is used by get_runtime_path() to find the path * to the .so containing the Cilk runtime. */ void dummy_function() { } -/* return a string with the path to the Cilk runtime, or "unknown" if the path +/* + * Return a string with the path to the Cilk runtime, or "unknown" if the path * cannot be determined. */ static const char *get_runtime_path () { -#ifdef __CYGWIN__ - // Cygwin doesn't support dladdr, which sucks - return "unknown"; -#else + // dladdr is a glibc extension. If it's available, use it to find the path + // for libcilkrts.so +#ifdef _GNU_SOURCE Dl_info info; - if (0 == dladdr(dummy_function, &info)) return "unknown"; - return info.dli_fname; + if (0 != dladdr(dummy_function, &info)) + return info.dli_fname; #endif + + // If dladdr isn't available, or dladdr failed, we can't know the path for + // the shared object + return "unknown"; } +#ifdef _WRS_KERNEL +#include <version.h> +#include <sysLib.h> +#endif /* if the environment variable, CILK_VERSION, is defined, writes the version * information to the specified file. * g is the global state that was just created, and n is the number of workers @@ -640,7 +594,9 @@ static void write_version_file (global_state_t *g, int n) char buf[256]; // print buffer. time_t t; FILE *fp; +#ifndef _WRS_KERNEL struct utsname sys_info; +#endif int err; // error code from system calls. // if CILK_VERSION is not set, or if the file cannot be opened, fail @@ -711,15 +667,22 @@ static void write_version_file (global_state_t *g, int n) // System OS: Linux, release 2.6.28-19-generic // System architecture: x86_64 - err = uname(&sys_info); fprintf(fp, "\nSystem information\n"); fprintf(fp, "==================\n"); fprintf(fp, "Cilk runtime path: %s\n", get_runtime_path()); +#ifndef _WRS_KERNEL + err = uname(&sys_info); fprintf(fp, "System OS: %s, release %s\n", err < 0 ? "unknown" : sys_info.sysname, err < 0 ? "?" : sys_info.release); fprintf(fp, "System architecture: %s\n", err < 0 ? "unknown" : sys_info.machine); +#else + fprintf(fp, "System OS: %s, release %s\n", + "VxWorks", RUNTIME_NAME RUNTIME_VERSION); + fprintf(fp, "System architecture: %s\n", + sysModel()); +#endif // Print thread info. E.g., // Thread information @@ -792,10 +755,12 @@ void __cilkrts_establish_c_stack(void) static __attribute__((noinline)) void internal_enforce_global_visibility() { +#ifndef __VXWORKS__ void* handle = dlopen( get_runtime_path(), RTLD_GLOBAL|RTLD_LAZY ); /* For proper reference counting, close the handle immediately. */ if( handle) dlclose(handle); +#endif } /* |