summaryrefslogtreecommitdiff
path: root/libcilkrts/include
diff options
context:
space:
mode:
authoriverbin <iverbin@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-04 12:29:14 +0000
committeriverbin <iverbin@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-04 12:29:14 +0000
commit0657c20f751e42bb4e5e6d1f9db15df1e73fe653 (patch)
tree8bcfabda678320bf7a1530bb85d97e4f3bce384b /libcilkrts/include
parent466b8a137325aff1f5666ec6252f911ab0149e56 (diff)
downloadgcc-0657c20f751e42bb4e5e6d1f9db15df1e73fe653.tar.gz
Merge libcilkrts from upstream.
libcilkrts/ * Makefile.am: Merge from upstream, version 2.0.4420.0 <https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git>. * README: Likewise. * configure.ac: Likewise. * configure.tgt: Likewise. * include/cilk/cilk.h: Likewise. * include/cilk/cilk_api.h: Likewise. * include/cilk/cilk_api_linux.h: Likewise. * include/cilk/cilk_stub.h: Likewise. * include/cilk/cilk_undocumented.h: Likewise. * include/cilk/common.h: Likewise. * include/cilk/holder.h: Likewise. * include/cilk/hyperobject_base.h: Likewise. * include/cilk/metaprogramming.h: Likewise. * include/cilk/reducer.h: Likewise. * include/cilk/reducer_file.h: Likewise. * include/cilk/reducer_list.h: Likewise. * include/cilk/reducer_max.h: Likewise. * include/cilk/reducer_min.h: Likewise. * include/cilk/reducer_min_max.h: Likewise. * include/cilk/reducer_opadd.h: Likewise. * include/cilk/reducer_opand.h: Likewise. * include/cilk/reducer_opmul.h: Likewise. * include/cilk/reducer_opor.h: Likewise. * include/cilk/reducer_opxor.h: Likewise. * include/cilk/reducer_ostream.h: Likewise. * include/cilk/reducer_string.h: Likewise. * include/cilktools/cilkscreen.h: Likewise. * include/cilktools/cilkview.h: Likewise. * include/cilktools/fake_mutex.h: Likewise. * include/cilktools/lock_guard.h: Likewise. * include/internal/abi.h: Likewise. * include/internal/cilk_fake.h: Likewise. * include/internal/cilk_version.h: Likewise. * include/internal/metacall.h: Likewise. * include/internal/rev.mk: Likewise. * mk/cilk-version.mk: Likewise. * runtime/acknowledgements.dox: Likewise. * runtime/bug.cpp: Likewise. * runtime/bug.h: Likewise. * runtime/c_reducers.c: Likewise. * runtime/cilk-abi-cilk-for.cpp: Likewise. * runtime/cilk-abi-vla-internal.c: Likewise. * runtime/cilk-abi-vla-internal.h: Likewise. * runtime/cilk-abi.c: Likewise. * runtime/cilk-ittnotify.h: Likewise. * runtime/cilk-tbb-interop.h: Likewise. * runtime/cilk_api.c: Likewise. * runtime/cilk_fiber-unix.cpp: Likewise. * runtime/cilk_fiber-unix.h: Likewise. * runtime/cilk_fiber.cpp: Likewise. * runtime/cilk_fiber.h: Likewise. * runtime/cilk_malloc.c: Likewise. * runtime/cilk_malloc.h: Likewise. * runtime/component.h: Likewise. * runtime/config/generic/cilk-abi-vla.c: Likewise. * runtime/config/generic/os-fence.h: Likewise. * runtime/config/generic/os-unix-sysdep.c: Likewise. * runtime/config/x86/cilk-abi-vla.c: Likewise. * runtime/config/x86/os-fence.h: Likewise. * runtime/config/x86/os-unix-sysdep.c: Likewise. * runtime/doxygen-layout.xml: Likewise. * runtime/doxygen.cfg: Likewise. * runtime/except-gcc.cpp: Likewise. * runtime/except-gcc.h: Likewise. * runtime/except.h: Likewise. * runtime/frame_malloc.c: Likewise. * runtime/frame_malloc.h: Likewise. * runtime/full_frame.c: Likewise. * runtime/full_frame.h: Likewise. * runtime/global_state.cpp: Likewise. * runtime/global_state.h: Likewise. * runtime/jmpbuf.c: Likewise. * runtime/jmpbuf.h: Likewise. * runtime/linux-symbols.ver: Likewise. * runtime/local_state.c: Likewise. * runtime/local_state.h: Likewise. * runtime/mac-symbols.txt: Likewise. * runtime/metacall_impl.c: Likewise. * runtime/metacall_impl.h: Likewise. * runtime/os-unix.c: Likewise. * runtime/os.h: Likewise. * runtime/os_mutex-unix.c: Likewise. * runtime/os_mutex.h: Likewise. * runtime/pedigrees.c: Likewise. * runtime/pedigrees.h: Likewise. * runtime/record-replay.cpp: Likewise. * runtime/record-replay.h: Likewise. * runtime/reducer_impl.cpp: Likewise. * runtime/reducer_impl.h: Likewise. * runtime/rts-common.h: Likewise. * runtime/scheduler.c: Likewise. * runtime/scheduler.h: Likewise. * runtime/signal_node.c: Likewise. * runtime/signal_node.h: Likewise. * runtime/spin_mutex.c: Likewise. * runtime/spin_mutex.h: Likewise. * runtime/stats.c: Likewise. * runtime/stats.h: Likewise. * runtime/sysdep-unix.c: Likewise. * runtime/sysdep.h: Likewise. * runtime/worker_mutex.c: Likewise. * runtime/worker_mutex.h: Likewise. * include/cilk/reducer_vector.h: New. * runtime/cilk_str_mem.h: New. * runtime/config/arm/cilk-abi-vla.c: New. * runtime/config/arm/os-fence.h: New. * runtime/config/arm/os-unix-sysdep.c: New. * runtime/declare-alloca.h: New. * runtime/sslib/ignore_handler_s.c: New. * runtime/sslib/safe_lib.h: New. * runtime/sslib/safe_lib_errno.h: New. * runtime/sslib/safe_str_constraint.c: New. * runtime/sslib/safe_str_constraint.h: New. * runtime/sslib/safe_str_lib.h: New. * runtime/sslib/safe_types.h: New. * runtime/sslib/safeclib_private.h: New. * runtime/sslib/snprintf_s.h: New. * runtime/sslib/snprintf_support.c: New. * runtime/sslib/strcpy_s.c: New. * runtime/sslib/strncpy_s.c: New. * runtime/sslib/strnlen_s.c: New. * runtime/symbol_test.c: Remove. * Makefile.in: Regenerate. * configure: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235870 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcilkrts/include')
-rw-r--r--libcilkrts/include/cilk/cilk.h37
-rw-r--r--libcilkrts/include/cilk/cilk_api.h184
-rw-r--r--libcilkrts/include/cilk/cilk_api_linux.h19
-rw-r--r--libcilkrts/include/cilk/cilk_stub.h28
-rw-r--r--libcilkrts/include/cilk/cilk_undocumented.h21
-rw-r--r--libcilkrts/include/cilk/common.h52
-rw-r--r--libcilkrts/include/cilk/holder.h25
-rw-r--r--libcilkrts/include/cilk/hyperobject_base.h23
-rw-r--r--libcilkrts/include/cilk/metaprogramming.h107
-rw-r--r--libcilkrts/include/cilk/reducer.h1154
-rw-r--r--libcilkrts/include/cilk/reducer_file.h19
-rw-r--r--libcilkrts/include/cilk/reducer_list.h461
-rw-r--r--libcilkrts/include/cilk/reducer_max.h19
-rw-r--r--libcilkrts/include/cilk/reducer_min.h19
-rw-r--r--libcilkrts/include/cilk/reducer_min_max.h1559
-rw-r--r--libcilkrts/include/cilk/reducer_opadd.h227
-rw-r--r--libcilkrts/include/cilk/reducer_opand.h216
-rw-r--r--libcilkrts/include/cilk/reducer_opmul.h131
-rw-r--r--libcilkrts/include/cilk/reducer_opor.h213
-rw-r--r--libcilkrts/include/cilk/reducer_opxor.h212
-rw-r--r--libcilkrts/include/cilk/reducer_ostream.h650
-rw-r--r--libcilkrts/include/cilk/reducer_string.h198
-rw-r--r--libcilkrts/include/cilk/reducer_vector.h533
-rw-r--r--libcilkrts/include/cilktools/cilkscreen.h19
-rw-r--r--libcilkrts/include/cilktools/cilkview.h19
-rw-r--r--libcilkrts/include/cilktools/fake_mutex.h19
-rw-r--r--libcilkrts/include/cilktools/lock_guard.h19
-rw-r--r--libcilkrts/include/internal/abi.h33
-rw-r--r--libcilkrts/include/internal/cilk_fake.h19
-rw-r--r--libcilkrts/include/internal/cilk_version.h31
-rw-r--r--libcilkrts/include/internal/metacall.h19
-rw-r--r--libcilkrts/include/internal/rev.mk21
32 files changed, 3832 insertions, 2474 deletions
diff --git a/libcilkrts/include/cilk/cilk.h b/libcilkrts/include/cilk/cilk.h
index 2d0de0d293e..86038ac1adc 100644
--- a/libcilkrts/include/cilk/cilk.h
+++ b/libcilkrts/include/cilk/cilk.h
@@ -1,10 +1,8 @@
/* cilk.h -*-C++-*-
*
- * @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:
@@ -19,7 +17,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
@@ -32,40 +29,54 @@
* 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.
*/
/** @file cilk.h
*
- * @brief Provides convenient aliases for the Cilk language keywords.
+ * @brief Provides convenient aliases for Intel(R) Cilk(TM) language keywords.
*
* @details
- * Since Cilk is a nonstandard extension to both C and C++, the Cilk
- * language keywords all begin with “`_Cilk_`”, which guarantees that they
+ * Since Intel Cilk Plus is a nonstandard extension to both C and C++, the Intel
+ * Cilk language keywords all begin with "`_Cilk_`", which guarantees that they
* will not conflict with user-defined identifiers in properly written
- * programs, so that “standard” C and C++ programs can safely be
- * compiled a Cilk-enabled C or C++ compiler.
+ * programs. This way, a Cilk-enabled C or C++ compiler can safely compile
+ * "standard" C and C++ programs.
*
* However, this means that the keywords _look_ like something grafted on to
* the base language. Therefore, you can include this header:
*
* #include "cilk/cilk.h"
*
- * and then write the Cilk keywords with a “`cilk_`” prefix instead of
- * “`_Cilk_`”.
+ * and then write the Intel Cilk keywords with a "`cilk_`" prefix instead of
+ * "`_Cilk_`".
*
* @ingroup language
*/
/** @defgroup language Language Keywords
- * Definitions having to do with the Cilk language.
+ * Definitions for the Intel Cilk language.
* @{
*/
#ifndef cilk_spawn
# define cilk_spawn _Cilk_spawn ///< Spawn a task that can execute in parallel.
# define cilk_sync _Cilk_sync ///< Wait for spawned tasks to complete.
-# define cilk_for _Cilk_for ///< Execute iterations of a for loop in parallel.
+# define cilk_for _Cilk_for ///< Execute iterations of a `for` loop in parallel.
#endif
/// @}
diff --git a/libcilkrts/include/cilk/cilk_api.h b/libcilkrts/include/cilk/cilk_api.h
index a21687b7b32..6cc62c994b7 100644
--- a/libcilkrts/include/cilk/cilk_api.h
+++ b/libcilkrts/include/cilk/cilk_api.h
@@ -1,10 +1,8 @@
/* cilk_api.h
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,23 +29,37 @@
* 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.
*/
-
+
/** @file cilk_api.h
*
- * @brief Defines the documented API exposed by the Cilk Plus for use
- * by applications.
+ * @brief Defines the Intel(R) Cilk(TM) Plus API for use by applications.
*
* @ingroup api
*/
-
+
#ifndef INCLUDED_CILK_API_H
#define INCLUDED_CILK_API_H
+
/** @defgroup api Runtime API
- * API to allow user programs to interact with the Cilk runtime.
- * @{
- */
+* API to interact with the Intel Cilk Plus runtime.
+* @{
+*/
#ifndef CILK_STUB /* Real (non-stub) definitions */
@@ -81,7 +92,7 @@
__CILKRTS_BEGIN_EXTERN_C
-/** Return values from __cilkrts_set_param() and __cilkrts_set_param_w()
+/** Return values from `__cilkrts_set_param()` and `__cilkrts_set_param_w()`
*/
enum __cilkrts_set_param_status {
__CILKRTS_SET_PARAM_SUCCESS = 0, /**< Success - parameter set */
@@ -91,79 +102,79 @@ enum __cilkrts_set_param_status {
__CILKRTS_SET_PARAM_LATE = 4 /**< Too late to change parameter value */
};
-/** Set user controllable runtime parameters
+/** Sets user controllable runtime parameters
*
- * Call this function to set runtime parameters that control the behavior
- * of the Cilk scheduler.
+ * Call this function to set runtime parameters that control the behavior
+ * of the Intel Cilk Plus scheduler.
*
* @param param A string specifying the parameter to be set. One of:
* - `"nworkers"`
* - `"force reduce"`
* @param value A string specifying the parameter value.
- * @returns A value from the @ref __cilkrts_set_param_status
+ * @returns A value from the @ref __cilkrts_set_param_status
* enumeration indicating the result of the operation.
*
* @par The "nworkers" parameter
*
* This parameter specifies the number of worker threads to be created by the
- * Cilk runtime. @a Value must be a string of digits to be parsed by
- * `strtol()`.
+ * Intel Cilk Plus runtime. @a Value must be a string of digits to be parsed by
+ * `strtol()` as a decimal number.
*
* The number of worker threads is:
- * 1. the value set with `__cilkrts_set_param("nworkers")`, if it is
+ * 1. the value set with `__cilkrts_set_param("nworkers")`, if it is
* positive; otherwise,
- * 2. the value of the CILK_NWORKERS environment variable, if it is
+ * 2. the value of the CILK_NWORKERS environment variable, if it is
* defined; otherwise
* 3. the number of cores available, as reported by the operating system.
*
* @note
- * Technically, Cilk distinguishes between the _user thread_ (the thread that
- * the user code was executing on when the Cilk runtime started), and
- * _worker threads_ (new threads created by the Cilk runtime to support
- * Cilk parallelism). `nworkers` actually includes both the user thread and
- * the worker threads; that is, it is one greater than the number of true
- * “worker threads”.
+ * Technically, Intel Cilk Plus distinguishes between the _user thread_ (the thread
+ * that the user code was executing on when the Intel Cilk Plus runtime started),
+ * and _worker threads_ (new threads created by the Intel Cilk Plus runtime to
+ * support Intel Cilk Plus parallelism). `nworkers` actually includes both the user
+ * thread and the worker threads; that is, it is one greater than the number of
+ * true "worker threads".
*
* @note
- * Setting `nworkers = 1` produces serial behavior. Cilk spawns and syncs will
- * be executed, but with only one worker, continuations will never be stolen,
- * so all code will execute in serial.
+ * Setting `nworkers = 1` produces serial behavior. Intel Cilk Plus spawns and syncs
+ * will be executed, but with only one worker, continuations will never be
+ * stolen, so all code will execute in serial.
*
* @warning
- * The number of worker threads can only be set *before* the runtime has
- * started. Attempting to set it when the runtime is running will have no
- * effect, and will return an error code. You can call __cilkrts_end_cilk()
+ * The number of worker threads can only be set *before* the runtime has
+ * started. Attempting to set it when the runtime is running will have no
+ * effect, and will return an error code. You can call __cilkrts_end_cilk()
* to shut down the runtime to change the number of workers.
*
* @warning
- * The default Cilk scheduler behavior is usually pretty good. The ability
- * to override `nworkers` can be useful for experimentation, but it won’t
- * usually be necessary for getting good performance.
+ * The default Intel Cilk scheduler behavior is usually pretty good. The
+ * ability to override `nworkers` can be useful for experimentation, but it
+ * won't usually be necessary for getting good performance.
*
* @par The "force reduce" parameter
*
* This parameter controls whether the runtime should allocate a new view
- * for a reducer for every parallel strand that it is accessed on. (See
- * @ref pagereducers.) @a Value must be `"1"` or `"true"` to enable the
- * “force reduce” behavior, or `"0"` or `"false"` to disable it.
+ * for a reducer for every parallel strand that it is accessed on. (See
+ * @ref pagereducers.) @a Value must be `"1"` or `"true"` to enable the
+ * "force reduce" behavior, or `"0"` or `"false"` to disable it.
*
- * “Force reduce” behavior will also be enabled if
+ * "Force reduce" behavior will also be enabled if
* `__cilkrts_set_param("force reduce")` is not called, but the
* `CILK_FORCE_REDUCE` environment variable is defined.
*
* @warning
- * When this option is enabled, `nworkers` should be set to `1`. Using “force
- * reduce” with more than one worker may result in runtime errors.
- *
+ * When this option is enabled, `nworkers` should be set to `1`. Using "force
+ * reduce" with more than one worker may result in runtime errors.
+ *
* @warning
- * Enabling this option can significantly reduce performance. It should
- * _only_ be used as a debugging tool.
+ * Enabling this option can significantly reduce performance. Use it
+ * _only_ as a debugging tool.
*/
CILK_API(int) __cilkrts_set_param(const char *param, const char *value);
#ifdef _WIN32
/**
- * Set user controllable parameters using wide strings
+ * Sets user controllable parameters using wide strings
*
* @note This variant of __cilkrts_set_param() is only available
* on Windows.
@@ -173,36 +184,36 @@ CILK_API(int) __cilkrts_set_param(const char *param, const char *value);
CILK_API(int) __cilkrts_set_param_w(const wchar_t *param, const wchar_t *value);
#endif
-/** Shut down and deallocate all Cilk state. The runtime will abort the
- * application if Cilk is still in use by this thread. Otherwise the runtime
- * will wait for all other threads using Cilk to exit.
+/** Shuts down and deallocates all Intel Cilk Plus states. If Intel Cilk Plus is still in
+ * use by the calling thread, the runtime aborts the application. Otherwise, the
+ * runtime waits for all other threads using Intel Cilk Plus to exit.
*/
CILK_API(void) __cilkrts_end_cilk(void);
-/** Initialize the Cilk data structures and start the runtime.
+/** Initializes Intel Cilk Plus data structures and start the runtime.
*/
CILK_API(void) __cilkrts_init(void);
-/** Return the runtime `nworkers` parameter. (See the discussion of `nworkers`
+/** Returns the runtime `nworkers` parameter. (See the discussion of `nworkers`
* in the documentation for __cilkrts_set_param().)
*/
CILK_API(int) __cilkrts_get_nworkers(void);
-/** Return the number of thread data structures.
+/** Returns the number of thread data structures.
*
- * This function returns the number of data structures that has been allocated
- * allocated by the runtime to hold information about user and worker threads.
+ * This function returns the number of data structures that have been allocated
+ * by the runtime to hold information about user and worker threads.
*
- * If you don’t already know what this is good for, then you probably don’t
- * need it.
+ * If you don't already know what this is good for, then you probably don't
+ * need it. :)
*/
CILK_API(int) __cilkrts_get_total_workers(void);
-/** What thread is the function running on?
+/** Returns a small integer identifying the current thread.
*
- * Return a small integer identifying the current thread. Each worker thread
- * started by the Cilk runtime library has a unique worker number in the range
- * `1 .. nworkers - 1`.
+ * What thread is the function running on? Each worker thread
+ * started by the Intel Cilk Plus runtime library has a unique worker number in the
+ * range `1 .. nworkers - 1`.
*
* All _user_ threads (threads started by the user, or by other libraries) are
* identified as worker number 0. Therefore, the worker number is not unique
@@ -210,13 +221,13 @@ CILK_API(int) __cilkrts_get_total_workers(void);
*/
CILK_API(int) __cilkrts_get_worker_number(void);
-/** Test whether “force reduce” behavior is enabled.
- *
+/** Tests whether "force reduce" behavior is enabled.
+ *
* @return Non-zero if force-reduce mode is on, zero if it is off.
*/
CILK_API(int) __cilkrts_get_force_reduce(void);
-/** Interact with tools
+/** Interacts with tools
*/
CILK_API(void)
__cilkrts_metacall(unsigned int tool, unsigned int code, void *data);
@@ -229,12 +240,13 @@ typedef struct _EXCEPTION_RECORD _EXCEPTION_RECORD;
*/
typedef void (*__cilkrts_pfn_seh_callback)(const _EXCEPTION_RECORD *exception);
-/** Specify a function to call when a non-C++ exception is caught.
+/** Specifies a function to call when a non-C++ exception is caught.
*
- * Cilk Plus parallelism plays nicely with C++ exception handling, but the
- * Cilk Plus runtime has no way to unwind the stack across a strand boundary
- * for Microsoft SEH (“Structured Exception Handling”) exceptions. Therefore,
- * when the runtime catches such an exception, it must abort the application.
+ * Intel Cilk Plus parallelism plays nicely with C++ exception handling, but
+ * the Intel Cilk Plus runtime has no way to unwind the stack across a strand
+ * boundary for Microsoft SEH ("Structured Exception Handling") exceptions.
+ * Therefore, when the runtime catches such an exception, it must abort the
+ * application.
*
* If an SEH callback has been set, the runtime will call it before aborting.
*
@@ -267,33 +279,33 @@ __cilkrts_bump_worker_rank_internal(__cilkrts_worker* w);
/// @endcond
-/** Get the current pedigree, in a linked list representation.
+/** Gets the current pedigree in a linked list representation.
*
* This routine returns a copy of the last node in the pedigree list.
* For example, if the current pedigree (in order) is <1, 2, 3, 4>,
* then this method returns a node with rank == 4, and whose parent
* field points to the node with rank of 3. In summary, following the
* nodes in the chain visits the terms of the pedigree in reverse.
- *
+ *
* The returned node is guaranteed to be valid only until the caller
* of this routine has returned.
*/
__CILKRTS_INLINE
-__cilkrts_pedigree __cilkrts_get_pedigree(void)
+__cilkrts_pedigree __cilkrts_get_pedigree(void)
{
- return __cilkrts_get_pedigree_internal(__cilkrts_get_tls_worker());
+ return __cilkrts_get_pedigree_internal(__cilkrts_get_tls_worker());
}
/** Context used by __cilkrts_get_pedigree_info.
*
* @deprecated
- * This data structure is only used by the deprecated
+ * This data structure is only used by the deprecated
* __cilkrts_get_pedigree_info function.
*
* Callers should initialize the `data` array to NULL and set the `size`
* field to `sizeof(__cilkrts_pedigree_context_t)` before the first call
- * to __cilkrts_get_pedigree_info(), and should not examine or modify it
- * thereafter.
+ * to `__cilkrts_get_pedigree_info()`. Also, callers should not examine or
+ * modify `data` thereafter.
*/
typedef struct
{
@@ -301,16 +313,16 @@ typedef struct
void *data[3]; /**< Opaque context data */
} __cilkrts_pedigree_context_t;
-/** Get pedigree information.
+/** Gets pedigree information.
*
* @deprecated
* Use __cilkrts_get_pedigree() instead.
*
- * This routine allows code to walk up the stack of Cilk frames to gather
+ * This routine allows code to walk up the stack of Intel Cilk Plus frames to gather
* the pedigree.
*
* Initialize the pedigree walk by filling the pedigree context with NULLs
- * and setting the size field to sizeof(__cilkrts_pedigree_context).
+ * and setting the size field to `sizeof(__cilkrts_pedigree_context)`.
* Other than initialization to NULL to start the walk, user coder should
* consider the pedigree context data opaque and should not examine or
* modify it.
@@ -326,7 +338,7 @@ CILK_API(int)
__cilkrts_get_pedigree_info(/* In/Out */ __cilkrts_pedigree_context_t *context,
/* Out */ uint64_t *sf_birthrank);
-/** Get the rank of the currently executing worker.
+/** Gets the rank of the currently executing worker.
*
* @deprecated
* Use `__cilkrts_get_pedigree().rank` instead.
@@ -335,16 +347,16 @@ __cilkrts_get_pedigree_info(/* In/Out */ __cilkrts_pedigree_context_t *context,
* @returns <0 - Failure - *rank is not changed
*/
CILK_EXPORT_AND_INLINE
-int __cilkrts_get_worker_rank(uint64_t *rank)
+int __cilkrts_get_worker_rank(uint64_t *rank)
{
*rank = __cilkrts_get_pedigree().rank;
return 0;
}
-/** Increment the pedigree rank of the currently executing worker.
+/** Increments the pedigree rank of the currently executing worker.
*
* @returns 0 - Success - rank was incremented
- * @returns-1 - Failure
+ * @returns -1 - Failure
*/
CILK_EXPORT_AND_INLINE
int __cilkrts_bump_worker_rank(void)
@@ -352,7 +364,7 @@ int __cilkrts_bump_worker_rank(void)
return __cilkrts_bump_worker_rank_internal(__cilkrts_get_tls_worker());
}
-/** Increment the pedigree rank for a cilk_for loop.
+/** Increments the pedigree rank for a `cilk_for` loop.
* Obsolete.
*
* @deprecated
@@ -362,7 +374,7 @@ int __cilkrts_bump_worker_rank(void)
* be called, but will have no effect.
*/
CILK_EXPORT_AND_INLINE
-int __cilkrts_bump_loop_rank(void)
+int __cilkrts_bump_loop_rank(void)
{
return 0;
}
@@ -375,7 +387,7 @@ __CILKRTS_END_EXTERN_C
#else /* CILK_STUB */
-// Programs compiled with CILK_STUB are not linked with the Cilk runtime
+// Programs compiled with CILK_STUB are not linked with the Intel Cilk Plus runtime
// library, so they should not have external references to runtime functions.
// Therefore, the functions are replaced with stubs.
@@ -401,8 +413,8 @@ __CILKRTS_END_EXTERN_C
/*
* A stub method for __cilkrts_get_pedigree.
- * Returns an empty __cilkrts_pedigree.
- */
+ * Returns an empty __cilkrts_pedigree.
+ */
__CILKRTS_INLINE
__cilkrts_pedigree __cilkrts_get_pedigree_stub(void)
{
diff --git a/libcilkrts/include/cilk/cilk_api_linux.h b/libcilkrts/include/cilk/cilk_api_linux.h
index ed9e70635f6..0ebd57cba21 100644
--- a/libcilkrts/include/cilk/cilk_api_linux.h
+++ b/libcilkrts/include/cilk/cilk_api_linux.h
@@ -1,9 +1,7 @@
/*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -18,7 +16,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
@@ -31,6 +28,20 @@
* 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.
*
*/
diff --git a/libcilkrts/include/cilk/cilk_stub.h b/libcilkrts/include/cilk/cilk_stub.h
index 116e3ff5541..b4a54f37c9b 100644
--- a/libcilkrts/include/cilk/cilk_stub.h
+++ b/libcilkrts/include/cilk/cilk_stub.h
@@ -1,10 +1,8 @@
/* cilk_stub.h -*-C++-*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,13 +29,27 @@
* 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.
*
*/
#ifndef INCLUDED_CILK_STUB_DOT_H
#define INCLUDED_CILK_STUB_DOT_H
-/* Definitions for creating a serialization from a Cilk program.
+/* Definitions for creating a serialization from an Intel(R) Cilk(TM) Plus program.
* These definitions are suitable for use by a compiler that is not
* Cilk-enabled.
*/
@@ -47,9 +58,14 @@
#undef __cilk
#define CILK_STUB
-/* Replace Cilk keywords with serial equivalents */
+/* Replace Intel Cilk keywords with serial equivalents */
#define _Cilk_spawn
#define _Cilk_sync
#define _Cilk_for for
+/* Replace simd-loop keywords with serial equivalents */
+#define _Simd
+#define _Safelen(...)
+#define _Reduction(...)
+
#endif /* ! defined(INCLUDED_CILK_STUB_DOT_H) */
diff --git a/libcilkrts/include/cilk/cilk_undocumented.h b/libcilkrts/include/cilk/cilk_undocumented.h
index 81cdd64bb89..5f4a8c5dff1 100644
--- a/libcilkrts/include/cilk/cilk_undocumented.h
+++ b/libcilkrts/include/cilk/cilk_undocumented.h
@@ -1,9 +1,7 @@
/*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -18,7 +16,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
@@ -31,6 +28,20 @@
* 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.
*
******************************************************************************
*
@@ -83,7 +94,7 @@ CILK_EXPORT __CILKRTS_NOTHROW
void *__cilkrts_get_sf(void);
/**
- * Returns the size of stacks created by Cilk.
+ * Returns the size of stacks created by Intel(R) Cilk(TM) Plus.
*/
CILK_EXPORT __CILKRTS_NOTHROW
size_t __cilkrts_get_stack_size(void);
diff --git a/libcilkrts/include/cilk/common.h b/libcilkrts/include/cilk/common.h
index 97dd66e0639..91b2928e7e6 100644
--- a/libcilkrts/include/cilk/common.h
+++ b/libcilkrts/include/cilk/common.h
@@ -1,10 +1,8 @@
/** common.h
*
- * @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:
@@ -19,7 +17,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
@@ -32,18 +29,31 @@
* 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.
*/
/** @file common.h
*
- * @brief Defines common macros and structures used by the Intel Cilk Plus
- * runtime.
+ * @brief Defines common macros and structures used by the Intel(R) Cilk(TM) Plus runtime.
*
* @ingroup common
*/
/** @defgroup common Common Definitions
- * Macro, structure, and class definitions used elsewhere in the runtime.
+ * Definitions for runtime macros, structures, and classes.
* @{
*/
@@ -51,18 +61,17 @@
#define INCLUDED_CILK_COMMON
#ifdef __cplusplus
-/** Namespace for all Cilk definitions that can be included in user code.
+/** Namespace for all Intel Cilk Plus definitions that can be included in user code.
*/
namespace cilk {
- /** Namespace for definitions that are primarily intended for use
- * in other Cilk definitions.
+ /** Namespace for definitions re-used in other Intel Cilk Plus definitions.
*/
namespace internal {}
}
#endif
-/** Cilk library version = 1.01
+/** Intel Cilk Plus library version = 1.02
*/
#define CILK_LIBRARY_VERSION 102
@@ -73,7 +82,7 @@ namespace cilk {
#endif
/**
- * Prefix standard library function and type names with __STDNS in order to
+ * Prefix standard library function and type names with __STDNS to
* get correct lookup in both C and C++.
*/
#ifdef __cplusplus
@@ -159,7 +168,7 @@ namespace cilk {
/**
* Macro to specify alignment of a data member in a structure.
- * Because of the way that gcc’s alignment attribute is defined, @a n must
+ * Because of the way that gcc's alignment attribute is defined, @a n must
* be a numeric literal, not just a compile-time constant expression.
*/
#ifdef _WIN32
@@ -231,7 +240,7 @@ namespace cilk {
/**
* OS-independent macro to specify a function that should be inlined
*/
-#ifdef __cpluspus
+#ifdef __cplusplus
// C++
# define __CILKRTS_INLINE inline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
@@ -247,7 +256,7 @@ namespace cilk {
/**
* Functions marked as CILK_EXPORT_AND_INLINE have both
- * inline versions defined in the Cilk API, as well as
+ * inline versions defined in the Intel Cilk Plus API, as well as
* non-inlined versions that are exported (for
* compatibility with previous versions that did not
* inline the functions).
@@ -306,13 +315,14 @@ namespace cilk {
#endif /* ! defined(_MSC_VER) || (_MSC_VER >= 1600) */
/**
- * @brief Application Binary Interface version of the Cilk runtime library.
+ * @brief Application Binary Interface (ABI) version of the Intel Cilk Plus runtime
+ * library.
*
- * The ABI version is determined by the compiler used. An object file
- * compiled with a higher ABI version is not compatible with a library that is
- * compiled with a lower ABI version. An object file compiled with a lower
- * ABI version, however, can be used with a library compiled with a higher ABI
- * version unless otherwise stated.
+ * The compiler determines the ABI version used for compilation. Object files
+ * compiled with higher ABI versions are not compatible with libraries compiled
+ * with lower ABI versions. However, an object file compiled with a lower ABI
+ * version can be used with a library compiled with a higher ABI version
+ * (unless otherwise stated.)
*/
#ifndef __CILKRTS_ABI_VERSION
# ifdef IN_CILK_RUNTIME
diff --git a/libcilkrts/include/cilk/holder.h b/libcilkrts/include/cilk/holder.h
index 8620c052f53..66899a25bc9 100644
--- a/libcilkrts/include/cilk/holder.h
+++ b/libcilkrts/include/cilk/holder.h
@@ -1,9 +1,7 @@
/*
- * @copyright
- * Copyright (C) 2011-2013, Intel Corporation
+ * Copyright (C) 2011-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:
@@ -18,7 +16,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
@@ -31,6 +28,20 @@
* 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.
*
*/
@@ -60,8 +71,8 @@
* common variable where it is not necessary to preserve changes from
* different parallel strands. In effect, a holder acts a bit like
* thread-local storage, but has qualities that work better with the
- * fork-join structure of Cilk. In particular, a holder has the following
- * qualities:
+ * fork-join structure of Intel(R) Cilk(TM) Plus. In particular, a holder has the
+ * following qualities:
*
* - The view of a holder before the first spawn within a function is the same
* as the view after each sync (as in the case of a reducer).
@@ -220,7 +231,7 @@
* same as the view on entry to 'h'. More importantly, the view of the holder
* within the recursive call to 'compute' is the same as the view on entry to
* 'h', even if a different worker is executing the recursive call. Thus, the
- * holder view within a Cilk program has useful qualities not found in
+ * holder view within a Intel Cilk Plus program has useful qualities not found in
* thread-local storage.
*/
diff --git a/libcilkrts/include/cilk/hyperobject_base.h b/libcilkrts/include/cilk/hyperobject_base.h
index 484bf5f01ea..dd7ccfd9020 100644
--- a/libcilkrts/include/cilk/hyperobject_base.h
+++ b/libcilkrts/include/cilk/hyperobject_base.h
@@ -1,9 +1,7 @@
/*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -18,7 +16,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
@@ -31,6 +28,20 @@
* 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.
*
*/
@@ -49,7 +60,7 @@
#if defined _WIN32 || defined _WIN64
# if !defined CILK_STUB && !defined IN_CILK_RUNTIME
- /* bring in the Cilk library, which has definitions for some of these
+ /* bring in the Intel(R) Cilk(TM) Plus library, which has definitions for some of these
* functions. */
# pragma comment(lib, "cilkrts")
# endif
@@ -126,7 +137,7 @@ CILK_EXPORT
#else // CILK_STUB
-// Programs compiled with CILK_STUB are not linked with the Cilk runtime
+// Programs compiled with CILK_STUB are not linked with the Intel Cilk Plus runtime
// library, so they should not have external references to cilkrts functions.
// Furthermore, they don't need the hyperobject functionality, so the
// functions can be stubbed.
diff --git a/libcilkrts/include/cilk/metaprogramming.h b/libcilkrts/include/cilk/metaprogramming.h
index 29b0839e788..2df7cf6467c 100644
--- a/libcilkrts/include/cilk/metaprogramming.h
+++ b/libcilkrts/include/cilk/metaprogramming.h
@@ -1,10 +1,8 @@
/* metaprogramming.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2012-2013, Intel Corporation
+ * Copyright (C) 2012-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:
@@ -19,7 +17,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
@@ -32,11 +29,25 @@
* 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.
*/
/** @file metaprogramming.h
*
- * @brief Defines metaprogramming utility classes used in the Cilk library.
+ * @brief Defines metaprogramming utility classes used in the Intel(R) Cilk(TM) Plus library.
*
* @ingroup common
*/
@@ -61,7 +72,7 @@ namespace internal {
/** Test if a class is empty.
*
* If @a Class is an empty (and therefore necessarily stateless) class, then
- * the “empty base-class optimization” guarantees that
+ * the "empty base-class optimization" guarantees that
* `sizeof(check_for_empty_class<Class>) == sizeof(char)`. Conversely, if
* `sizeof(check_for_empty_class<Class>) > sizeof(char)`, then @a Class is not
* empty, and we must discriminate distinct instances of @a Class.
@@ -84,7 +95,7 @@ namespace internal {
* @ingroup common
*/
template <class Class>
-class class_is_empty {
+class class_is_empty {
class check_for_empty_class : public Class
{
char m_data;
@@ -147,11 +158,11 @@ public:
* @tparam Size The required minimum size of the resulting class.
* @tparam Alignment The required alignment of the resulting class.
*
- * @pre @a Alignment shall be a power of 2 no greater then 64.
+ * @pre @a Alignment shall be a power of 2 no greater than 64.
*
* @note This is implemented using the `CILK_ALIGNAS` macro, which uses
* the non-standard, implementation-specific features
- * `__declspec(align(N))` on Windows, and
+ * `__declspec(align(N))` on Windows, and
* `__attribute__((__aligned__(N)))` on Unix. The `gcc` implementation
* of `__attribute__((__aligned__(N)))` requires a numeric literal `N`
* (_not_ an arbitrary compile-time constant expression). Therefore,
@@ -165,21 +176,22 @@ public:
template <std::size_t Size, std::size_t Alignment>
struct aligned_storage;
-template<std::size_t Size> class aligned_storage<Size, 1>
+/// @cond
+template<std::size_t Size> class aligned_storage<Size, 1>
{ CILK_ALIGNAS( 1) char m_bytes[Size]; };
-template<std::size_t Size> class aligned_storage<Size, 2>
+template<std::size_t Size> class aligned_storage<Size, 2>
{ CILK_ALIGNAS( 2) char m_bytes[Size]; };
-template<std::size_t Size> class aligned_storage<Size, 4>
+template<std::size_t Size> class aligned_storage<Size, 4>
{ CILK_ALIGNAS( 4) char m_bytes[Size]; };
-template<std::size_t Size> class aligned_storage<Size, 8>
+template<std::size_t Size> class aligned_storage<Size, 8>
{ CILK_ALIGNAS( 8) char m_bytes[Size]; };
-template<std::size_t Size> class aligned_storage<Size, 16>
+template<std::size_t Size> class aligned_storage<Size, 16>
{ CILK_ALIGNAS(16) char m_bytes[Size]; };
-template<std::size_t Size> class aligned_storage<Size, 32>
+template<std::size_t Size> class aligned_storage<Size, 32>
{ CILK_ALIGNAS(32) char m_bytes[Size]; };
-template<std::size_t Size> class aligned_storage<Size, 64>
+template<std::size_t Size> class aligned_storage<Size, 64>
{ CILK_ALIGNAS(64) char m_bytes[Size]; };
-
+/// @endcond
/** A buffer of uninitialized bytes with the same size and alignment as a
* specified type.
@@ -188,14 +200,14 @@ template<std::size_t Size> class aligned_storage<Size, 64>
* properties as `Type`, but it will contain only raw (uninitialized) bytes.
* This allows the definition of a data member which can contain a `Type`
* object which is initialized explicitly under program control, rather
- * than implicitly as part of the initialization of the containing class.
+ * than implicitly as part of the initialization of the containing class.
* For example:
*
* class C {
* storage_for_object<MemberClass> _member;
* public:
* C() ... // Does NOT initialize _member
- * void initialize(args)
+ * void initialize(args)
* { new (_member.pointer()) MemberClass(args); }
* const MemberClass& member() const { return _member.object(); }
* MemberClass& member() { return _member.object(); }
@@ -204,21 +216,22 @@ template<std::size_t Size> class aligned_storage<Size, 64>
* by this class.
*/
template <typename Type>
-class storage_for_object :
+class storage_for_object :
aligned_storage< sizeof(Type), align_of<Type>::value >
{
public:
/// Return a typed reference to the buffer.
const Type& object() const { return *reinterpret_cast<Type*>(this); }
+ /// Return a typed reference to the buffer.
Type& object() { return *reinterpret_cast<Type*>(this); }
};
/** Get the functor class corresponding to a binary function type.
*
- * The `binary_functor` template class class can be instantiated with a binary
+ * The `binary_functor` template class can be instantiated with a binary
* functor class or with a real binary function, and will yield an equivalent
- * binary functor class class in either case.
+ * binary functor class in either case.
*
* @tparam F A binary functor class, a binary function type, or a pointer to
* binary function type.
@@ -260,7 +273,7 @@ struct binary_functor<R(*)(A,B)> {
* `typed_indirect_binary_function<F>` is an `Adaptable Binary Function` class
* based on an existing binary functor class or binary function type @a F. If
* @a F is a stateless class, then this class will be empty, and its
- * `operator()` will invoke @a F’s `operator()`. Otherwise, an object of this
+ * `operator()` will invoke @a F's `operator()`. Otherwise, an object of this
* class will hold a pointer to an object of type @a F, and will refer its
* `operator()` calls to the pointed-to @a F object.
*
@@ -276,14 +289,15 @@ struct binary_functor<R(*)(A,B)> {
*
* @note Just to repeat: if `F` is an empty class, then
* `typed_indirect_binary_function\<F\>' is also an empty class.
- * This is critical for its use in the @ref min_max::view_base
+ * This is critical for its use in the
+ * @ref cilk::cilk_lib_1_1::min_max_internal::view_base
* "min/max reducer view classes", where it allows the view to
* call a comparison functor in the monoid without actually
- * having to allocate a pointer in the view class when the
+ * having to allocate a pointer in the view class when the
* comparison class is empty.
*
* @note If you have an `Adaptable Binary Function` class or a binary
- * function type, then you can use the
+ * function type, then you can use the
* @ref indirect_binary_function class, which derives the
* argument and result types parameter type instead of requiring
* you to specify them as template arguments.
@@ -312,7 +326,7 @@ class typed_indirect_binary_function : std::binary_function<A1, A2, R>
public:
/// Constructor captures a pointer to the wrapped function.
typed_indirect_binary_function(const F* f) : f(f) {}
-
+
/// Return the comparator pointer, or `NULL` if the comparator is stateless.
const F* pointer() const { return f; }
@@ -323,10 +337,10 @@ public:
/// @copydoc typed_indirect_binary_function
/// Specialization for an empty functor class. (This is only possible if @a F
-/// itself is an empty class. If @a F is a function or pointer-to-function
+/// itself is an empty class. If @a F is a function or pointer-to-function
/// type, then the functor will contain a pointer.)
template <typename F, typename A1, typename A2, typename R, typename Functor>
-class typed_indirect_binary_function<F, A1, A2, R, Functor, true> :
+class typed_indirect_binary_function<F, A1, A2, R, Functor, true> :
std::binary_function<A1, A2, R>
{
public:
@@ -335,7 +349,7 @@ public:
/// Constructor discards the pointer to a stateless functor class.
typed_indirect_binary_function(const F* f) {}
-
+
/// Create an instance of the stateless functor class and apply it to the arguments.
R operator()(const A1& a1, const A2& a2) const { return F()(a1, a2); }
};
@@ -343,28 +357,29 @@ public:
/** Indirect binary function class with inferred types.
*
- * This is identical to @ref typed_indirect_binary_function, except that it
- * derives the binary function argument and result types from the parameter
- * type @a F instead of taking them as additional template parameters. If @a F
- * is a class type, then it must be an `Adaptable Binary Function`.
+ * This is identical to @ref cilk::internal::typed_indirect_binary_function,
+ * except that it derives the binary function argument and result types from
+ * the parameter type @a F instead of taking them as additional template
+ * parameters. If @a F is a class type, then it must be an `Adaptable Binary
+ * Function`.
*
* @see typed_indirect_binary_function
*
* @ingroup common
*/
template <typename F, typename Functor = typename binary_functor<F>::type>
-class indirect_binary_function :
+class indirect_binary_function :
typed_indirect_binary_function< F
, typename Functor::first_argument_type
, typename Functor::second_argument_type
, typename Functor::result_type
- >
+ >
{
typedef typed_indirect_binary_function< F
, typename Functor::first_argument_type
, typename Functor::second_argument_type
, typename Functor::result_type
- >
+ >
base;
public:
indirect_binary_function(const F* f) : base(f) {} ///< Constructor
@@ -373,7 +388,7 @@ public:
/** Choose a type based on a boolean constant.
*
- * This metafunction is identical to C++11’s condition metafunction.
+ * This metafunction is identical to C++11's condition metafunction.
* It needs to be here until we can reasonably assume that users will be
* compiling with C++11.
*
@@ -407,12 +422,12 @@ struct condition<false, IfTrue, IfFalse>
* Causes a compilation error if a compile-time constant expression is false.
*
* @par Usage example.
- * This assertion is used in reducer_min_max.h to avoid defining
+ * This assertion is used in reducer_min_max.h to avoid defining
* legacy reducer classes that would not be binary-compatible with the
* same classes compiled with earlier versions of the reducer library.
*
* __CILKRTS_STATIC_ASSERT(
- * internal::class_is_empty< internal::binary_functor<Compare> >::value,
+ * internal::class_is_empty< internal::binary_functor<Compare> >::value,
* "cilk::reducer_max<Value, Compare> only works with an empty Compare class");
*
* @note In a C++11 compiler, this is just the language predefined
@@ -468,13 +483,13 @@ inline void* allocate_aligned(std::size_t size, std::size_t alignment)
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#else
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__VXWORKS__)
return memalign(std::max(alignment, sizeof(void*)), size);
#else
void* ptr;
return (posix_memalign(&ptr, std::max(alignment, sizeof(void*)), size) == 0) ? ptr : 0;
#endif
-#endif
+#endif
}
/** Implementation-specific aligned memory deallocation function.
@@ -487,13 +502,13 @@ inline void deallocate_aligned(void* ptr)
_aligned_free(ptr);
#else
std::free(ptr);
-#endif
+#endif
}
/** Class to allocate and guard an aligned pointer.
*
* A new_aligned_pointer object allocates aligned heap-allocated memory when
- * it is created, and automatically deallocates it when it is destroyed
+ * it is created, and automatically deallocates it when it is destroyed
* unless its `ok()` function is called.
*
* @tparam T The type of the object to allocate on the heap. The allocated
@@ -504,14 +519,14 @@ class new_aligned_pointer {
void* m_ptr;
public:
/// Constructor allocates the pointer.
- new_aligned_pointer() :
+ new_aligned_pointer() :
m_ptr(allocate_aligned(sizeof(T), internal::align_of<T>::value)) {}
/// Destructor deallocates the pointer.
~new_aligned_pointer() { if (m_ptr) deallocate_aligned(m_ptr); }
/// Get the pointer.
operator void*() { return m_ptr; }
/// Return the pointer and release the guard.
- T* ok() {
+ T* ok() {
T* ptr = static_cast<T*>(m_ptr);
m_ptr = 0;
return ptr;
diff --git a/libcilkrts/include/cilk/reducer.h b/libcilkrts/include/cilk/reducer.h
index a22651e1e6f..09c2e196903 100644
--- a/libcilkrts/include/cilk/reducer.h
+++ b/libcilkrts/include/cilk/reducer.h
@@ -1,10 +1,8 @@
/* reducer.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,11 +29,25 @@
* 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.
*/
-
+
/** @file reducer.h
*
- * @brief Defines foundation classes for creating Cilk reducers.
+ * @brief Defines foundation classes for creating Intel(R) Cilk(TM) Plus reducers.
*
* @ingroup Reducers
*
@@ -44,7 +55,7 @@
*
* @defgroup Reducers Reducers
*/
-
+
#ifndef REDUCER_H_INCLUDED
#define REDUCER_H_INCLUDED
@@ -59,12 +70,96 @@
namespace cilk {
+/** Class for provisionally constructed objects.
+ *
+ * The monoid_base<T,V>::construct() functions manually construct both a
+ * monoid and a view. If one of these is constructed successfully, and the
+ * construction of the other (or some other initialization) fails, then the
+ * first one must be destroyed to avoid a memory leak. Because the
+ * construction is explicit, the destruction must be explicit, too.
+ *
+ * A provisional_guard object wraps a pointer to a newly constructed
+ * object. A call to its confirm() function confirms that the object is
+ * really going to be used. If the guard is destroyed without being
+ * confirmed, then the pointed-to object is destroyed (but not
+ * deallocated).
+ *
+ * Expected usage:
+ *
+ * provisional_guard<T1> x1_provisional( new (x1) T1 );
+ * … more initialization …
+ * x1_provisional.confirm();
+ *
+ * or
+ *
+ * provisional_guard<T1> x1_provisional( new (x1) T1 );
+ * x1_provisional.confirm_if( new (x2) T2 );
+ *
+ * If an exception is thrown in the "more initialization" code in the
+ * first example, or in the `T2` constructor in the second example, then
+ * `x1_provisional` will not be confirmed, so when its destructor is
+ * called during exception unwinding, the `T1` object that was constructed
+ * in `x1` will be destroyed.
+ *
+ * **NOTE**: Do *not* be tempted to chain a `provisional_guard`
+ * constructor with `confirm_if` as in this example:
+ *
+ * // BAD IDEA
+ * provisional_guard<T1>( new (x1) T1 ).confirm_if( new (x2) T2 );
+ *
+ * The code above is problematic because the evaluation of the T2
+ * constructor is unsequenced with respect to the call to the
+ * `provisional_guard` constructor (and with respect the T1 constructor).
+ * Thus, the compiler may choose to evaluate `new (x2) T2` before
+ * constructing the guard and leak the T1 object if the `T2` constructor
+ * throws.
+ *
+ * @tparam Type The type of the provisionally constructed object.
+ */
+template <typename Type>
+class provisional_guard {
+ Type* m_ptr;
+
+public:
+
+ /** Constructor. Creates a guard for a provisionally constructed object.
+ *
+ * @param ptr A pointer to the provisionally constructed object.
+ */
+ provisional_guard(Type* ptr) : m_ptr(ptr) {}
+
+ /** Destructor. Destroy the object pointed to by the contained pointer
+ * if it has not been confirmed.
+ */
+ ~provisional_guard() { if (m_ptr) m_ptr->~Type(); }
+
+ /** Confirm the provisional construction. Do *not* delete the contained
+ * pointer when the guard is destroyed.
+ */
+ void confirm() { m_ptr = 0; }
+
+ /** Confirm provisional construction if argument is non-null. Note that
+ * if an exception is thrown during evaluation of the argument
+ * expression, then this function will not be called, and the
+ * provisional object will not be confirmed. This allows the usage:
+ *
+ * x1_provisional.confirm_if( new (x2) T2() );
+ *
+ * @param cond An arbitrary pointer. The provisional object will be
+ * confirmed if @a cond is not null.
+ *
+ * @returns The value of the @a cond argument.
+ */
+ template <typename Cond>
+ Cond* confirm_if(Cond* cond) { if (cond) m_ptr = 0; return cond; }
+};
+
/** Base class for defining monoids.
*
* The monoid_base class template is useful for creating classes that model
* the monoid concept. It provides the core type and memory management
* functionality. A subclass of monoid_base need only declare and implement
- * the `identity` and `reduce` functions.
+ * the `identity` and `reduce` functions.
*
* The monoid_base class also manages the integration between the monoid, the
* reducer class that is based on it, and an optional view class which wraps
@@ -79,149 +174,51 @@ namespace cilk {
template <typename Value, typename View = Value>
class monoid_base
{
-protected:
-
- /** Class for provisionally constructed objects.
- *
- * The monoid_base::construct() functions manually construct both a monoid
- * and a view. If one of these is constructed successfully, and the
- * construction of the other (or some other initialization) fails, then
- * the first one must be destroyed to avoid a memory leak. Because the
- * construction is explicit, the destruction must be explicit, too.
- *
- * A provisional_guard object wraps a pointer to a newly constructed
- * object. A call to its confirm() function confirms that the object is
- * really going to be used. If the guard is destroyed without being
- * confirmed, then the pointed-to object is destroyed (but not
- * deallocated).
- *
- * Expected usage:
- *
- * provisional_guard<T1> x1_provisional( new (x1) T1() );
- * … more initialization …
- * x1_provisional.confirm();
- *
- * or
- *
- * provisional_guard<T1> x1_provisional( new (x1) T1() );
- * x1_provisional.confirm_if( new (x2) T2() );
- *
- * If an exception is thrown in the “more initialization” code in the
- * first example, or in the `T2` constructor in the second example, then
- * `x1_provisional` will not be confirmed, so when its destructor is
- * called during exception unwinding, the `T1` object that was constructed
- * in `x1` will be destroyed.
- *
- * @see provisional()
- *
- * @tparam Type The type of the provisionally constructed object.
- */
- template <typename Type>
- class provisional_guard {
- Type* m_ptr;
-
- public:
-
- /** Constructor. Creates a guard for a provisionally constructed object.
- *
- * @param ptr A pointer to the provisionally constructed object.
- */
- provisional_guard(Type* ptr) : m_ptr(ptr) {}
-
- /** Destructor. Destroy the object pointed to by the contained pointer
- * if it has not been confirmed.
- */
- ~provisional_guard() { if (m_ptr) m_ptr->~Type(); }
-
- /** Confirm the provisional construction. Do *not* delete the contained
- * pointer when the guard is destroyed.
- */
- void confirm() { m_ptr = 0; }
-
- /** Confirm provisional construction if argument is non-null. Note that
- * if an exception is thrown during evaluation of the argument
- * expression, then this function will not be called, and the
- * provisional object will not be confirmed. This allows the usage:
- *
- * x1_provisional.confirm_if( new (x2) T2() );
- *
- * @param cond An arbitrary pointer. The provisional object will be
- * confirmed if @a cond is not null.
- *
- * @returns The value of the @a cond argument.
- */
- template <typename Cond>
- Cond* confirm_if(Cond* cond) { if (cond) m_ptr = 0; return cond; }
- };
-
-
- /** Create a provisional_guard object. This function allows simpler code
- * when the only use of a provisional_guard is in a
- * provisional_guard::confirm_if() call immediately following its
- * creation. Instead of
- *
- * provisional_guard<T>guard( new (ptr_to_T) T() );
- * guard.confirm_if( new (ptr_to_U) U() );
- *
- * you can just write
- *
- * provisional( new (ptr_to_T) T() ).confirm_if( new (ptr_to_U) U() );
- *
- * @tparam Type The type of the provisionally constructed object.
- *
- * @param ptr A pointer to a provisionally constructed object.
- *
- * @returns A @ref provisional_guard object that guards the
- * provisionally constructed object pointed to by @a ptr.
- */
- template <typename Type>
- static provisional_guard<Type> provisional(Type* ptr)
- { return provisional_guard<Type>(ptr); }
public:
/** Value type of the monoid.
*/
typedef Value value_type;
-
+
/** View type of the monoid. Defaults to be the same as the value type.
* @see monoid_with_view
*/
typedef View view_type;
-
- enum {
+
+ enum {
/** Should reducers created with this monoid be aligned?
*
* @details
- * “Aligned” means that the view is allocated at a cache-line aligned
+ * "Aligned" means that the view is allocated at a cache-line aligned
* offset in the reducer, and the reducer must be cache-line aligned.
- * “Unaligned” means that the reducer as a whole is just naturally
- * aligned, but it contains a large enough block of uninitialized
+ * "Unaligned" means that the reducer as a whole is just naturally
+ * aligned, but it contains a large enough block of uninitialized
* storage for a cache-line aligned view to be allocated in it at
* reducer construction time.
*
- * Since the standard heap allocator (new reducer) does not allocate
+ * Since the standard heap allocator (new reducer) does not allocate
* cache-line aligned storage, only unaligned reducers can be safely
* allocated on the heap.
- *
+ *
* Default is false (unaligned) unless overridden in a subclass.
*
* @since 1.02
- * (In Cilk library versions 1.0 and 1.01, the default was true.
- * In Cilk library versions prior to 1.0, reducers were always aligned,
- * and this data member did not exist.)
+ * (In Intel Cilk Plus library versions 1.0 and 1.01, the default was true.
+ * In Intel Cilk Plus library versions prior to 1.0, reducers were always
+ * aligned, and this data member did not exist.)
*/
- align_reducer = false
+ align_reducer = false
};
-
- /** Destroy a view. Destroys (without deallocating) the @a View object
+
+ /** Destroys a view. Destroys (without deallocating) the @a View object
* pointed to by @a p.
*
* @param p The address of the @a View object to be destroyed.
*/
void destroy(view_type* p) const { p->~view_type(); }
- /** Allocate raw memory. Allocate @a s bytes of memory with no
+ /** Allocates raw memory. Allocate @a s bytes of memory with no
* initialization.
*
* @param s The number of bytes of memory to allocate.
@@ -229,7 +226,7 @@ public:
*/
void* allocate(size_t s) const { return operator new(s); }
- /** Deallocate raw memory. Deallocates the memory pointed to by @a p
+ /** Deallocates raw memory pointed to by @a p
* without doing any destruction.
*
* @param p Pointer to the memory to be deallocated.
@@ -239,10 +236,10 @@ public:
*/
void deallocate(void* p) const { operator delete(p); }
- /** Create the identity value. Constructs (without allocating) a @a View
+ /** Creates the identity value. Constructs (without allocating) a @a View
* object representing the default value of the @a Value type.
*
- * @param p A pointer to a block of raw memory large enough to hold a
+ * @param p A pointer to a block of raw memory large enough to hold a
* @a View object.
*
* @post The memory pointed to by @a p contains a @a View object that
@@ -255,128 +252,165 @@ public:
* this default definition.
*/
void identity(View* p) const { new ((void*) p) View(); }
-
-
- /** @name Construct the monoid and the view with arbitrary arguments.
+
+
+ /** @name Constructs the monoid and the view with arbitrary arguments.
*
* A @ref reducer object contains monoid and view data members, which are
* declared as raw storage (byte arrays), so that they are not implicitly
* constructed when the reducer is constructed. Instead, a reducer
- * constructor calls one of the monoid class’s static construct()
+ * constructor calls one of the monoid class's static construct()
* functions with the addresses of the monoid and the view, and the
* construct() function uses placement `new` to construct them.
- *
* This allows the monoid to determine the order in which the monoid and
* view are constructed, and to make one of them dependent on the other.
*
- * Any arguments to the reducer constructor are just passed on as
+ * Any arguments to the reducer constructor are just passed on as
* additional arguments to the construct() function (after the monoid
- * and view addresses).
+ * and view addresses are set).
*
- * Any monoid whose needs are satisfied by the suite of construct()
+ * A monoid whose needs are satisfied by the suite of construct()
* functions below, such as @ref monoid_with_view, can just inherit them
* from monoid_base. Other monoids will need to provide their own versions
* to override the monoid_base functions.
*/
//@{
-
- /** Default-construct the monoid, and pass zero to five const reference
- * arguments to the view constructor.
+
+ /** Default-constructs the monoid, identity-constructs the view.
+ *
+ * @param monoid Address of uninitialized monoid object.
+ * @param view Address of uninitialized initial view object.
*/
//@{
-
template <typename Monoid>
static void construct(Monoid* monoid, View* view)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- (monoid->identity(view), view) ); }
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid() );
+ monoid->identity(view);
+ guard.confirm();
+ }
+ //@}
+
+ /** Default-constructs the monoid, and passes one to five const reference
+ * arguments to the view constructor.
+ */
+ //@{
template <typename Monoid, typename T1>
static void construct(Monoid* monoid, View* view, const T1& x1)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1) ); }
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid() );
+ guard.confirm_if( new((void*) view) View(x1) );
+ }
template <typename Monoid, typename T1, typename T2>
- static void construct(Monoid* monoid, View* view,
+ static void construct(Monoid* monoid, View* view,
const T1& x1, const T2& x2)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1, x2) ); }
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid() );
+ guard.confirm_if( new((void*) view) View(x1, x2) );
+ }
template <typename Monoid, typename T1, typename T2, typename T3>
- static void construct(Monoid* monoid, View* view,
+ static void construct(Monoid* monoid, View* view,
const T1& x1, const T2& x2, const T3& x3)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1, x2, x3) ); }
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid() );
+ guard.confirm_if( new((void*) view) View(x1, x2, x3) );
+ }
- template <typename Monoid, typename T1, typename T2, typename T3,
+ template <typename Monoid, typename T1, typename T2, typename T3,
typename T4>
- static void construct(Monoid* monoid, View* view,
- const T1& x1, const T2& x2, const T3& x3,
+ static void construct(Monoid* monoid, View* view,
+ const T1& x1, const T2& x2, const T3& x3,
const T4& x4)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1, x2, x3, x4) ); }
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid() );
+ guard.confirm_if( new((void*) view) View(x1, x2, x3, x4) );
+ }
- template <typename Monoid, typename T1, typename T2, typename T3,
+ template <typename Monoid, typename T1, typename T2, typename T3,
typename T4, typename T5>
- static void construct(Monoid* monoid, View* view,
- const T1& x1, const T2& x2, const T3& x3,
+ static void construct(Monoid* monoid, View* view,
+ const T1& x1, const T2& x2, const T3& x3,
const T4& x4, const T5& x5)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1, x2, x3, x4, x5) ); }
-
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid() );
+ guard.confirm_if( new((void*) view) View(x1, x2, x3, x4, x5) );
+ }
+
//@}
-
- /** Default-construct the monoid, and pass one non-const reference argument
- * to the view constructor.
+
+ /** Default-constructs the monoid, and passes one non-const reference
+ * argument to the view constructor.
*/
//@{
template <typename Monoid, typename T1>
static void construct(Monoid* monoid, View* view, T1& x1)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1) ); }
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid() );
+ guard.confirm_if( new((void*) view) View(x1) );
+ }
//@}
- /** Copy-construct the monoid, and pass zero to four const reference
- * arguments to the view constructor.
+ /** Copy-constructs the monoid, and identity-constructs the view
+ * constructor.
+ *
+ * @param monoid Address of uninitialized monoid object.
+ * @param view Address of uninitialized initial view object.
+ * @param m Object to be copied into `*monoid`
*/
//@{
-
template <typename Monoid>
static void construct(Monoid* monoid, View* view, const Monoid& m)
- { provisional( new ((void*)monoid) Monoid(m) ).confirm_if(
- new ((void*)view) View() ); }
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid(m) );
+ monoid->identity(view);
+ guard.confirm();
+ }
+ //@}
+
+ /** Copy-constructs the monoid, and passes one to four const reference
+ * arguments to the view constructor.
+ */
+ //@{
template <typename Monoid, typename T1>
- static void construct(Monoid* monoid, View* view, const Monoid& m,
+ static void construct(Monoid* monoid, View* view, const Monoid& m,
const T1& x1)
- { provisional( new ((void*)monoid) Monoid(m) ).confirm_if(
- new ((void*)view) View(x1) ); }
-
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid(m) );
+ guard.confirm_if( new((void*) view) View(x1) );
+ }
+
template <typename Monoid, typename T1, typename T2>
- static void construct(Monoid* monoid, View* view, const Monoid& m,
+ static void construct(Monoid* monoid, View* view, const Monoid& m,
const T1& x1, const T2& x2)
- { provisional( new ((void*)monoid) Monoid(m) ).confirm_if(
- new ((void*)view) View(x1, x2) ); }
-
+ {
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid(m) );
+ guard.confirm_if( new((void*) view) View(x1, x2) );
+ }
+
template <typename Monoid, typename T1, typename T2, typename T3>
- static void construct(Monoid* monoid, View* view, const Monoid& m,
+ static void construct(Monoid* monoid, View* view, const Monoid& m,
const T1& x1, const T2& x2, const T3& x3)
{
- provisional( new ((void*)monoid) Monoid(m) ).confirm_if(
- new ((void*)view) View(x1, x2, x3) );
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid(m) );
+ guard.confirm_if( new((void*) view) View(x1, x2, x3) );
}
-
- template <typename Monoid, typename T1, typename T2, typename T3,
+
+ template <typename Monoid, typename T1, typename T2, typename T3,
typename T4>
- static void construct(Monoid* monoid, View* view, const Monoid& m,
- const T1& x1, const T2& x2, const T3& x3,
+ static void construct(Monoid* monoid, View* view, const Monoid& m,
+ const T1& x1, const T2& x2, const T3& x3,
const T4& x4)
{
- provisional( new ((void*)monoid) Monoid(m) ).confirm_if(
- new ((void*)view) View(x1, x2, x3, x4) );
+ provisional_guard<Monoid> guard( new((void*) monoid) Monoid(m) );
+ guard.confirm_if( new((void*) view) View(x1, x2, x3, x4) );
}
-
+
//@}
-
+
//@}
};
@@ -385,8 +419,8 @@ public:
* from its view.
*
* A simple implementation of the monoid-view-reducer architecture would
- * distribute knowledge about the type and operations for the reduction
- * between the monoid and the view — the identity and reduction operations are
+ * distribute knowledge about the type and operations for the reduction
+ * between the monoid and the view - the identity and reduction operations are
* specified in the monoid, the reduction operations are implemented in the
* view, and the value type is specified in both the monoid and the view.
* This is inelegant.
@@ -396,10 +430,11 @@ public:
* customization of the monoid_with_view class itself is needed beyond
* instantiating it with an appropriate view class. (Customized subclasses of
* monoid_with_view may be needed for other reasons, such as to keep some
- * state for the reducer.) All of the Cilk predefined reducers use
+ * state for the reducer.) All of the Intel Cilk Plus predefined reducers use
* monoid_with_view or one of its subclasses.
- *
- * The view class `View` of a monoid_with_view must provide the following public definitions:
+ *
+ * The view class `View` of a monoid_with_view must provide the following
+ * public definitions:
*
* Definition | Meaning
* ---------------------------------|--------
@@ -420,20 +455,20 @@ public:
/** Should reducers created with this monoid be aligned?
*/
enum { align_reducer = Align };
-
+
/** Create the identity value.
*
- * Implements the monoid `identity` operation by using the @a View class’s
+ * Implements the monoid `identity` operation by using the @a View class's
* default constructor.
*
- * @param p A pointer to a block of raw memory large enough to hold a
+ * @param p A pointer to a block of raw memory large enough to hold a
* @p View object.
*/
- void identity(View* p) const { new ((void*)p) View(); }
-
+ void identity(View* p) const { new((void*) p) View(); }
+
/** Reduce the values of two views.
*
- * Implements the monoid `reduce` operation by calling the left view’s
+ * Implements the monoid `reduce` operation by calling the left view's
* `%reduce()` function with the right view as an operand.
*
* @param left The left operand of the reduce operation.
@@ -452,7 +487,7 @@ public:
* required by a @ref monoid_with_view (but not the identity constructor and
* reduce operation, which are inherently specific to a particular kind of
* reduction). It also defines the value access functions which will be called
- * by the corresponding @ref reducer functions. (It uses copy semantics for
+ * by the corresponding @ref reducer functions. (It uses copy semantics for
* the view_move_in() and view_move_out() functions, which is appropriate
* for simple scalar types, but not necessarily for more complex types like
* STL containers.
@@ -469,15 +504,15 @@ public:
/** Value type definition required by @ref monoid_with_view.
*/
typedef Type value_type;
-
+
/** Default constructor.
*/
- scalar_view() : m_value() {}
-
+ scalar_view() : m_value() {}
+
/** Value constructor.
*/
scalar_view(const Type& v) : m_value(v) {}
-
+
/** @name Value functions required by the reducer class.
*
* Note that the move in/out functions use simple assignment semantics.
@@ -499,12 +534,16 @@ public:
/** Get the value of the view.
*/
Type const& view_get_value() const { return m_value; }
-
+
+ /** Type returned by view_get_value.
+ */
+ typedef Type const& return_type_for_get_value;
+
/** Get a reference to the value contained in the view. For legacy
* reducer support only.
*/
Type & view_get_reference() { return m_value; }
-
+
/** Get a reference to the value contained in the view. For legacy
* reducer support only.
*/
@@ -517,18 +556,18 @@ public:
*
* Some types allow their values to be _moved_ as an alternative to copying.
* Moving a value may be much faster than copying it, but may leave the value
- * of the move’s source undefined. Consider the `swap` operation provided by
+ * of the move's source undefined. Consider the `swap` operation provided by
* many STL container classes:
*
* list<T> x, y;
* x = y; // Copy
* x.swap(y); // Move
*
- * The assignment _copies_ the value of `y` into `x` in time linear in the
+ * The assignment _copies_ the value of `y` into `x` in time linear in the
* size of `y`, leaving `y` unchanged. The `swap` _moves_ the value of `y`
* into `x` in constant time, but it also moves the value of `x` into `y`,
* potentially leaving `y` undefined.
- *
+ *
* A move_in_wrapper simply wraps a pointer to an object. It is created by a
* call to cilk::move_in(). Passing a move_in_wrapper to a view constructor
* (actually, passing it to a reducer constructor, which passes it to the
@@ -538,18 +577,18 @@ public:
*
* A view class exercises this option by defining a _move-in constructor_,
* i.e., a constructor with a move_in_wrapper parameter. The constructor calls
- * the wrapper’s `value()` function to get a reference to its pointed-to
+ * the wrapper's `value()` function to get a reference to its pointed-to
* value, and can then use that reference in a move operation.
*
* A move_in_wrapper also has an implicit conversion to its pointed-to value,
- * so if a view class does not define a move-in constructor, its ordinary
+ * so if a view class does not define a move-in constructor, its ordinary
* value constructor will be called with the wrapped value. For example, an
* @ref ReducersAdd "op_add" view does not have a move-in constructor, so
*
* int x;
* reducer< op_add<int> > xr(move_in(x));
*
- * will simply call the `op_add_view(const int &)` constructor. But an
+ * will simply call the `op_add_view(const int &)` constructor. But an
* @ref ReducersList "op_list_append" view does have a move-in constructor,
* so
*
@@ -573,19 +612,19 @@ class move_in_wrapper
{
Type *m_pointer;
public:
-
+
/** Constructor that captures the address of its argument. This is almost
* always called from the @ref move_in function.
*/
explicit move_in_wrapper(Type& ref) : m_pointer(&ref) { }
-
+
/** Implicit conversion to the wrapped value. This allows a move_in_wrapper
* to be used where a value of the wrapped type is expected, in which case
* the wrapper is completely transparent.
*/
operator Type&() const { return *m_pointer; }
-
- /** Get a reference to the pointed-to value. This has the same effect as
+
+ /** Get a reference to the pointed-to value. This has the same effect as
* the implicit conversion, but makes the intent clearer in a move-in
* constructor.
*/
@@ -594,7 +633,7 @@ public:
/** Function to create a move_in_wrapper for a value.
*
- * @tparam Type The type of the argument, which will be the `type` of the
+ * @tparam Type The type of the argument, which will be the `type` of the
* created wrapper.
*
* @see move_in_wrapper
@@ -608,9 +647,9 @@ move_in_wrapper<Type> move_in(Type& ref)
/** @copydoc move_in(Type&)
*
* @note Applying a function that is explicitly specified as modifying its
- * argument to a const argument is obviously an irrational thing to
+ * argument to a const argument is obviously an irrational thing to
* do. This move_in() variant is just provided to allow calling a
- * move-in constructor with a function return value, which the
+ * move-in constructor with a function return value, which the
* language treats as a const. Using it for any other purpose will
* probably end in tears.
*/
@@ -622,37 +661,37 @@ move_in_wrapper<Type> move_in(const Type& ref)
/** Wrapper class to allow implicit downcasts to reducer subclasses.
*
- * The Cilk library contains a collection of reducer wrapper classes which
- * were created before the `cilk::reducer<Monoid>` style was developed. For
+ * The Intel Cilk Plus library contains a collection of reducer wrapper classes which
+ * were created before the `cilk::reducer<Monoid>` style was developed. For
* example, `cilk::reducer_opadd<Type>` provided essentially the same
- * functionality that is now provided by
- * `cilk::reducer< cilk::op_add<Type> >`. These legacy reducer classes are
- * deprecated, but still supported, and they have been reimplemented as
+ * functionality that is now provided by
+ * `cilk::reducer< cilk::op_add<Type> >`. These legacy reducer classes are
+ * deprecated, but still supported, and they have been reimplemented as
* subclasses of the corresponding `cilk::reducer` classes. For example:
*
* template <class T>
* reducer_opadd<T> : public reducer< op_add<T> > { ... };
*
- * This reimplementation allows transparent conversion between legacy and
- * new reducers. That is, a `reducer<op_add>*` or `reducer<op_add>&` can be
- * used anywhere that a `reducer_opadd*` or `reducer_opadd&` is expected,
- * and vice versa.
+ * This reimplementation allows transparent conversion between legacy and
+ * new reducers. That is, a `reducer<op_add>*` or `reducer<op_add>&` can be
+ * used anywhere that a `reducer_opadd*` or `reducer_opadd&` is expected,
+ * and vice versa.
*
- * The conversion from the legacy reducer to the new reducer is just an
- * up-cast, which is provided for free by C++. The conversion from the new
- * reducer to the legacy reducer is a down-cast, though, which requires an
+ * The conversion from the legacy reducer to the new reducer is just an
+ * up-cast, which is provided for free by C++. The conversion from the new
+ * reducer to the legacy reducer is a down-cast, though, which requires an
* explicit conversion member function in the `reducer` class. The challenge
* is to define a function in the reducer template class which will convert
- * each cilk::reducer specialization to the corresponding legacy reducer,
+ * each cilk::reducer specialization to the corresponding legacy reducer,
* if there is one.
*
* The trick is in the legacy_reducer_downcast template class, which provides
* a mapping from `cilk::reducer` specializations to legacy reducer classes.
- * `reducer<Monoid>` has a conversion function to convert itself to
+ * `reducer<Monoid>` has a conversion function to convert itself to
* `legacy_reducer_downcast< reducer<Monoid> >::%type`. By default,
* `legacy_reducer_downcast<Reducer>::%type` is just a trivial subclass of
* `Reducer`, which is uninteresting, but a reducer with a legacy counterpart
- * will have a specialization of `legacy_reducer_downcast` whose `type` is
+ * will have a specialization of `legacy_reducer_downcast` whose `type` is
* the corresponding legacy reducer. For example:
*
* template <typename Type>
@@ -662,16 +701,17 @@ move_in_wrapper<Type> move_in(const Type& ref)
* };
*
*
- * @tparam Reducer The new-style reducer class whose corresponding legacy reducer class
- * is `type`, if there is such a legacy reducer class.
+ * @tparam Reducer The new-style reducer class whose corresponding legacy
+ * reducer class is `type`, if there is such a legacy reducer
+ * class.
*/
template <typename Reducer>
struct legacy_reducer_downcast
{
/** The related legacy reducer class.
*
- * By default, this is just a trivial subclass of Reducer, but it can be
- * overridden in the specialization of legacy_reducer_downcast for
+ * By default, this is just a trivial subclass of Reducer, but it can be
+ * overridden in the specialization of legacy_reducer_downcast for
* a reducer that has a corresponding legacy reducers.
*/
struct type : Reducer { };
@@ -684,21 +724,51 @@ namespace internal {
template <typename Value, typename View>
struct reducer_set_get
{
- static View theView; // Declared but not defined
-
- // sizeof(notchar) is guaranteed larger than 1
+ // sizeof(notchar) != sizeof(char)
struct notchar { char x[2]; };
- // check_for_ref returns char if 'get_value' returns by value and notchar
- // if 'get_value' returns by reference.
- static char check_for_ref(Value, ...);
- static notchar check_for_ref(Value&, int);
+ // `does_view_define_return_type_for_get_value(View*)` returns `char` if
+ // `View` defines `return_type_for_get_value`, and `notchar` if it doesn't.
+
+ template <typename T>
+ struct using_type {};
+
+ template <typename T>
+ static char does_view_define_return_type_for_get_value(
+ using_type<typename T::return_type_for_get_value>*);
- enum { GET_VALUE_BY_VALUE =
- (1 == sizeof(check_for_ref(theView.view_get_value(), 0))) } ;
+ template <typename T>
+ static notchar does_view_define_return_type_for_get_value(...);
- typedef typename condition<GET_VALUE_BY_VALUE,
- Value, const Value&>::type get_value_type;
+ // `VIEW_DOES_DEFINE_RETURN_TYPE_FOR_GET_VALUE` is true if `View` defines
+ // `return_type_for_get_value`.
+
+ enum { VIEW_DOES_DEFINE_RETURN_TYPE_FOR_GET_VALUE =
+ sizeof( does_view_define_return_type_for_get_value<View>(0) )
+ == sizeof(char) } ;
+
+ // `return_type_for_get_value` is `View::return_type_for_get_value`
+ // if it is defined, and just `Value` otherwise.
+
+ template <typename InnerView, bool ViewDoesDefineReturnTypeForGetValue>
+ struct return_type_for_view_get_value {
+ typedef Value type;
+ };
+
+ template <typename InnerView>
+ struct return_type_for_view_get_value<InnerView, true> {
+ typedef typename InnerView::return_type_for_get_value type;
+ };
+
+public:
+
+ typedef
+ typename
+ return_type_for_view_get_value<
+ View,
+ VIEW_DOES_DEFINE_RETURN_TYPE_FOR_GET_VALUE
+ >::type
+ return_type_for_get_value;
static void move_in(View& view, Value& v) { view.view_move_in(v); }
static void move_out(View& view, Value& v) { view.view_move_out(v); }
@@ -706,21 +776,23 @@ struct reducer_set_get
static void set_value(View& view, const Value& v)
{ view.view_set_value(v); }
- static get_value_type get_value(const View& view)
+ static return_type_for_get_value get_value(const View& view)
{ return view.view_get_value(); }
};
template <typename Value>
struct reducer_set_get<Value, Value>
{
- typedef const Value& get_value_type;
+ typedef const Value& return_type_for_get_value;
static void move_in(Value& view, Value& v) { view = v; }
static void move_out(Value& view, Value& v) { v = view; }
- static void set_value(Value& view, const Value& v) { view = v; }
+ static void set_value(Value& view, const Value& v)
+ { view = v; }
- static get_value_type get_value(const Value& view) { return view; }
+ static return_type_for_get_value get_value(const Value& view)
+ { return view; }
};
/// @endcond
@@ -728,7 +800,7 @@ struct reducer_set_get<Value, Value>
/** Base class defining the data layout that is common to all reducers.
*/
-template <typename Monoid>
+template <typename Monoid>
class reducer_base {
typedef typename Monoid::view_type view_type;
@@ -746,20 +818,20 @@ class reducer_base {
// Used for sanity checking at destruction.
//
void* m_initialThis;
-
+
// The leftmost view comes next. It is defined in the derived
// reducer_content class.
-
+
/** @name C-callable wrappers for the C++-coded monoid dispatch functions.
*/
//@{
-
+
static void reduce_wrapper(void* r, void* lhs, void* rhs);
static void identity_wrapper(void* r, void* view);
static void destroy_wrapper(void* r, void* view);
static void* allocate_wrapper(void* r, __STDNS size_t bytes);
static void deallocate_wrapper(void* r, void* view);
-
+
//@}
protected:
@@ -768,7 +840,7 @@ protected:
*
* @param leftmost The address of the leftmost view in the reducer.
*/
- reducer_base(char* leftmost)
+ reducer_base(char* leftmost)
{
static const cilk_c_monoid c_monoid_initializer = {
(cilk_c_reducer_reduce_fn_t) &reduce_wrapper,
@@ -783,10 +855,10 @@ protected:
m_base.__view_offset = (char*)leftmost - (char*)this;
m_base.__view_size = sizeof(view_type);
m_initialThis = this;
-
+
__cilkrts_hyper_create(&m_base);
}
-
+
/** Destructor.
*/
__CILKRTS_STRAND_STALE(~reducer_base())
@@ -794,7 +866,7 @@ protected:
// Make sure we haven't been memcopy'd or corrupted
__CILKRTS_ASSERT(
this == m_initialThis ||
- // Allow for a layout bug that may put the initialThis field one
+ // Allow for a layout bug that may put the initialThis field one
// word later in 1.0 reducers than in 0.9 and 1.1 reducers.
this == *(&m_initialThis + 1)
);
@@ -803,63 +875,63 @@ protected:
/** Monoid data member.
*
- * @return A pointer to the reducer’s monoid data member.
+ * @return A pointer to the reducer's monoid data member.
*/
Monoid* monoid_ptr() { return &m_monoid.object(); }
/** Leftmost view data member.
*
- * @return A pointer to the reducer’s leftmost view data member.
+ * @return A pointer to the reducer's leftmost view data member.
*
- * @note This function returns the address of the *leftmost* view,
- * which is unique for the lifetime of the reducer. It is
- * intended to be used in constructors and destructors.
- * Use the reducer::view() function to access the per-strand
+ * @note This function returns the address of the *leftmost* view,
+ * which is unique for the lifetime of the reducer. It is
+ * intended to be used in constructors and destructors.
+ * Use the reducer::view() function to access the per-strand
* view instance.
*/
- view_type* leftmost_ptr()
+ view_type* leftmost_ptr()
{
char* view_addr = (char*)this + m_base.__view_offset;
return reinterpret_cast<view_type*>(view_addr);
}
-
+
public:
/** @name Access the current view.
*
- * These functions return a reference to the instance of the reducer’s
+ * These functions return a reference to the instance of the reducer's
* view that was created for the current strand of a parallel computation
- * (and create it if it doesn’t already exist). Note the difference from
+ * (and create it if it doesn't already exist). Note the difference from
* the (private) leftmost_ptr() function, which returns a pointer to the
* _leftmost_ view, which is the same in all strands.
*/
//@{
-
+
/** Per-strand view instance.
*
* @return A reference to the per-strand view instance.
*/
- view_type& view()
+ view_type& view()
{
- return *static_cast<view_type *>(__cilkrts_hyper_lookup(&m_base));
+ return *static_cast<view_type *>(__cilkrts_hyper_lookup(&m_base));
}
-
+
/** @copydoc view()
*/
- const view_type& view() const
- {
- return const_cast<reducer_base*>(this)->view();
+ const view_type& view() const
+ {
+ return const_cast<reducer_base*>(this)->view();
}
-
+
//@}
-
+
/** Initial view pointer field.
*
* @internal
*
* @return a reference to the m_initialThis field.
*
- * @note This function is provided for “white-box” testing of the
+ * @note This function is provided for "white-box" testing of the
* reducer layout code. There is never any reason for user code
* to call it.
*/
@@ -905,7 +977,7 @@ void reducer_base<Monoid>::deallocate_wrapper(void* r, void* view)
/** Base class defining the data members of a reducer.
*
- * @tparam Aligned The `m_view` data member, and therefore the entire
+ * @tparam Aligned The `m_view` data member, and therefore the entire
* structure, are cache-line aligned if this parameter
* is `true'.
*/
@@ -918,12 +990,12 @@ template <typename Monoid>
class reducer_content<Monoid, true> : public reducer_base<Monoid>
{
typedef typename Monoid::view_type view_type;
-
+
// The leftmost view is defined as raw bytes. It will be constructed
- // by the monoid `construct` function. It is cache-aligned, which
+ // by the monoid `construct` function. It is cache-aligned, which
// will push it into a new cache line. Furthermore, its alignment causes
- // the reducer as a whole to be cache-aligned, which makes the reducer
- // size a multiple of a cache line. Since there is nothing in the reducer
+ // the reducer as a whole to be cache-aligned, which makes the reducer
+ // size a multiple of a cache line. Since there is nothing in the reducer
// after the view, all this means that the leftmost view gets one or more
// cache lines all to itself, which prevents false sharing.
//
@@ -936,7 +1008,7 @@ class reducer_content<Monoid, true> : public reducer_base<Monoid>
*/
bool reducer_is_cache_aligned() const
{ return 0 == ((std::size_t) this & (__CILKRTS_CACHE_LINE__ - 1)); }
-
+
protected:
/** Constructor.
@@ -945,14 +1017,15 @@ protected:
{
#ifndef CILK_IGNORE_REDUCER_ALIGNMENT
assert(reducer_is_cache_aligned() &&
- "Reducer should be cache aligned. Please see comments following this assertion for explanation and fixes.");
+ "Reducer should be cache aligned. Please see comments following "
+ "this assertion for explanation and fixes.");
#endif
/* "REDUCER SHOULD BE CACHE ALIGNED" ASSERTION.
*
- * This Reducer class instantiation specifies cache-line alignment of the
+ * This Reducer class instantiation specifies cache-line alignment of the
* leftmost view field (and, implicitly, of the reducer itself). You got
* this assertion because a reducer with this class was allocated at a
- * non-cache-aligned address, probably because it was allocated on the
+ * non-cache-aligned address, probably because it was allocated on the
* heap with `new`. This can be a problem for two reasons:
*
* 1. If the leftmost view is not on a cache line by itself, there might
@@ -974,14 +1047,14 @@ protected:
*
* There are three ways that you can fix this assertion failure.
*
- * A. Rewrite your code to use the new-style `reducer< op_XXX<Type> >`
+ * A. Rewrite your code to use the new-style `reducer< op_XXX<Type> >`
* instead of the legacy `reducer_XXX<type>`. The new-style reducers
* are not declared to be cache-aligned, and will work properly if
* they are not cache-aligned.
*
* B. If you must allocate an old-style reducer or a structure containing
* a reducer on the heap, figure out how to align it correctly. The
- * suggested fix is to use `cilk::aligned_new()` and
+ * suggested fix is to use `cilk::aligned_new()` and
* `cilk::aligned_delete()` instead of `new` and `delete`, as follows:
*
* Type* ptr = cilk::aligned_new<Type>(constructor-arguments);
@@ -1003,7 +1076,7 @@ class reducer_content<Monoid, false> : public reducer_base<Monoid>
// Reserve space for the leftmost view. The view will be allocated at an
// aligned offset in this space at runtime, to guarantee that the view
- // will get one or more cache lines all to itself, to prevent false
+ // will get one or more cache lines all to itself, to prevent false
// sharing.
//
// The number of bytes to reserve is determined as follows:
@@ -1026,10 +1099,10 @@ class reducer_content<Monoid, false> : public reducer_base<Monoid>
protected:
/** Constructor. Find the first cache-aligned position in the reserved
- * area, and pass it to the base constructor as the leftmost view
+ * area, and pass it to the base constructor as the leftmost view
* address.
*/
- reducer_content() :
+ reducer_content() :
reducer_base<Monoid>(
(char*)( ((std::size_t)&m_leftmost + __CILKRTS_CACHE_LINE__ - 1)
& ~ (__CILKRTS_CACHE_LINE__ - 1) ) )
@@ -1056,8 +1129,9 @@ namespace stub {
* A reducer is instantiated on a Monoid. The Monoid provides the value
* type, associative reduce function, and identity for the reducer.
*
- * @tparam Monoid The monoid class that the reducer is instantiated on. It must model
- * the @ref reducers_monoid_concept "monoid concept".
+ * @tparam Monoid The monoid class that the reducer is instantiated on. It
+ * must model the @ref reducers_monoid_concept "monoid
+ * concept".
*
* @see @ref pagereducers
*/
@@ -1068,33 +1142,33 @@ class reducer : public internal::reducer_content<Monoid>
using base::monoid_ptr;
using base::leftmost_ptr;
public:
- typedef Monoid monoid_type; ///< The monoid type.
- typedef typename Monoid::value_type value_type; ///< The value type.
- typedef typename Monoid::view_type view_type; ///< The view type.
+ typedef Monoid monoid_type; ///< The monoid type.
+ typedef typename Monoid::value_type value_type; ///< The value type.
+ typedef typename Monoid::view_type view_type; ///< The view type.
private:
typedef internal::reducer_set_get<value_type, view_type> set_get;
-
+
reducer(const reducer&); ///< Disallow copying.
reducer& operator=(const reducer&); ///< Disallow assignment.
public:
-
+
/** @name Constructors
*
- * All reducer constructors call the static `construct()` function of the monoid class to
- * construct the reducer's monoid and leftmost view.
+ * All reducer constructors call the static `construct()` function of the
+ * monoid class to construct the reducer's monoid and leftmost view.
*
- * The reducer constructor arguments are simply passed through to the construct() function.
- * Thus, the constructor parameters accepted by a particular reducer class are determined
- * by its monoid class.
+ * The reducer constructor arguments are simply passed through to the
+ * construct() function. Thus, the constructor parameters accepted by a
+ * particular reducer class are determined by its monoid class.
*/
//@{
/** 0 – 6 const reference parameters.
*/
//@{
-
+
reducer()
{
monoid_type::construct(monoid_ptr(), leftmost_ptr());
@@ -1125,19 +1199,24 @@ class reducer : public internal::reducer_content<Monoid>
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
- reducer(const T1& x1, const T2& x2, const T3& x3, const T4& x4, const T5& x5)
+ reducer(const T1& x1, const T2& x2, const T3& x3, const T4& x4,
+ const T5& x5)
{
- monoid_type::construct(monoid_ptr(), leftmost_ptr(), x1, x2, x3, x4, x5);
+ monoid_type::construct(monoid_ptr(), leftmost_ptr(),
+ x1, x2, x3, x4, x5);
}
- template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
- reducer(const T1& x1, const T2& x2, const T3& x3, const T4& x4, const T5& x5, const T6& x6)
+ template <typename T1, typename T2, typename T3, typename T4,
+ typename T5, typename T6>
+ reducer(const T1& x1, const T2& x2, const T3& x3, const T4& x4,
+ const T5& x5, const T6& x6)
{
- monoid_type::construct(monoid_ptr(), leftmost_ptr(), x1, x2, x3, x4, x5, x6);
+ monoid_type::construct(monoid_ptr(), leftmost_ptr(),
+ x1, x2, x3, x4, x5, x6);
}
-
+
//@}
-
+
/** 1 non-const reference parameter.
*/
//@{
@@ -1147,7 +1226,7 @@ class reducer : public internal::reducer_content<Monoid>
{
monoid_type::construct(monoid_ptr(), leftmost_ptr(), x1);
}
-
+
//@}
/** Destructor.
@@ -1164,29 +1243,29 @@ class reducer : public internal::reducer_content<Monoid>
* @return A reference to the monoid object belonging to this reducer.
*/
Monoid& monoid() { return *monoid_ptr(); }
-
- const Monoid& monoid() const
+
+ const Monoid& monoid() const
{ return const_cast<reducer*>(this)->monoid(); }
//@}
//@{
/** Access the current view.
*
- * Return a reference to the instance of the reducer’s view that was
+ * Return a reference to the instance of the reducer's view that was
* created for the current strand of a parallel computation (and create
- * it if it doesn’t already exist).
+ * it if it doesn't already exist).
*/
view_type& view() { return base::view(); }
const view_type& view() const { return base::view(); }
//@}
-
+
/** @name Dereference the reducer to get the view.
*
- * “Dereferencing” a reducer yields the view for the current strand. The
+ * "Dereferencing" a reducer yields the view for the current strand. The
* view, in turn, acts as a proxy for its contained value, exposing only
- * those operations which are consistent with the reducer’s monoid. Thus,
- * all modifications of the reducer’s accumulator variable are written as
+ * those operations which are consistent with the reducer's monoid. Thus,
+ * all modifications of the reducer's accumulator variable are written as
*
* *reducer OP ...
*
@@ -1194,7 +1273,7 @@ class reducer : public internal::reducer_content<Monoid>
*
* reducer->func(...)
*
- * (The permitted operations on a reducer’s accumulator are listed in the
+ * (The permitted operations on a reducer's accumulator are listed in the
* documentation for that particular kind of reducer.)
*
* @note `*r` is a synonym for `r.view()`. Recommended style is to use
@@ -1204,7 +1283,7 @@ class reducer : public internal::reducer_content<Monoid>
* call attention to the view itself.
*/
//@{
-
+
//@{
/** Dereference operator.
*
@@ -1222,12 +1301,12 @@ class reducer : public internal::reducer_content<Monoid>
view_type* operator->() { return &view(); }
view_type const* operator->() const { return &view(); }
//@}
-
+
//@{
/** Deprecated view access.
*
- * `r()` is a synonym for `*r` which was used with early versions of Cilk
- * reducers. `*r` is now the preferred usage.
+ * `r()` is a synonym for `*r` which was used with early versions of
+ * Intel Cilk Plus reducers. `*r` is now the preferred usage.
*
* @deprecated Use operator*() instead of operator()().
*
@@ -1236,9 +1315,9 @@ class reducer : public internal::reducer_content<Monoid>
view_type& operator()() { return view(); }
view_type const& operator()() const { return view(); }
//@}
-
+
//@}
-
+
/** @name Set and get the value.
*
* These functions are used to set an initial value for the reducer before
@@ -1247,25 +1326,25 @@ class reducer : public internal::reducer_content<Monoid>
*
* @note These functions are completely different from the view
* operations that are made available via operator*() and
- * operator->(), which are used to _modify_ the reducer’s value
+ * operator->(), which are used to _modify_ the reducer's value
* _during_ the reduction.
*
- * @warning These functions _can_ be called at any time, and in
+ * @warning These functions _can_ be called at any time, and in
* general, they will refer to the value contained in the view
* for the current strand. However, using them other than to
- * set the reduction’s initial value or get its final value
+ * set the reduction's initial value or get its final value
* will almost always result in undefined behavior.
*/
//@{
/** Move a value into the reducer.
*
- * This function is used to set the initial value of the reducer’s
+ * This function is used to set the initial value of the reducer's
* accumulator variable by either copying or _moving_ the value of @a obj
* into it. Moving a value can often be performed in constant time, even
* for large container objects, but has the side effect of leaving the
- * value of @a obj undefined. (See the description of the
- * @ref move_in_wrapper class for a discussion of moving values.)
+ * value of @a obj undefined. (See the description of the
+ * @ref move_in_wrapper class for a discussion of moving values.)
*
* @par Usage
* A move_in() call to initialize a reducer is often paired with a
@@ -1278,14 +1357,14 @@ class reducer : public internal::reducer_content<Monoid>
*
* @par Assumptions
* - You cannot assume either that this will function will copy its
- * value or that it will move it.
- * - You must assume that the value of @a obj will be undefined
- * after the call to move_in().
+ * value or that it will move it.
+ * - You must assume that the value of @a obj will be undefined
+ * after the call to move_in().
* - You can assume that move_in() will be at least as efficient as
* set_value(), and you should therefore prefer move_in() unless
* you need the value of @a obj to be unchanged after the call.
* (But you should usually prefer the move-in constructor over a
- * move_in() call — see the note below.)
+ * move_in() call - see the note below.)
*
* @note The behavior of a default constructor followed by move-in
* initialization:
@@ -1296,14 +1375,14 @@ class reducer : public internal::reducer_content<Monoid>
* @note is not necessarily the same as a move-in constructor:
*
* reducer<Type> xr(move_in(x));
- *
- * @note In particular, when @a Type is a container type with a
+ *
+ * @note In particular, when @a Type is a container type with a
* non-empty allocator, the move-in constructor will create the
* accumulator variable with the same allocator as the input
* argument @a x, while the default constructor will create the
* accumulator variable with a default allocator. The mismatch of
- * allocators in the latter case means that the input argument
- * @a x may have to be copied in linear time instead of being
+ * allocators in the latter case means that the input argument
+ * @a x may have to be copied in linear time instead of being
* moved in constant time.
*
* @note Best practice is to prefer the move-in constructor over the
@@ -1326,13 +1405,13 @@ class reducer : public internal::reducer_content<Monoid>
/** Move the value out of the reducer.
*
- * This function is used to retrieve the final value of the reducer’s
+ * This function is used to retrieve the final value of the reducer's
* accumulator variable by either copying or _moving_ the value of @a obj
* into it. Moving a value can often be performed in constant time, even
* for large container objects, but has the side effect of leaving the
- * value of the reducer’s accumulator variable undefined. (See the
- * description of the @ref move_in_wrapper class for a discussion of
- * moving values.)
+ * value of the reducer's accumulator variable undefined. (See the
+ * description of the @ref move_in_wrapper class for a discussion of
+ * moving values.)
*
* @par Usage
* A move_in() call to initialize a reducer is often paired with a
@@ -1345,15 +1424,15 @@ class reducer : public internal::reducer_content<Monoid>
*
* @par Assumptions
* - You cannot assume either that this will function will copy its
- * value or that it will move it.
- * - You must assume that the value of the reducer’s accumulator
+ * value or that it will move it.
+ * - You must assume that the value of the reducer's accumulator
* variable will be undefined after the call to move_out().
* - You can assume that move_out() will be at least as efficient as
* get_value(), and you should therefore prefer move_out() unless
* you need the accumulator variable to be preserved after the
* call.
*
- * @warning Calling this function other than to retrieve the final
+ * @warning Calling this function other than to retrieve the final
* value of a reduction will almost always result in undefined
* behavior.
*
@@ -1368,7 +1447,7 @@ class reducer : public internal::reducer_content<Monoid>
/** Set the value of the reducer.
*
- * This function sets the initial value of the reducer’s accumulator
+ * This function sets the initial value of the reducer's accumulator
* variable to the value of @a obj.
*
* @note The behavior of a default constructor followed by
@@ -1380,8 +1459,8 @@ class reducer : public internal::reducer_content<Monoid>
* @note is not necessarily the same as a value constructor:
*
* reducer<Type> xr(x);
- *
- * @note In particular, when @a Type is a container type with a
+ *
+ * @note In particular, when @a Type is a container type with a
* non-empty allocator, the value constructor will create the
* accumulator variable with the same allocator as the input
* argument @a x, while the default constructor will create the
@@ -1391,7 +1470,7 @@ class reducer : public internal::reducer_content<Monoid>
* for a reduction will almost always result in undefined
* behavior.
*
- * @param obj The object containing the value that will be copied into
+ * @param obj The object containing the value that will be copied into
* the reducer.
*
* @post The reducer contains a copy of the value in @a obj.
@@ -1402,10 +1481,10 @@ class reducer : public internal::reducer_content<Monoid>
/** Get the value of the reducer.
*
- * This function gets the final value of the reducer’s accumulator
+ * This function gets the final value of the reducer's accumulator
* variable.
*
- * @warning Calling this function other than to retrieve the final
+ * @warning Calling this function other than to retrieve the final
* value of a reduction will almost always result in undefined
* behavior.
*
@@ -1413,9 +1492,9 @@ class reducer : public internal::reducer_content<Monoid>
*
* @see move_out()
*/
- typename set_get::get_value_type get_value() const
+ typename set_get::return_type_for_get_value get_value() const
{ return set_get::get_value(view()); }
-
+
//@}
/** Implicit downcast to legacy reducer wrapper, if any.
@@ -1452,137 +1531,148 @@ using stub::reducer;
/** @page page_reducers_in_c Creating and Using Reducers in C
*
* @tableofcontents
- *
- * The Cilk runtime supports reducers written in C as well as in C++. The basic logic is the
- * same, but the implementation details are very different. The C++ reducer implementation uses
- * templates heavily to create very generic components. The C reducer implementation uses
- * macros, which are a much blunter instrument. The most immediate consequence is that the
- * monoid/view/reducer architecture is mostly implicit rather than explicit in C reducers.
- *
+ *
+ * The Intel Cilk Plus runtime supports reducers written in C as well as in C++. The
+ * basic logic is the same, but the implementation details are very
+ * different. The C++ reducer implementation uses templates heavily to create
+ * very generic components. The C reducer implementation uses macros, which
+ * are a much blunter instrument. The most immediate consequence is that the
+ * monoid/view/reducer architecture is mostly implicit rather than explicit
+ * in C reducers.
+ *
* @section reducers_c_overview Overview of Using Reducers in C
- *
+ *
* The basic usage pattern for C reducers is:
- *
+ *
* 1. Create and initialize a reducer object.
- * 2. Tell the Cilk runtime about the reducer.
+ * 2. Tell the Intel Cilk Plus runtime about the reducer.
* 3. Update the value contained in the reducer in a parallel computation.
- * 4. Tell the Cilk runtime that you are done with the reducer.
+ * 4. Tell the Intel Cilk Plus runtime that you are done with the reducer.
* 5. Retrieve the value from the reducer.
- *
+ *
* @subsection reducers_c_creation Creating and Initializing a C Reducer
- *
+ *
* The basic pattern for creating and initializing a reducer object in C is
- *
+ *
* CILK_C_DECLARE_REDUCER(value-type) reducer-name =
* CILK_C_INIT_REDUCER(value-type,
* reduce-function,
* identity-function,
* destroy-function,
* initial-value);
- *
- * This is simply an initialized definition of a variable named _reducer-name_. The
- * @ref CILK_C_DECLARE_REDUCER macro expands to an anonymous `struct` declaration for a reducer
- * object containing a view of type _value-type_, and the @ref CILK_C_INIT_REDUCER macro
- * expands to a struct initializer.
- *
+ *
+ * This is simply an initialized definition of a variable named
+ * _reducer-name_. The @ref CILK_C_DECLARE_REDUCER macro expands to an
+ * anonymous `struct` declaration for a reducer object containing a view of
+ * type _value-type_, and the @ref CILK_C_INIT_REDUCER macro expands to a
+ * struct initializer.
+ *
* @subsection reducers_c_reduce_func Reduce Functions
- *
- * The reduce function for a reducer is called when a parallel execution strand terminates, to
- * combine the values computed by the terminating strand and the strand to its left. It takes
- * three arguments:
- *
- * - `void* reducer` — the address of the reducer.
- * - `void* left` — the address of the value for the left strand.
- * - `void* right` — the address of the value for the right (terminating) strand.
- *
- * It must apply the reducer’s reduction operation to the `left` and `right` values, leaving
- * the result in the `left` value. The `right` value is undefined after the reduce function
- * call.
- *
+ *
+ * The reduce function for a reducer is called when a parallel execution
+ * strand terminates, to combine the values computed by the terminating
+ * strand and the strand to its left. It takes three arguments:
+ *
+ * - `void* reducer` - the address of the reducer.
+ * - `void* left` - the address of the value for the left strand.
+ * - `void* right` - the address of the value for the right (terminating)
+ * strand.
+ *
+ * It must apply the reducer's reduction operation to the `left` and `right`
+ * values, leaving the result in the `left` value. The `right` value is
+ * undefined after the reduce function call.
+ *
* @subsection reducers_c_identity_func Identity Functions
- *
- * The identity function for a reducer is called when a parallel execution strand begins, to
- * initialize its value to the reducer’s identity value. It takes two arguments:
- *
- * - `void* reducer` — the address of the reducer.
- * - `void* v` — the address of a freshly allocated block of memory of size
+ *
+ * The identity function for a reducer is called when a parallel execution
+ * strand begins, to initialize its value to the reducer's identity value. It
+ * takes two arguments:
+ *
+ * - `void* reducer` - the address of the reducer.
+ * - `void* v` - the address of a freshly allocated block of memory of size
* `sizeof(value-type)`.
- *
- * It must initialize the memory pointed to by `v` so that it contains the reducer’s identity
- * value.
- *
+ *
+ * It must initialize the memory pointed to by `v` so that it contains the
+ * reducer's identity value.
+ *
* @subsection reducers_c_destroy_func Destroy Functions
- *
- * The destroy function for a reducer is called when a parallel execution strand terminates, to
- * do any necessary cleanup before its value is deallocated. It takes two arguments:
- *
- * - `void* reducer` — the address of the reducer.
- * - `void* p` — the address of the value for the terminating strand.
- *
- * It must release any resources belonging to the value pointed to by `p`, to avoid a resource
- * leak when the memory containing the value is deallocated.
- *
- * The runtime function `__cilkrts_hyperobject_noop_destroy` can be used for the destructor
- * function if the reducer’s values do not need any cleanup.
- *
- * @subsection reducers_c_register Tell the Cilk Runtime About the Reducer
- *
- * Call the @ref CILK_C_REGISTER_REDUCER macro to register the reducer with the Cilk runtime:
- *
+ *
+ * The destroy function for a reducer is called when a parallel execution
+ * strand terminates, to do any necessary cleanup before its value is
+ * deallocated. It takes two arguments:
+ *
+ * - `void* reducer` - the address of the reducer.
+ * - `void* p` - the address of the value for the terminating strand.
+ *
+ * It must release any resources belonging to the value pointed to by `p`, to
+ * avoid a resource leak when the memory containing the value is deallocated.
+ *
+ * The runtime function `__cilkrts_hyperobject_noop_destroy` can be used for
+ * the destructor function if the reducer's values do not need any cleanup.
+ *
+ * @subsection reducers_c_register Tell the Intel Cilk Plus Runtime About the
+ * Reducer
+ *
+ * Call the @ref CILK_C_REGISTER_REDUCER macro to register the reducer with
+ * the Intel Cilk Plus runtime:
+ *
* CILK_C_REGISTER_REDUCER(reducer-name);
- *
- * The runtime will manage reducer values for all registered reducers when parallel execution
- * strands begin and end.
- *
+ *
+ * The runtime will manage reducer values for all registered reducers when
+ * parallel execution strands begin and end.
+ *
* @subsection reducers_c_update Update the Value Contained in the Reducer
- *
- * The @ref REDUCER_VIEW macro returns a reference to the reducer’s value for the current
- * parallel strand:
- *
+ *
+ * The @ref REDUCER_VIEW macro returns a reference to the reducer's value for
+ * the current parallel strand:
+ *
* REDUCER_VIEW(reducer-name) = REDUCER_VIEW(reducer-name) OP x;
- *
- * C++ reducer views restrict access to the wrapped value so that it can only be modified in
- * ways consistent with the reducer’s operation. No such protection is provided for C reducers.
- * It is
- * entirely the responsibility of the user to avoid modifying the value in any
- * inappropriate way.
- *
- * @subsection c_reducers_unregister Tell the Cilk Runtime That You Are Done with the Reducer
- *
- * When the parallel computation is complete, call the @ref CILK_C_UNREGISTER_REDUCER macro to
- * unregister the reducer with the Cilk runtime:
- *
+ *
+ * C++ reducer views restrict access to the wrapped value so that it can only
+ * be modified in ways consistent with the reducer's operation. No such
+ * protection is provided for C reducers. It is entirely the responsibility
+ * of the user to avoid modifying the value in any inappropriate way.
+ *
+ * @subsection c_reducers_unregister Tell the Intel Cilk Plus Runtime That You Are
+ * Done with the Reducer
+ *
+ * When the parallel computation is complete, call the @ref
+ * CILK_C_UNREGISTER_REDUCER macro to unregister the reducer with the
+ * Intel Cilk Plus runtime:
+ *
* CILK_C_UNREGISTER_REDUCER(reducer-name);
- *
+ *
* The runtime will stop managing reducer values for the reducer.
- *
+ *
* @subsection c_reducers_retrieve Retrieve the Value from the Reducer
- *
- * When the parallel computation is complete, use the @ref REDUCER_VIEW macro to retrieve the
- * final value computed by the reducer.
- *
- * @subsection reducers_c_example_custom Example — Creating and Using a Custom C Reducer
- *
+ *
+ * When the parallel computation is complete, use the @ref REDUCER_VIEW macro
+ * to retrieve the final value computed by the reducer.
+ *
+ * @subsection reducers_c_example_custom Example - Creating and Using a
+ * Custom C Reducer
+ *
* The `IntList` type represents a simple list of integers.
- *
+ *
* struct _intListNode {
* int value;
* _intListNode* next;
* } IntListNode;
* typedef struct { IntListNode* head; IntListNode* tail; } IntList;
- *
+ *
* // Initialize a list to be empty
* void IntList_init(IntList* list) { list->head = list->tail = 0; }
- *
+ *
* // Append an integer to the list
- * void IntList_append(IntList* list, int x)
- * {
+ * void IntList_append(IntList* list, int x)
+ * {
* IntListNode* node = (IntListNode*) malloc(sizeof(IntListNode));
* if (list->tail) list->tail->next = node; else list->head = node;
* list->tail = node;
* }
- *
- * // Append the right list to the left list, and leave the right list empty
+ *
+ * // Append the right list to the left list, and leave the right list
+ * // empty
* void IntList_concat(IntList* left, IntList* right)
* {
* if (left->head) {
@@ -1594,19 +1684,20 @@ using stub::reducer;
* }
* IntList_init(*right);
* }
- *
- * This code creates a reducer that supports creating an `IntList` by appending values to it.
- *
+ *
+ * This code creates a reducer that supports creating an `IntList` by
+ * appending values to it.
+ *
* void identity_IntList(void* reducer, void* list)
* {
* IntList_init((IntList*)list);
* }
- *
+ *
* void reduce_IntList(void* reducer, void* left, void* right)
* {
* IntList_concat((IntList*)left, (IntList*)right);
* }
- *
+ *
* CILK_C_DECLARE_REDUCER(IntList) my_list_int_reducer =
* CILK_C_INIT_REDUCER(IntList,
* reduce_int_list,
@@ -1620,28 +1711,29 @@ using stub::reducer;
* IntList_append(&REDUCER_VIEW(my_int_list_reducer), a[i]);
* }
* CILK_C_UNREGISTER_REDUCER(my_int_list_reducer);
- *
+ *
* IntList result = REDUCER_VIEW(my_int_list_reducer);
*
* @section reducers_c_predefined Predefined C Reducers
*
- * Some of the predefined reducer classes in the Cilk library come with a set of predefined
- * macros to provide the same capabilities in C. In general, two macros are provided for each
- * predefined reducer family:
+ * Some of the predefined reducer classes in the Intel Cilk Plus library come with
+ * a set of predefined macros to provide the same capabilities in C.
+ * In general, two macros are provided for each predefined reducer family:
*
- * - `CILK_C_REDUCER_operation(reducer-name, type-name, initial-value)` — Declares a
- * reducer object named _reducer-name_ with initial value _initial-value_ to perform
- * a reduction using the _operation_ on values of the type specified by _type-name_.
- * This is the equivalent of the general code described in @ref reducers_c_creation :
+ * - `CILK_C_REDUCER_operation(reducer-name, type-name, initial-value)` -
+ * Declares a reducer object named _reducer-name_ with initial value
+ * _initial-value_ to perform a reduction using the _operation_ on values
+ * of the type specified by _type-name_. This is the equivalent of the
+ * general code described in @ref reducers_c_creation :
*
* CILK_C_DECLARE_REDUCER(type) reducer-name =
* CILK_C_INIT_REDUCER(type, ..., initial-value);
*
- * where _type_ is the C type corresponding to _type_name_. See @ref reducers_c_type_names
- * below for the _type-names_ that you can use.
+ * where _type_ is the C type corresponding to _type_name_. See @ref
+ * reducers_c_type_names below for the _type-names_ that you can use.
*
- * - `CILK_C_REDUCER_operation_TYPE(type-name)` — Expands to the `typedef` name for the type
- * of the reducer object declared by
+ * - `CILK_C_REDUCER_operation_TYPE(type-name)` - Expands to the `typedef`
+ * name for the type of the reducer object declared by
* `CILK_C_REDUCER_operation(reducer-name, type-name, initial-value)`.
*
* See @ref reducers_c_example_predefined.
@@ -1651,22 +1743,23 @@ using stub::reducer;
* | Operation | Name | Documentation |
* |-------------------|---------------|-------------------------------|
* | addition | `OPADD` | @ref ReducersAdd |
- * | bitwise and | `OPAND` | @ref ReducersAnd |
- * | bitwise or | `OPOR` | @ref ReducersOr |
- * | bitwise xor | `OPXOR` | @ref ReducersXor |
+ * | bitwise AND | `OPAND` | @ref ReducersAnd |
+ * | bitwise OR | `OPOR` | @ref ReducersOr |
+ * | bitwise XOR | `OPXOR` | @ref ReducersXor |
* | multiplication | `OPMUL` | @ref ReducersMul |
* | minimum | `MIN` | @ref ReducersMinMax |
* | minimum & index | `MIN_INDEX` | @ref ReducersMinMax |
- * | maximum | `MIN` | @ref ReducersMinMax |
- * | maximum & index | `MIN_INDEX` | @ref ReducersMinMax |
- *
+ * | maximum | `MAX` | @ref ReducersMinMax |
+ * | maximum & index | `MAX_INDEX` | @ref ReducersMinMax |
+ *
* @subsection reducers_c_type_names Numeric Type Names
- *
- * The type and function names created by the C reducer definition macros incorporate both the
- * reducer kind (`opadd`, `opxor`, etc.) and the value type of the reducer (`int`, `double`,
- * etc.). The value type is represented by a _numeric type name_ string. The types supported
- * in C reducers, and their corresponding numeric type names, are given in the following table:
- *
+ *
+ * The type and function names created by the C reducer definition macros
+ * incorporate both the reducer kind (`opadd`, `opxor`, etc.) and the value
+ * type of the reducer (`int`, `double`, etc.). The value type is represented
+ * by a _numeric type name_ string. The types supported in C reducers, and
+ * their corresponding numeric type names, are given in the following table:
+ *
* | Type | Numeric Type Name |
* |-----------------------|-------------------------------|
* | `char` | `char` |
@@ -1685,8 +1778,9 @@ using stub::reducer;
* | `float` | `float` |
* | `double` | `double` |
* | `long double` | `longdouble` |
- *
- * @subsection reducers_c_example_predefined Example — Using a Predefined C Reducer
+ *
+ * @subsection reducers_c_example_predefined Example - Using a Predefined C
+ * Reducer
*
* To compute the sum of all the values in an array of `unsigned int`:
*
@@ -1699,7 +1793,7 @@ using stub::reducer;
* printf("The sum is %u\n", REDUCER_VIEW(sum));
*/
-
+
/** @name C language reducer macros
*
* These macros are used to declare and work with reducers in C code.
@@ -1712,7 +1806,8 @@ using stub::reducer;
/** @name Compound identifier macros.
*
- * These macros are used to construct an identifier by concatenating two or three identifiers.
+ * These macros are used to construct an identifier by concatenating two or
+ * three identifiers.
*/
//@{
@@ -1730,7 +1825,7 @@ using stub::reducer;
//@}
-/** Compiler-specific keyword for the “type of” operator.
+/** Compiler-specific keyword for the "type of" operator.
*/
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
# define _Typeof __typeof__
@@ -1738,15 +1833,16 @@ using stub::reducer;
/** @name Predefined reducer function declaration macros.
*
- * These macros are used to create the function headers for the identity, reduction,
- * and destructor functions for a builtin reducer family. The macro can be followed by
- * a semicolon to create a declaration, or by a brace-enclosed body to create a definition.
+ * These macros are used to create the function headers for the identity,
+ * reduction, and destructor functions for a builtin reducer family. The
+ * macro can be followed by a semicolon to create a declaration, or by a
+ * brace-enclosed body to create a definition.
*/
//@{
/** Create an identity function header.
*
- * @note The name of the function’s value pointer parameter will always be `v`.
+ * @note The name of the function's value pointer parameter will always be `v`.
*
* @param name The reducer family name.
* @param tn The type name.
@@ -1758,8 +1854,9 @@ using stub::reducer;
*
* @param name The reducer family name.
* @param tn The type name.
- * @param l The name to use for the function’s left value pointer parameter.
- * @param r The name to use for the function’s right value pointer parameter.
+ * @param l The name to use for the function's left value pointer parameter.
+ * @param r The name to use for the function's right value pointer
+ * parameter.
*/
#define __CILKRTS_DECLARE_REDUCER_REDUCE(name,tn,l,r) CILK_EXPORT \
void __CILKRTS_MKIDENT3(name,_reduce_,tn)(void* key, void* l, void* r)
@@ -1768,7 +1865,7 @@ using stub::reducer;
*
* @param name The reducer family name.
* @param tn The type name.
- * @param p The name to use for the function’s value pointer parameter.
+ * @param p The name to use for the function's value pointer parameter.
*/
#define __CILKRTS_DECLARE_REDUCER_DESTROY(name,tn,p) CILK_EXPORT \
void __CILKRTS_MKIDENT3(name,_destroy_,tn)(void* key, void* p)
@@ -1784,8 +1881,8 @@ using stub::reducer;
/** Declaration of a C reducer structure type.
*
- * This macro expands into an anonymous structure declaration for a C reducer structure
- * which contains a @a Type value. For example:
+ * This macro expands into an anonymous structure declaration for a C reducer
+ * structure which contains a @a Type value. For example:
*
* CILK_C_DECLARE_REDUCER(int) my_add_int_reducer =
* CILK_C_INIT_REDUCER(int, …);
@@ -1801,27 +1898,30 @@ using stub::reducer;
/** Initializer for a C reducer structure.
*
- * This macro expands into a brace-enclosed structure initializer for a C reducer structure
- * that was declared with `CILK_C_DECLARE_REDUCER(Type)`. For example:
+ * This macro expands into a brace-enclosed structure initializer for a C
+ * reducer structure that was declared with
+ * `CILK_C_DECLARE_REDUCER(Type)`. For example:
*
* CILK_C_DECLARE_REDUCER(int) my_add_int_reducer =
- * CILK_C_INIT_REDUCER(int,
- * add_int_reduce,
- * add_int_identity,
+ * CILK_C_INIT_REDUCER(int,
+ * add_int_reduce,
+ * add_int_identity,
* __cilkrts_hyperobject_noop_destroy,
* 0);
*
- * @param Type The type of the value contained in the reducer object. Must be the same as
- * the @a Type argument of the CILK_C_DECLARE_REDUCER macro call that created
- * the reducer.
- * @param Reduce The address of the @ref reducers_c_reduce_func "reduce function" for the
+ * @param Type The type of the value contained in the reducer object. Must
+ * be the same as the @a Type argument of the
+ * CILK_C_DECLARE_REDUCER macro call that created the
* reducer.
- * @param Identity The address of the @ref reducers_c_identity_func "identity function" for
- * the reducer.
- * @param Destroy The address of the @ref reducers_c_destroy_func "destroy function" for the
- * reducer.
- * @param ... The initial value for the reducer. (A single expression if @a Type is a
- * scalar type; a list of values if @a Type is a struct or array type.)
+ * @param Reduce The address of the @ref reducers_c_reduce_func
+ * "reduce function" for the reducer.
+ * @param Identity The address of the @ref reducers_c_identity_func
+ * "identity function" for the reducer.
+ * @param Destroy The address of the @ref reducers_c_destroy_func
+ * "destroy function" for the reducer.
+ * @param ... The initial value for the reducer. (A single expression if
+ * @a Type is a scalar type; a list of values if @a Type is a
+ * struct or array type.)
*
* @see @ref reducers_c_creation
*/
@@ -1840,10 +1940,10 @@ using stub::reducer;
, __VA_ARGS__ \
}
-/** Register a reducer with the Cilk runtime.
+/** Register a reducer with the Intel Cilk Plus runtime.
*
- * The runtime will manage reducer values for all registered reducers when parallel execution
- * strands begin and end. For example:
+ * The runtime will manage reducer values for all registered reducers when
+ * parallel execution strands begin and end. For example:
*
* CILK_C_REGISTER_REDUCER(my_add_int_reducer);
* cilk_for (int i = 0; i != n; ++i) {
@@ -1857,10 +1957,10 @@ using stub::reducer;
#define CILK_C_REGISTER_REDUCER(Expr) \
__cilkrts_hyper_create(&(Expr).__cilkrts_hyperbase)
-/** Unregister a reducer with the Cilk runtime.
+/** Unregister a reducer with the Intel Cilk Plus runtime.
*
- * The runtime will stop managing reducer values for a reducer after it is unregistered. For
- * example:
+ * The runtime will stop managing reducer values for a reducer after it is
+ * unregistered. For example:
*
* cilk_for (int i = 0; i != n; ++i) {
* …
@@ -1876,17 +1976,19 @@ using stub::reducer;
/** Get the current view for a reducer.
*
- * The `REDUCER_VIEW(reducer-name)` returns a reference to the reducer’s value for the
- * current parallel strand. This can be used to initialize thevalue of the reducer before it
- * is used, to modify the value of the reducer on the current parallel strand, or to retrieve
- * the final value of the reducer at the end of the parallel computation.
+ * The `REDUCER_VIEW(reducer-name)` returns a reference to the reducer's
+ * value for the current parallel strand. This can be used to initialize the
+ * value of the reducer before it is used, to modify the value of the reducer
+ * on the current parallel strand, or to retrieve the final value of the
+ * reducer at the end of the parallel computation.
*
* REDUCER_VIEW(my_add_int_reducer) = REDUCER_VIEW(my_add_int_reducer) + x;
*
- * @note C++ reducer views restrict access to the wrapped value so that it can only be
- * modified in ways consistent with the reducer’s operation. No such protection is provided
- * for C reducers. It is entirely the responsibility of the user to refrain from modifying the
- * value in any inappropriate way.
+ * @note C++ reducer views restrict access to the wrapped value so that it
+ * can only be modified in ways consistent with the reducer's operation. No
+ * such protection is provided for C reducers. It is entirely the
+ * responsibility of the user to refrain from modifying the value in any
+ * inappropriate way.
*
* @param Expr The reducer whose value is to be returned.
*
diff --git a/libcilkrts/include/cilk/reducer_file.h b/libcilkrts/include/cilk/reducer_file.h
index 75af994e9d4..a372cee7cda 100644
--- a/libcilkrts/include/cilk/reducer_file.h
+++ b/libcilkrts/include/cilk/reducer_file.h
@@ -1,9 +1,7 @@
/*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -18,7 +16,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
@@ -31,6 +28,20 @@
* 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.
*
*/
diff --git a/libcilkrts/include/cilk/reducer_list.h b/libcilkrts/include/cilk/reducer_list.h
index fc0be1e03d3..80204af1d9e 100644
--- a/libcilkrts/include/cilk/reducer_list.h
+++ b/libcilkrts/include/cilk/reducer_list.h
@@ -1,10 +1,8 @@
/* reducer_list.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,12 +29,26 @@
* 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.
*/
/** @file reducer_list.h
*
- * @brief Defines classes for doing parallel list creation by appending or
- * prepending.
+ * @brief Defines classes for parallel list creation by appending or
+ * prepending reducers.
*
* @ingroup ReducersList
*
@@ -52,19 +63,19 @@
/** @defgroup ReducersList List Reducers
*
- * List append and prepend reducers allow the creation of a standard list by
+ * List-append and list-prepend reducers create standard lists by
* concatenating a set of lists or values in parallel.
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file `reducers.md`, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers"
+ * (from file `reducers.md`) and particularly with @ref reducers_using, before
+ * trying to use the information in this file.
*
* @section redlist_usage Usage Example
*
* // Create a list containing the labels of the nodes of a tree in
- * // “inorder” (left subtree, root, right subtree).
+ * // "inorder" (left subtree, root, right subtree).
*
* struct Tree { Tree* left; Tree* right; string label; ... };
*
@@ -72,8 +83,8 @@
* cilk::reducer< cilk::op_list_append<string> > xr(cilk::move_in(x));
* collect_labels(tree, xr);
* xr.move_out(x);
- *
- * void collect_labels(Tree* node,
+ *
+ * void collect_labels(Tree* node,
* cilk::reducer< cilk::op_list_append<string> >& xr)
* {
* if (node) {
@@ -88,39 +99,39 @@
*
* @subsection redlist_monoid_values Value Set
*
- * The value set of a list reducer is the set of values of the class
- * `std::list<Type, Allocator>`, which we refer to as “the reducer’s list
- * type”.
+ * The __value set__ of a list reducer is the set of values of the class
+ * `std::list<Type, Allocator>`, which we refer to as the reducer's _list
+ * type_.
*
* @subsection redlist_monoid_operator Operator
*
- * The operator of a list append reducer is defined as
+ * The operator of a list-append reducer is defined as
*
* x CAT y == (every element of x, followed by every element of y)
*
- * The operator of a list prepend reducer is defined as
+ * The operator of a list-prepend reducer is defined as
*
* x RCAT y == (every element of y, followed by every element of x)
*
* @subsection redlist_monoid_identity Identity
*
- * The identity value of a list reducer is the empty list, which is the value
+ * The identity value of a list reducer is the empty list, which is the value
* of the expression `std::list<Type, Allocator>([allocator])`.
*
* @section redlist_operations Operations
*
- * In the operation descriptions below, the type name `List` refers to the
- * reducer’s string type, `std::list<Type, Allocator>`.
+ * In the operation descriptions below, the type name `List` refers to the
+ * reducer's string type, `std::list<Type, Allocator>`.
*
* @subsection redlist_constructors Constructors
*
- * Any argument list which is valid for a `std::list` constructor is valid for
+ * Any argument list which is valid for a `std::list` constructor is valid for
* a list reducer constructor. The usual move-in constructor is also provided:
*
* reducer(move_in(List& variable))
*
- * A list reducer with no constructor arguments, or with only an allocator
- * argument, will initially contain the identity value, an empty list.
+ * A list reducer with no constructor arguments, or with only an allocator
+ * argument, will initially contain the identity value, an empty list.
*
* @subsection redlist_get_set Set and Get
*
@@ -131,19 +142,19 @@
*
* @subsection redlist_view_ops View Operations
*
- * The view of a list append reducer provides the following member functions:
+ * The view of a list-append reducer provides the following member functions:
*
- * void push_back(const Type& element)
- * void insert_back(List::size_type n, const Type& element)
+ * void push_back(const Type& element)
+ * void insert_back(List::size_type n, const Type& element)
* template <typename Iter> void insert_back(Iter first, Iter last)
* void splice_back(List& x)
* void splice_back(List& x, List::iterator i)
* void splice_back(List& x, List::iterator first, List::iterator last)
- *
- * The view of a list prepend reducer provides the following member functions:
*
- * void push_front(const Type& element)
- * void insert_front(List::size_type n, const Type& element)
+ * The view of a list-prepend reducer provides the following member functions:
+ *
+ * void push_front(const Type& element)
+ * void insert_front(List::size_type n, const Type& element)
* template <typename Iter> void insert_front(Iter first, Iter last)
* void splice_front(List& x)
* void splice_front(List& x, List::iterator i)
@@ -151,26 +162,26 @@
*
* The `push_back` and `push_front` functions are the same as the
* corresponding `std::list` functions. The `insert_back`, `splice_back`,
- * `insert_front`, and `splice_front` functions are the same as the
+ * `insert_front`, and `splice_front` functions are the same as the
* `std::list` `insert` and `splice` functions, with the first parameter
* fixed to the end or beginning of the list, respectively.
*
* @section redlist_performance Performance Considerations
*
- * An efficient reducer requires that combining the values of two views (using
+ * An efficient reducer requires that combining the values of two views (using
* the view `reduce()` function) be a constant-time operations. Two lists can
* be merged in constant time using the `splice()` function if they have the
* same allocator. Therefore, the lists for new views are created (by the view
* identity constructor) using the same allocator as the list that was created
* when the reducer was constructed.
*
- * The performance of adding elements to a list reducer depends on the view
+ * The performance of adding elements to a list reducer depends on the view
* operations that are used:
*
* * The `push` functions add a single element to the list, and therefore
* take constant time.
* * An `insert` function that inserts _N_ elements adds each of them
- * individually, and therefore takes _O(N)_ time.
+ * individually, and therefore takes _O(N)_ time.
* * A `splice` function that inserts _N_ elements just adjusts a couple of
* pointers, and therefore takes constant time, _if the splice is from a
* list with the same allocator as the reducer_. Otherwise, it is
@@ -183,7 +194,7 @@
* The reducer `move_in` and `move_out` functions do a constant-time `swap` if
* the variable has the same allocator as the reducer, and a linear-time copy
* otherwise.
- *
+ *
* Note that the allocator of a list reducer is determined when the reducer is
* constructed. The following two examples may have very different behavior:
*
@@ -199,16 +210,16 @@
* reducer2.move_out(a_list);
*
* * `reducer1` will be constructed with the same allocator as `a_list`,
- * because the list was was specified in the constructor. The `move_in`
- * and`move_out` can therefore be done with a `swap` in constant time.
+ * because the list was specified in the constructor. The `move_in`
+ * and `move_out` can therefore be done with a `swap` in constant time.
* * `reducer2` will be constructed with a _default_ allocator,
- * “`Allocator()`”, which may or may not be the same as the allocator of
+ * "`Allocator()`", which may or may not be the same as the allocator of
* `a_list`. Therefore, the `move_in` and `move_out` may have to be done
* with a copy in _O(N)_ time.
- *
+ *
* (All instances of an allocator type with no internal state (like
- * `std::allocator`) are “the same”. You only need to worry about the “same
- * allocator” issue when you create list reducers with custom allocator types.)
+ * `std::allocator`) are "the same". You only need to worry about the "same
+ * allocator" issue when you create list reducers with custom allocator types.)
*
* @section redlist_types Type and Operator Requirements
*
@@ -223,11 +234,11 @@ namespace internal {
/** @ingroup ReducersList */
//@{
-/** Base class for list append and prepend view classes.
+/** Base class for list-append and prepend view classes.
*
* @note This class provides the definitions that are required for a class
* that will be used as the parameter of a @ref list_monoid_base
- * specialization.
+ * specialization.
*
* @tparam Type The list element type (not the list type).
* @tparam Allocator The list's allocator class.
@@ -250,31 +261,31 @@ public:
/** @name Monoid support.
*/
//@{
-
+
/// Required by @ref monoid_with_view
typedef list_type value_type;
/// Required by @ref list_monoid_base
Allocator get_allocator() const
- {
- return m_value.get_allocator();
+ {
+ return m_value.get_allocator();
}
-
+
//@}
-
-
+
+
/** @name Constructors.
*/
//@{
-
+
/// Standard list constructor.
explicit list_view_base(const Allocator& a = Allocator()) : m_value(a) {}
explicit list_view_base(
- typename list_type::size_type n,
- const Type& value = Type(),
+ typename list_type::size_type n,
+ const Type& value = Type(),
const Allocator& a = Allocator() ) : m_value(n, value, a) {}
- template <typename Iter>
- list_view_base(Iter first, Iter last, const Allocator& a = Allocator()) :
+ template <typename Iter>
+ list_view_base(Iter first, Iter last, const Allocator& a = Allocator()) :
m_value(first, last, a) {}
list_view_base(const list_type& list) : m_value(list) {}
@@ -284,13 +295,13 @@ public:
{
m_value.swap(w.value());
}
-
+
//@}
-
+
/** @name Reducer support.
*/
//@{
-
+
/// Required by reducer::move_in()
void view_move_in(value_type& v)
{
@@ -302,7 +313,7 @@ public:
m_value = v;
v.clear();
}
-
+
/// Required by reducer::move_out()
void view_move_out(value_type& v)
{
@@ -314,43 +325,46 @@ public:
v = m_value;
m_value.clear();
}
-
+
/// Required by reducer::set_value()
void view_set_value(const value_type& v) { m_value = v; }
/// Required by reducer::get_value()
value_type const& view_get_value() const { return m_value; }
-
+
+ /// Type returned by view_get_value.
+ typedef value_type const& return_type_for_get_value;
+
// Required by legacy wrapper get_reference()
value_type & view_get_reference() { return m_value; }
value_type const& view_get_reference() const { return m_value; }
-
+
//@}
};
-/** Base class for list append and prepend monoid classes.
+/** Base class for list-append and prepend monoid classes.
*
* The key to efficient reducers is that the `identity` operation, which
* creates a new per-strand view, and the `reduce` operation, which combines
* two per-strand views, must be constant-time operations. Two lists can be
* concatenated in constant time only if they have the same allocator.
* Therefore, all the per-strand list accumulator variables must be created
- * with the same allocator as the leftmost view list.
+ * with the same allocator as the leftmost view list.
*
* This means that a list reduction monoid must have a copy of the allocator
- * of the leftmost view’s list, so that it can use it in the `identity`
+ * of the leftmost view's list, so that it can use it in the `identity`
* operation. This, in turn, requires that list reduction monoids have a
* specialized `construct()` function, which constructs the leftmost view
- * before the monoid, and then passes the leftmost view’s allocator to the
+ * before the monoid, and then passes the leftmost view's allocator to the
* monoid constructor.
*
- * @tparam View The list append or prepend view class.
+ * @tparam View The list-append or prepend view class.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersList
* @see list_view_base
@@ -360,15 +374,15 @@ class list_monoid_base : public monoid_with_view<View, Align>
{
typedef typename View::value_type list_type;
typedef typename list_type::allocator_type allocator_type;
+ typedef provisional_guard<View> view_guard;
+
allocator_type m_allocator;
-
- using monoid_base<list_type, View>::provisional;
-
+
public:
/** Constructor.
*
- * There is no default constructor for list monoids, because the allocator
+ * There is no default constructor for list monoids, because the allocator
* must always be specified.
*
* @param allocator The list allocator to be used when
@@ -377,7 +391,7 @@ public:
list_monoid_base(const allocator_type& allocator = allocator_type()) :
m_allocator(allocator) {}
- /** Create an identity view.
+ /** Creates an identity view.
*
* List view identity constructors take the list allocator as an argument.
*
@@ -385,12 +399,12 @@ public:
* will be constructed.
*/
void identity(View *v) const { ::new((void*) v) View(m_allocator); }
-
+
/** @name construct functions
*
- * All `construct()` functions first construct the leftmost view, using
+ * All `construct()` functions first construct the leftmost view, using
* the optional @a x1, @a x2, and @a x3 arguments that were passed in from
- * the reducer constructor. They then call the view’s `get_allocator()`
+ * the reducer constructor. They then call the view's `get_allocator()`
* function to get the list allocator from its contained list, and pass it
* to the monoid constructor.
*/
@@ -398,24 +412,33 @@ public:
template <typename Monoid>
static void construct(Monoid* monoid, View* view)
- { provisional( new ((void*)view) View() ).confirm_if(
- new ((void*)monoid) Monoid(view->get_allocator()) ); }
+ {
+ view_guard vg( new((void*) view) View() );
+ vg.confirm_if( new((void*) monoid) Monoid(view->get_allocator()) );
+ }
template <typename Monoid, typename T1>
static void construct(Monoid* monoid, View* view, const T1& x1)
- { provisional( new ((void*)view) View(x1) ).confirm_if(
- new ((void*)monoid) Monoid(view->get_allocator()) ); }
+ {
+ view_guard vg( new((void*) view) View(x1) );
+ vg.confirm_if( new((void*) monoid) Monoid(view->get_allocator()) );
+ }
template <typename Monoid, typename T1, typename T2>
- static void construct(Monoid* monoid, View* view, const T1& x1, const T2& x2)
- { provisional( new ((void*)view) View(x1, x2) ).confirm_if(
- new ((void*)monoid) Monoid(view->get_allocator()) ); }
+ static void construct(Monoid* monoid, View* view,
+ const T1& x1, const T2& x2)
+ {
+ view_guard vg( new((void*) view) View(x1, x2) );
+ vg.confirm_if( new((void*) monoid) Monoid(view->get_allocator()) );
+ }
template <typename Monoid, typename T1, typename T2, typename T3>
- static void construct(Monoid* monoid, View* view, const T1& x1, const T2& x2,
- const T3& x3)
- { provisional( new ((void*)view) View(x1, x2, x3) ).confirm_if(
- new ((void*)monoid) Monoid(view->get_allocator()) ); }
+ static void construct(Monoid* monoid, View* view,
+ const T1& x1, const T2& x2, const T3& x3)
+ {
+ view_guard vg( new((void*) view) View(x1, x2, x3) );
+ vg.confirm_if( new((void*) monoid) Monoid(view->get_allocator()) );
+ }
//@}
};
@@ -428,17 +451,17 @@ public:
/** @ingroup ReducersList */
//@{
-/** The list append reducer view class.
+/** The list-append reducer view class.
*
- * This is the view class for reducers created with
+ * This is the view class for reducers created with
* `cilk::reducer< cilk::op_list_append<Type, Allocator> >`. It holds the
* accumulator variable for the reduction, and allows only append operations
* to be performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `push_back` operation would be used in an expression like
- * `r->push_back(a)`, where `r` is a list append reducer variable.
+ * `r->push_back(a)`, where `r` is a list-append reducer variable.
*
* @tparam Type The list element type (not the list type).
* @tparam Allocator The list allocator type.
@@ -446,14 +469,14 @@ public:
* @see ReducersList
* @see op_list_append
*/
-template <class Type,
+template <class Type,
class Allocator = typename std::list<Type>::allocator_type>
class op_list_append_view : public internal::list_view_base<Type, Allocator>
{
typedef internal::list_view_base<Type, Allocator> base;
typedef std::list<Type, Allocator> list_type;
typedef typename list_type::iterator iterator;
-
+
iterator end() { return this->m_value.end(); }
public:
@@ -467,40 +490,40 @@ public:
* forms, as well as the reducer move_in constructor form.
*/
//@{
-
+
op_list_append_view() : base() {}
-
+
template <typename T1>
op_list_append_view(const T1& x1) : base(x1) {}
-
+
template <typename T1, typename T2>
op_list_append_view(const T1& x1, const T2& x2) : base(x1, x2) {}
-
+
template <typename T1, typename T2, typename T3>
- op_list_append_view(const T1& x1, const T2& x2, const T3& x3) :
+ op_list_append_view(const T1& x1, const T2& x2, const T3& x3) :
base(x1, x2, x3) {}
- //@}
+ //@}
/** @name View modifier operations.
*/
//@{
-
- /** Add an element at the end of the list.
+
+ /** Adds an element at the end of the list.
*
* This is equivalent to `list.push_back(element)`
*/
- void push_back(const Type& element)
+ void push_back(const Type& element)
{ this->m_value.push_back(element); }
- /** Insert elements at the end of the list.
+ /** Inserts elements at the end of the list.
*
* This is equivalent to `list.insert(list.end(), n, element)`
*/
- void insert_back(typename list_type::size_type n, const Type& element)
+ void insert_back(typename list_type::size_type n, const Type& element)
{ this->m_value.insert(end(), n, element); }
- /** Insert elements at the end of the list.
+ /** Inserts elements at the end of the list.
*
* This is equivalent to `list.insert(list.end(), first, last)`
*/
@@ -508,7 +531,7 @@ public:
void insert_back(Iter first, Iter last)
{ this->m_value.insert(end(), first, last); }
- /** Splice elements at the end of the list.
+ /** Splices elements at the end of the list.
*
* This is equivalent to `list.splice(list.end(), x)`
*/
@@ -521,7 +544,7 @@ public:
}
}
- /** Splice elements at the end of the list.
+ /** Splices elements at the end of the list.
*
* This is equivalent to `list.splice(list.end(), x, i)`
*/
@@ -534,7 +557,7 @@ public:
}
}
- /** Splice elements at the end of the list.
+ /** Splices elements at the end of the list.
*
* This is equivalent to `list.splice(list.end(), x, first, last)`
*/
@@ -546,14 +569,14 @@ public:
x.erase(first, last);
}
}
-
+
//@}
- /** Reduction operation.
+ /** Reduces the views of two strands.
*
* This function is invoked by the @ref op_list_append monoid to combine
- * the views of two strands when the right strand merges with the left
- * one. It appends the value contained in the right-strand view to the
+ * the views of two strands when the right strand merges with the left
+ * one. It appends the value contained in the right-strand view to the
* value contained in the left-strand view, and leaves the value in the
* right-strand view undefined.
*
@@ -572,17 +595,17 @@ public:
};
-/** The list prepend reducer view class.
+/** The list-prepend reducer view class.
*
- * This is the view class for reducers created with
+ * This is the view class for reducers created with
* `cilk::reducer< cilk::op_list_prepend<Type, Allocator> >`. It holds the
* accumulator variable for the reduction, and allows only prepend operations
* to be performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `push_front` operation would be used in an expression like
- * `r->push_front(a)`, where `r` is a list prepend reducer variable.
+ * `r->push_front(a)`, where `r` is a list-prepend reducer variable.
*
* @tparam Type The list element type (not the list type).
* @tparam Allocator The list allocator type.
@@ -590,14 +613,14 @@ public:
* @see ReducersList
* @see op_list_prepend
*/
-template <class Type,
+template <class Type,
class Allocator = typename std::list<Type>::allocator_type>
class op_list_prepend_view : public internal::list_view_base<Type, Allocator>
{
typedef internal::list_view_base<Type, Allocator> base;
typedef std::list<Type, Allocator> list_type;
typedef typename list_type::iterator iterator;
-
+
iterator begin() { return this->m_value.begin(); }
public:
@@ -612,40 +635,40 @@ public:
*
*/
//@{
-
+
op_list_prepend_view() : base() {}
-
+
template <typename T1>
op_list_prepend_view(const T1& x1) : base(x1) {}
-
+
template <typename T1, typename T2>
op_list_prepend_view(const T1& x1, const T2& x2) : base(x1, x2) {}
-
+
template <typename T1, typename T2, typename T3>
- op_list_prepend_view(const T1& x1, const T2& x2, const T3& x3) :
+ op_list_prepend_view(const T1& x1, const T2& x2, const T3& x3) :
base(x1, x2, x3) {}
- //@}
+ //@}
/** @name View modifier operations.
*/
//@{
-
- /** Add an element at the beginning of the list.
+
+ /** Adds an element at the beginning of the list.
*
* This is equivalent to `list.push_front(element)`
*/
- void push_front(const Type& element)
+ void push_front(const Type& element)
{ this->m_value.push_front(element); }
- /** Insert elements at the beginning of the list.
+ /** Inserts elements at the beginning of the list.
*
* This is equivalent to `list.insert(list.begin(), n, element)`
*/
- void insert_front(typename list_type::size_type n, const Type& element)
+ void insert_front(typename list_type::size_type n, const Type& element)
{ this->m_value.insert(begin(), n, element); }
- /** Insert elements at the beginning of the list.
+ /** Inserts elements at the beginning of the list.
*
* This is equivalent to `list.insert(list.begin(), first, last)`
*/
@@ -653,7 +676,7 @@ public:
void insert_front(Iter first, Iter last)
{ this->m_value.insert(begin(), first, last); }
- /** Splice elements at the beginning of the list.
+ /** Splices elements at the beginning of the list.
*
* This is equivalent to `list.splice(list.begin(), x)`
*/
@@ -666,7 +689,7 @@ public:
}
}
- /** Splice elements at the beginning of the list.
+ /** Splices elements at the beginning of the list.
*
* This is equivalent to `list.splice(list.begin(), x, i)`
*/
@@ -679,7 +702,7 @@ public:
}
}
- /** Splice elements at the beginning of the list.
+ /** Splices elements at the beginning of the list.
*
* This is equivalent to `list.splice(list.begin(), x, first, last)`
*/
@@ -691,14 +714,14 @@ public:
x.erase(first, last);
}
}
-
+
//@}
- /** Reduction operation.
+ /** Reduces the views of two strands.
*
* This function is invoked by the @ref op_list_prepend monoid to combine
- * the views of two strands when the right strand merges with the left
- * one. It prepends the value contained in the right-strand view to the
+ * the views of two strands when the right strand merges with the left
+ * one. It prepends the value contained in the right-strand view to the
* value contained in the left-strand view, and leaves the value in the
* right-strand view undefined.
*
@@ -722,8 +745,8 @@ public:
-/** Monoid class for list append reductions. Instantiate the cilk::reducer
- * template class with a op_list_append monoid to create a list append reducer
+/** Monoid class for list-append reductions. Instantiate the cilk::reducer
+ * template class with a op_list_append monoid to create a list-append reducer
* class. For example, to create a list of strings:
*
* cilk::reducer< cilk::op_list_append<std::string> > r;
@@ -731,29 +754,29 @@ public:
* @tparam Type The list element type (not the list type).
* @tparam Alloc The list allocator type.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersList
* @see op_list_append_view
*/
-template <typename Type,
+template <typename Type,
typename Allocator = typename std::list<Type>::allocator_type,
bool Align = false>
-struct op_list_append :
- public internal::list_monoid_base<op_list_append_view<Type, Allocator>, Align>
+struct op_list_append :
+ public internal::list_monoid_base<op_list_append_view<Type, Allocator>, Align>
{
/// Construct with default allocator.
op_list_append() {}
/// Construct with specified allocator.
- op_list_append(const Allocator& alloc) :
+ op_list_append(const Allocator& alloc) :
internal::list_monoid_base<op_list_append_view<Type, Allocator>, Align>(alloc) {}
};
-/** Monoid class for list prepend reductions. Instantiate the cilk::reducer
- * template class with a op_list_prepend monoid to create a list prepend
+/** Monoid class for list-prepend reductions. Instantiate the cilk::reducer
+ * template class with a op_list_prepend monoid to create a list-prepend
* reducer class. For example, to create a list of strings:
*
* cilk::reducer< cilk::op_list_prepend<std::string> > r;
@@ -761,45 +784,45 @@ struct op_list_append :
* @tparam Type The list element type (not the list type).
* @tparam Alloc The list allocator type.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersList
* @see op_list_prepend_view
*/
-template <typename Type,
+template <typename Type,
typename Allocator = typename std::list<Type>::allocator_type,
bool Align = false>
-struct op_list_prepend :
- public internal::list_monoid_base<op_list_prepend_view<Type, Allocator>, Align>
+struct op_list_prepend :
+ public internal::list_monoid_base<op_list_prepend_view<Type, Allocator>, Align>
{
/// Construct with default allocator.
op_list_prepend() {}
/// Construct with specified allocator.
- op_list_prepend(const Allocator& alloc) :
+ op_list_prepend(const Allocator& alloc) :
internal::list_monoid_base<op_list_prepend_view<Type, Allocator>, Align>(alloc) {}
};
-/** Deprecated list append reducer wrapper class.
+/** Deprecated list-append reducer wrapper class.
*
- * reducer_list_append is the same as
+ * reducer_list_append is the same as
* @ref reducer<@ref op_list_append>, except that reducer_list_append is a
- * proxy for the contained view, so that accumulator variable update
+ * proxy for the contained view, so that accumulator variable update
* operations can be applied directly to the reducer. For example, an element
* is appended to a `reducer<%op_list_append>` with `r->push_back(a)`, but an
* element can be appended to a `%reducer_list_append` with `r.push_back(a)`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_list_append.
+ * reducers rather than the old wrappers like reducer_list_append.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_list_append`
+ * @note Implicit conversions are provided between `%reducer_list_append`
* and `reducer<%op_list_append>`. This allows incremental code
* conversion: old code that used `%reducer_list_append` can pass a
* `%reducer_list_append` to a converted function that now expects a
@@ -814,20 +837,20 @@ struct op_list_prepend :
* @see ReducersList
*/
template <class Type, class Allocator = std::allocator<Type> >
-class reducer_list_append :
+class reducer_list_append :
public reducer<op_list_append<Type, Allocator, true> >
{
typedef reducer<op_list_append<Type, Allocator, true> > base;
using base::view;
public:
- /// The reducer’s list type.
+ /// The reducer's list type.
typedef typename base::value_type list_type;
- /// The list’s element type.
+ /// The list's element type.
typedef Type list_value_type;
- /// The reducer’s primitive component type.
+ /// The reducer's primitive component type.
typedef Type basic_value_type;
/// The monoid type.
@@ -836,18 +859,18 @@ public:
/** @name Constructors
*/
//@{
-
- /** Construct a reducer with an empty list.
+
+ /** Constructs a reducer with an empty list.
*/
reducer_list_append() {}
- /** Construct a reducer with a specified initial list value.
+ /** Constructs a reducer with a specified initial list value.
*/
- reducer_list_append(const std::list<Type, Allocator> &initial_value) :
+ reducer_list_append(const std::list<Type, Allocator> &initial_value) :
base(initial_value) {}
-
+
//@}
-
+
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
@@ -856,25 +879,25 @@ public:
/// @copydoc op_list_append_view::push_back(const Type&)
void push_back(const Type& element) { view().push_back(element); }
-
+
//@}
- /** Allow mutable access to the list within the current view.
- *
+ /** Allows mutable access to the list within the current view.
+ *
* @warning If this method is called before the parallel calculation is
* complete, the list returned by this method will be a partial
* result.
- *
+ *
* @returns A mutable reference to the list within the current view.
*/
list_type &get_reference() { return view().view_get_reference(); }
- /** Allow read-only access to the list within the current view.
- *
+ /** Allows read-only access to the list within the current view.
+ *
* @warning If this method is called before the parallel calculation is
* complete, the list returned by this method will be a partial
* result.
- *
+ *
* @returns A const reference to the list within the current view.
*/
list_type const &get_reference() const { return view().view_get_reference(); }
@@ -903,12 +926,12 @@ public:
reducer_list_append* operator->() { return this; }
reducer_list_append const* operator->() const { return this; }
//@}
-
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
@@ -923,18 +946,18 @@ public:
}
operator const reducer< op_list_append<Type, Allocator, false> >& () const
{
- return *reinterpret_cast<
- const reducer< op_list_append<Type, Allocator, false> >*
+ return *reinterpret_cast<
+ const reducer< op_list_append<Type, Allocator, false> >*
>(this);
}
//@}
-
+
};
-/** Deprecated list prepend reducer wrapper class.
+/** Deprecated list-prepend reducer wrapper class.
*
- * reducer_list_prepend is the same as
+ * reducer_list_prepend is the same as
* @ref reducer<@ref op_list_prepend>, except that reducer_list_prepend is a
* proxy for the contained view, so that accumulator variable update operations
* can be applied directly to the reducer. For example, an element is prepended
@@ -942,13 +965,13 @@ public:
* prepended to a `reducer_list_prepend` with `r.push_back(a)`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_list_prepend.
+ * reducers rather than the old wrappers like reducer_list_prepend.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_list_prepend`
+ * @note Implicit conversions are provided between `%reducer_list_prepend`
* and `reducer<%op_list_prepend>`. This allows incremental code
* conversion: old code that used `%reducer_list_prepend` can pass a
* `%reducer_list_prepend` to a converted function that now expects a
@@ -963,22 +986,22 @@ public:
* @see ReducersList
*/
template <class Type, class Allocator = std::allocator<Type> >
-class reducer_list_prepend :
+class reducer_list_prepend :
public reducer<op_list_prepend<Type, Allocator, true> >
{
typedef reducer<op_list_prepend<Type, Allocator, true> > base;
using base::view;
public:
- /** The reducer’s list type.
+ /** The reducer's list type.
*/
typedef typename base::value_type list_type;
- /** The list’s element type.
+ /** The list's element type.
*/
typedef Type list_value_type;
- /** The reducer’s primitive component type.
+ /** The reducer's primitive component type.
*/
typedef Type basic_value_type;
@@ -989,45 +1012,45 @@ public:
/** @name Constructors
*/
//@{
-
- /** Construct a reducer with an empty list.
+
+ /** Constructs a reducer with an empty list.
*/
reducer_list_prepend() {}
- /** Construct a reducer with a specified initial list value.
+ /** Constructs a reducer with a specified initial list value.
*/
- reducer_list_prepend(const std::list<Type, Allocator> &initial_value) :
+ reducer_list_prepend(const std::list<Type, Allocator> &initial_value) :
base(initial_value) {}
-
+
//@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
- * simply forwarded to the contained @ref op_and_view.
+ * simply forwarded to the contained @ref op_and_view.
*/
//@{
/// @copydoc op_list_prepend_view::push_front(const Type&)
void push_front(const Type& element) { view().push_front(element); }
-
+
//@}
- /** Allow mutable access to the list within the current view.
- *
+ /** Allows mutable access to the list within the current view.
+ *
* @warning If this method is called before the parallel calculation is
* complete, the list returned by this method will be a partial
* result.
- *
+ *
* @returns A mutable reference to the list within the current view.
*/
list_type &get_reference() { return view().view_get_reference(); }
- /** Allow read-only access to the list within the current view.
- *
+ /** Allows read-only access to the list within the current view.
+ *
* @warning If this method is called before the parallel calculation is
* complete, the list returned by this method will be a partial
* result.
- *
+ *
* @returns A const reference to the list within the current view.
*/
list_type const &get_reference() const { return view().view_get_reference(); }
@@ -1055,12 +1078,12 @@ public:
reducer_list_prepend* operator->() { return this; }
reducer_list_prepend const* operator->() const { return this; }
//@}
-
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
@@ -1070,17 +1093,17 @@ public:
operator reducer< op_list_prepend<Type, Allocator, false> >& ()
{
return *reinterpret_cast<
- reducer< op_list_prepend<Type, Allocator, false> >*
+ reducer< op_list_prepend<Type, Allocator, false> >*
>(this);
}
operator const reducer< op_list_prepend<Type, Allocator, false> >& () const
{
return *reinterpret_cast<
- const reducer< op_list_prepend<Type, Allocator, false> >*
+ const reducer< op_list_prepend<Type, Allocator, false> >*
>(this);
}
//@}
-
+
};
/// @cond internal
@@ -1105,7 +1128,7 @@ struct legacy_reducer_downcast<reducer<op_list_append<Type, Allocator, Align> >
*
* This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the
- * `reducer< op_list_prepend<Type, Allocator> >` class to have an
+ * `reducer< op_list_prepend<Type, Allocator> >` class to have an
* `operator reducer_list_prepend<Type, Allocator>& ()` conversion operator
* that statically downcasts the `reducer<op_list_prepend>` to the
* corresponding `reducer_list_prepend` type. (The reverse conversion, from
diff --git a/libcilkrts/include/cilk/reducer_max.h b/libcilkrts/include/cilk/reducer_max.h
index 3ba3a0bc8ac..3982cb11c2a 100644
--- a/libcilkrts/include/cilk/reducer_max.h
+++ b/libcilkrts/include/cilk/reducer_max.h
@@ -1,10 +1,8 @@
/* reducer_max.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,6 +29,20 @@
* 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.
*/
/** @file reducer_max.h
diff --git a/libcilkrts/include/cilk/reducer_min.h b/libcilkrts/include/cilk/reducer_min.h
index f5a3910850e..912979d7229 100644
--- a/libcilkrts/include/cilk/reducer_min.h
+++ b/libcilkrts/include/cilk/reducer_min.h
@@ -1,10 +1,8 @@
/* reducer_min.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,6 +29,20 @@
* 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.
*/
/** @file reducer_min.h
diff --git a/libcilkrts/include/cilk/reducer_min_max.h b/libcilkrts/include/cilk/reducer_min_max.h
index 7fe09e8d605..641aa823901 100644
--- a/libcilkrts/include/cilk/reducer_min_max.h
+++ b/libcilkrts/include/cilk/reducer_min_max.h
@@ -1,10 +1,8 @@
/* reducer_min_max.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,6 +29,20 @@
* 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.
*/
/** @file reducer_min_max.h
@@ -60,9 +71,9 @@
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file `reducers.md`, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file `reducers.md`, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
*
* @section redminmax_usage Usage Examples
*
@@ -88,12 +99,13 @@
* @subsection redminmax_monoid_values Value Set
*
* The value set of a minimum or maximum reducer is the set of values of
- * `Type`, possibly augmented with a special identity value which is greater
- * than (less than) any value of `Type`.
+ * `Type`, augmented with a "special identity value" which is not a value of
+ * `Type`, but which is defined to be greater than (less than) any value of
+ * `Type`.
*
* @subsection redminmax_monoid_operator Operator
*
- * In the most common case, the operator of a minimum reducer is defined as
+ * By default, the operator of a minimum reducer is defined as
*
* x MIN y == (x < y) ? x : y
*
@@ -112,7 +124,7 @@
* Min/max reducers are not limited to finding the minimum or maximum value
* determined by the `<` or `>` operator. In fact, all min/max reducers use a
* _comparator_, which is either a function or an object of a function class
- * that defines a [strict weak ordering]
+ * that defines a [strict weak ordering]
* (http://en.wikipedia.org/wiki/Strict_weak_ordering#Strict_weak_orderings)
* on a set of values. (This is exactly the same as the requirement for the
* comparison predicate for STL associative containers and sorting
@@ -121,8 +133,8 @@
* Just as with STL algorithms and containers, the comparator type parameter
* for min/max reducers is optional. If it is omitted, it defaults to
* `std::less`, which gives the behavior described in the previous section.
- * Using non-default comparators (anything other than `std::less`) with
- * min/max reducers is just like using them with STL containers and
+ * Using non-default comparators (anything other than `std::less`) with
+ * min/max reducers is just like using them with STL containers and
* algorithms.
*
* Taking comparator objects into account, the reduction operation `MIN` for a
@@ -130,45 +142,44 @@
*
* x MIN y == compare(x, y) ? x : y
*
- * where `compare()` is the reducer’s comparator. Similarly, the reduction
+ * where `compare()` is the reducer's comparator. Similarly, the reduction
* operation MAX for a maximum reducer is defined as
*
* x MAX y == compare(y, x) ? x : y
*
- * (If `compare(x, y) == x < y`, then `compare(y, x) == x > y`.)
+ * (If `compare(x, y) == x < y`, then `compare(y, x) == x > y`.)
*
* @subsection redminmax_monoid_identity Identity
*
- * The identity value of the reducer is the value which is greater than (less
- * than) any other value in the value set of the reducer. This is the
- * [“special identity value”](#redminmax_monoid_values) if the reducer has
- * one, or the largest (smallest) value in the value set otherwise.
+ * The identity value of a min/max reducer is its monoid's
+ * ["special identity value"](#redminmax_monoid_values), which is not a value
+ * of the reducer's data type. (See @ref redminmax_initial.)
*
* @section redminmax_index Value and Index Reducers
*
- * Min/max reducers come in two families. The _value_ reducers, using `op_min`
- * and `op_max` monoids, simply find the smallest or largest value from a set
- * of values. The _index_ reducers, using `op_min_index` and `op_max_index`
- * monoids, also record an index value associated with the first occurrence of
- * the smallest or largest value.
+ * Min/max reducers come in two families. The _value_ reducers, with the
+ * `op_min` and `op_max` monoids, simply find the smallest or largest value
+ * from a set of values. The _index_ reducers, with the `op_min_index` and
+ * `op_max_index` monoids, also record an index value associated with the
+ * first occurrence of the smallest or largest value.
*
* In the `%op_min_index` usage example [above](#redminmax_usage), the values
* are taken from an array, and the index of a value is the index of the array
* element it comes from. More generally, though, an index can be any sort of
* key which identifies a particular value in a collection of values. For
- * example, if the values were taken from the nodes of a tree, then the
- * “index” of a value might be a pointer to the node containing that value.
+ * example, if the values were taken from the nodes of a tree, then the
+ * "index" of a value might be a pointer to the node containing that value.
*
* A min/max index reducer is essentially the same as a min/max value reducer
- * whose value type is an (index, value) pair, and whose comparator ignores
+ * whose value type is an (index, value) pair, and whose comparator ignores
* the index part of the pair. (index, value) pairs are represented by
- * `std::pair<Index, Type>` objects. This has the consequence that wherever
- * the interface of a min/max value reducer has a `Type`, the interface of the
- * corresponding min/max index reducer has a `std::pair<Index, Type>`. (There
- * are convenience variants of the `reducer(Type)` constructor and the
+ * `std::pair<Index, Type>` objects. This has the consequence that wherever
+ * the interface of a min/max value reducer has a `Type`, the interface of a
+ * min/max index reducer has a `std::pair<Index, Type>`. (There are
+ * convenience variants of the `reducer(Type)` constructor and the
* `calc_min()`, `calc_max()`, `%min_of()`, and `%max_of()` functions that
- * take an index argument and a value argument instead of an index/value
- * pair.)
+ * take an index argument and a value argument instead of a single index/value
+ * pair argument.)
*
* @section redminmax_operations Operations
*
@@ -194,6 +205,12 @@
* reducer(const Index& index, const Type& value, const Compare& compare)
* reducer(move_in(std::pair<Index, Type>& variable), const Compare& compare)
*
+ * See the explanation of the following two constructors in
+ * @ref redminmax_index_vector.
+ *
+ * reducer(const Index& index)
+ * reducer(const Index& index, const Compare& compare)
+ *
* @subsection redminmax_get_set Set and Get
*
* r.set_value(const Type& value)
@@ -207,51 +224,101 @@
*
* @subsection redminmax_initial Initial Values and is_set()
*
- * A minimum or maximum reducer without a specified initial value, before any
- * MIN or MAX operation has been performed on it, represents the [identity
- * value](#redminmax_monoid_identity) of its monoid. For value reducers with a
- * numeric type and default comparator (`std::less`), this will be a well
- * defined value. For example,
- *
- * reducer< op_max<unsigned> > r1;
- * // r1.get_value() == 0
- *
- * reducer< op_min<float> > r2;
- * // r2.get_value() == std::numeric_limits<float>::infinity
- *
- * In other cases, though (index reducers, non-numeric types, or non-default
- * comparators), the actual identity value for the monoid may be unknown, or
- * it may not even be a value of the reducer’s type. For example, there is no
- * “largest string” to serve as the initial value for a
- * `reducer< op_min<std::string> >`. In these cases, the result of calling
- * `get_value()` is undefined.
- *
- * To avoid calling `get_value()` when its result is undefined, you can call
- * the view’s `is_set()` function, which will return true if the reducer
- * has a well-defined value — either because a MIN or MAX operation has been
- * performed, or because it had a well-defined initial value:
- *
- * reducer< op_max<unsigned> > r1;
- * // r1->is_set() == true
- * // r1.get_value() == 0
- *
- * reducer< op_min<std::string> > r2;
- * // r2->is_set() == false
- * // r2.get_value() is undefined
- * r2->calc_min("xyzzy");
- * // r2->is_set() == true
- * // r2.get_value() == "xyzzy"
- *
- * > Note: For an index reducer without a specified initial value, the
- * > initial value of the index is the default value of the `Index` type.
+ * The initial value of the leftmost view of a default-initialized min/max
+ * reducer, or of a non-leftmost view (created for a stolen parallel strand)
+ * is the special identity value, which is not a value of the reducer's value
+ * type.
+ *
+ * A view will have a real (non-identity) value if:
+ *
+ * - it is the leftmost view of a reducer that was constructed with an
+ * initial value, or
+ * - it was assigned a value with a call to `reducer.set_value()` or
+ * `reducer.move_in()`, or
+ * - it has been updated with a call to `reducer->calc_min()` or
+ * `reducer->calc_max()`, or
+ * - it has been updated with an assignment `*reducer = min_of(*reducer, x)`
+ * or `*reducer = max_of(*reducer, x)`.
+ *
+ * Calling `get_value()` or `move_out()` on a reducer whose view has the
+ * special identity value will yield an undefined result. The `is_set()`
+ * function can be used to test whether a view has the special identity value
+ * or a real value. If a reducer's current view has the special identity
+ * value, then `reducer()->is_set()` will return `false` (and
+ * `reducer.get_value()` will return an undefined value); if the view has a
+ * real value, them `reducer->is_set()` will return `true` and
+ * `reducer.get_value()` will return the value.
+ *
+ * @subsubsection redminmax_index_vector Special Issues with Min/Max Index Reducers
+ *
+ * The index portion of the computed index/value pair will be wrong in the
+ * following special case:
+ *
+ * - The reducer's value type is a simple numeric type.
+ * - The reducer uses the default comparator (`std::less<Type>`).
+ * - The reducer is updated at least once with a call to `calc_min()` or
+ * `calc_max()` or an assignment with `min_of()` or `max_of()`.
+ * - The value in _every_ update to the reducer is the maximum value of the
+ * value type (for a min_index reducer) or the minimum value of the value
+ * type (for a max_index reducer).
+ *
+ * In this case, `reducer.get_value().first` should be the index argument from
+ * the first reducer update, but it will actually be the default value of the
+ * `Index` type. Now, in the common case where the index type is an integer
+ * type and the reducer is finding the smallest or largest element in an
+ * array, the default value of the index type will be zero, which is the
+ * index of the first element in the array, so everything will work out:
+ *
+ * unsigned a[3] = {0, 0, 0};
+ * reducer< op_max_index<int, unsigned> > r;
+ * for (int i = 0; i < 3; ++i) r->calc_max(i, a[i]);
+ * // r.get_value() = (0, 0)
+ *
+ * However, it doesn't always work out so well:
+ *
+ * typedef std::map<std::string, unsigned> my_map;
+ * my_map a;
+ * a["first"] = 0;
+ * a["second"] = 0;
+ * a["third"] = 0;
+ * reducer< op_max_index<std::string, unsigned> > r;
+ * for (typename my_map::iterator i = a.begin(); i != a.end(); ++i)
+ * r.calc_max(i->first, i->second);
+ * // r.get_value() = ("", 0), should be ("first", 0)
+ *
+ * If you know that no data value is associated with the default index value,
+ * then you can treat the default index value as a flag meaning "use the index
+ * of the first data value." But suppose that you don't know whether there is
+ * an element in the map with index `""`. Then you won't know what to do when
+ * `r.get_value().first == ""`.
+ *
+ * As a workaround for this conundrum, you can specify an alternative
+ * "default" index value. Either provide an index argument, _but not a
+ * value argument_, to the reducer constructor:
+ *
+ * reducer< op_max_index<std::string, unsigned> >
+ * r(a.empty() ? std::string() : a.begin()->first);
+ *
+ * or specify the default index with the view `set_default_index()` function:
+ *
+ * reducer< op_max_index<std::string, unsigned> > r;
+ * if (!a.empty()) r->set_default_index(a.begin()->first);
+ *
+ * Note that setting a default index, unlike setting an initial value, does
+ * not mark the view as having a non-identity value:
+ *
+ * reducer< op_min_index<int, int> > r;
+ * r->set_default_index(-1);
+ * // r->is_set() = false
+ * // r.get_value() is undefined
*
* @subsection redminmax_view_ops View Operations
*
- * The basic reduction operation is `x = x MIN a` for a minimum reducer, or
+ * The basic reduction operation is `x = x MIN a` for a minimum reducer, or
* `x = x MAX a` for a maximum reducer. The basic syntax for these operations
* uses the `calc_min()` and `calc_max()` member functions of the view class.
- * An assignment syntax is also provided, using the %cilk::min_of() and
- * %cilk::max_of() global functions:
+ * An assignment syntax is also provided, using the `%cilk::min_of()` and
+ * `%cilk::max_of()` global functions:
*
* Class | Modifier | Assignment
* ---------------|---------------------|-----------
@@ -260,7 +327,7 @@
* `op_min_index` | `r->calc_min(i, x)` | `*r = min_of(*r, i, x)` or `*r = min_of(i, x, *r)`
* `op_max_index` | `r->calc_max(i, x)` | `*r = max_of(*r, i, x)` or `*r = max_of(i, x, *r)`
*
- * Wherever an “`i`, `x`” argument pair is shown in the table above, a single
+ * Wherever an "`i`, `x`" argument pair is shown in the table above, a single
* pair argument may be passed instead. For example:
*
* Index index;
@@ -272,7 +339,7 @@
* *r = min_of(*r, index, value);
* *r = min_of(*r, ind_val);
*
- * The `calc_min()` and `calc_max()` member functions return a reference to
+ * The `calc_min()` and `calc_max()` member functions return a reference to
* the view, so they can be chained:
*
* r->calc_max(x).calc_max(y).calc_max(z);
@@ -290,58 +357,48 @@
* *r = max_of(max_of(max_of(*r, x), y), z);
* *r = min_of(i, a[i], min_of(j, a[j], min_of(k, a[k], *r)));
*
- * @section redminmax_compatibility Compatibility Issues
- *
- * Most Cilk library reducers provide
- * * Binary compatibility between `reducer_KIND` reducers compiled with Cilk
- * library version 0.9 (distributed with Intel® C++ Composer XE version
- * 13.0 and earlier) and the same reducers compiled with Cilk library
- * version 1.0 and later.
- * * Transparent casting between references to `reducer<op_KIND>` and
- * `reducer_KIND`.
- *
- * This compatibility is not available in all cases for min/max reducers.
- * There are two areas of incompatibility.
+ * @section redminmax_compatibility Binary Compatibility Issues
+ *
+ * Most Intel Cilk Plus library reducers provide binary compatibility between
+ * `reducer_KIND` reducers compiled with Intel Cilk Plus library version 0.9
+ * (distributed with Intel® C++ Composer XE version 13.0 and earlier) and the
+ * ame reducers compiled with Intel Cilk Plus library version 1.0 and later.
+ *
+ * Because of implementation changes that were needed to allow vectorization
+ * of loops containing min/max reducers, this binary compatibility is _not_
+ * generally available for min/max reducers, either between Intel Cilk Plus library
+ * versions 0.9 and 1.0, or between versions 1.0 and 1.1. (Code compiled with
+ * different versions can be linked together safely, but min/max reducers in
+ * different library versions are in different namespaces, so reducer objects
+ * cannot be shared between them.)
+ *
+ * If this is an inconvenience, the simplest solution is just to recompile any
+ * existing code you may have that uses min/max reducers. If that is
+ * impossible, you can define the `CILK_LIBRARY_0_9_REDUCER_MINMAX` macro (on
+ * the compiler command line, or in your source code before including
+ * `reducer_min_max.h`) when compiling with the new library. This will cause
+ * it to generate numeric reducers that will be link-time and run-time
+ * compatible with the 0.9 library.
*
* @subsection redminmax_compatibility_stateful Non-empty Comparators
*
- * There is no way to provide binary compatibility between the 0.9 and 1.0
- * definitions of min/max reducers that use a non-empty comparator class or a
- * comparator function. (Empty comparator classes like `std::less` are not a
- * problem.)
- *
- * To avoid run-time surprises, the legacy `reducer_{min|max}[_index]` classes
- * have been coded in the 1.0 library so that they will not even compile when
- * instantiated with a non-empty comparator class.
- *
- * @subsection redminmax_compatibility_optimized Numeric Optimization
- *
- * Min/max reducers with a numeric value type and the default comparator can
- * be implemented slightly more efficiently than other min/max reducers.
- * However, the optimization is incompatible with the 0.9 library
- * implementation of min/max reducers.
- *
- * The default min/max reducers implementation in the 1.0 library uses this
- * numeric optimization. Code using legacy reducers compiled with the 1.0
- * library can be safely used in the same program as code compiled with the
- * 0.9 library, but classes compiled with the different Cilk libraries will be
- * defined in different namespaces.
- *
- * The simplest solution is just to recompile the code that was compiled with
- * the older version of Cilk. However, if this is impossible, you can define
- * the `CILK_LIBRARY_0_9_REDUCER_MINMAX` macro (on the compiler command line,
- * or in your source code before including `reducer_min_max.h`) when compiling
- * with the new library. This will cause it to generate numeric reducers that
- * will be less efficient, but will be fully compatible with previously
- * compiled code. (Note that this macro has no effect on [the non-empty
- * comparator incompatibility] (redminmax_compatibility_stateful).)
+ * The representation of min/max reducers with non-empty comparator objects or
+ * with comparator functions is so different in between the 0.9 and 1.1
+ * libraries that there is no way to make them binary compatible, even when
+ * compiling with `CILK_LIBRARY_0_9_REDUCER_MINMAX`. Therefore, the
+ * `reducer_{min|max}[_index]` wrapper classes have been coded in the 1.0 and
+ * later library so that they will not even compile when instantiated with a
+ * non-empty comparator class.
+ *
+ * This is not a problem when using an empty comparator class, such as the
+ * default `std::less`.
*
* @section redminmax_types Type Requirements
*
* `Type` and `Index` must be `Copy Constructible`, `Default Constructible`,
* and `Assignable`.
*
- * `Compare` must be `Copy Constructible` if the reducer is constructed with a
+ * `Compare` must be `Copy Constructible` if the reducer is constructed with a
* `compare` argument, and `Default Constructible` otherwise.
*
* The `Compare` function must induce a strict weak ordering on the elements
@@ -353,8 +410,8 @@
*
* Declaration | Type | Operation
* -----------------------------|-----------------------------------|----------
- * @ref CILK_C_REDUCER_MIN |@ref CILK_C_REDUCER_MIN_TYPE |@ref CILK_C_REDUCER_MIN_CALC
- * @ref CILK_C_REDUCER_MAX |@ref CILK_C_REDUCER_MAX_TYPE |@ref CILK_C_REDUCER_MAX_CALC
+ * @ref CILK_C_REDUCER_MIN |@ref CILK_C_REDUCER_MIN_TYPE |@ref CILK_C_REDUCER_MIN_CALC
+ * @ref CILK_C_REDUCER_MAX |@ref CILK_C_REDUCER_MAX_TYPE |@ref CILK_C_REDUCER_MAX_CALC
* @ref CILK_C_REDUCER_MIN_INDEX |@ref CILK_C_REDUCER_MIN_INDEX_TYPE |@ref CILK_C_REDUCER_MIN_INDEX_CALC
* @ref CILK_C_REDUCER_MAX_INDEX |@ref CILK_C_REDUCER_MAX_INDEX_TYPE |@ref CILK_C_REDUCER_MAX_INDEX_CALC
*
@@ -375,7 +432,7 @@
* CILK_C_REDUCER_MAX_INDEX_CALC(r, i, a[i]);
* }
* CILK_C_UNREGISTER_REDUCER(r);
- * printf("The largest value in a is %u at %d\n",
+ * printf("The largest value in a is %u at %d\n",
* REDUCER_VIEW (r).value, REDUCER_VIEW(r).index);
*
* See @ref reducers_c_predefined.
@@ -385,39 +442,39 @@ namespace cilk {
/** @defgroup ReducersMinMaxBinComp Binary compatibility
*
- * If the macro CILK_LIBRARY_0_9_REDUCER_MINMAX is defined, then we generate
+ * If the macro `CILK_LIBRARY_0_9_REDUCER_MINMAX` is defined, then we generate
* reducer code and data structures which are binary-compatible with code that
* was compiled with the old min/max wrapper definitions, so we want the
* mangled names of the legacy min/max reducer wrapper classes to be the
* same as the names produced by the old definitions.
*
- * Conversely, if the macro is not defined, then we generate binary-
- * incompatible code, so we want different mangled names, to make sure that
+ * Conversely, if the macro is not defined, then we generate binary-
+ * incompatible code, so we want different mangled names, to make sure that
* the linker does not allow new and old compiled legacy wrappers to be passed
* to one another. (Global variables are a different, and probably insoluble,
* problem.)
*
- * Similarly, min/max classes compiled with and without
- * CILK_LIBRARY_0_9_REDUCER_MINMAX are binary-incompatible, and must get
+ * Similarly, min/max classes compiled with and without
+ * CILK_LIBRARY_0_9_REDUCER_MINMAX are binary-incompatible, and must get
* different mangled names.
*
* The trick is, when compiling in normal (non-compatibility) mode, wrap
* everything in an extra namespace, and then `use` it into the top-level cilk
- * namespace. Then
+ * namespace. Then
*
* * Classes and functions compiled in normal mode will be in
* different namespaces from the same classes and functions compiled in
* compatibility mode.
- * * The legacy wrapper classes and functions will be in the same namespace
- * as the same classes and functions compiled with the0.9 library if and
- * only if the are compiled in compatibility mode.
+ * * The legacy wrapper classes and functions will be in the same namespace
+ * as the same classes and functions compiled with the 0.9 library if and
+ * only if they are compiled in compatibility mode.
*
* @ingroup ReducersMinMax
*/
-
+
#ifndef CILK_LIBRARY_0_9_REDUCER_MINMAX
-/** Namespace to wrap min/max reducer definitions when not compiling in “binary
- * compatibility” mode.
+/** Namespace to wrap min/max reducer definitions when not compiling in "binary
+ * compatibility" mode.
*
* By default, all of the min/max reducer definitions are defined in this
* namespace and then imported into namespace ::cilk, so that they do not
@@ -430,7 +487,7 @@ namespace cilk {
* @ingroup ReducersMinMaxBinComp
* @ingroup ReducersMinMax
*/
-namespace cilk_lib_1_0 {
+namespace cilk_lib_1_1 {
#endif
/** Namespace containing internal implementation classes and functions for
@@ -444,12 +501,12 @@ using ::cilk::internal::binary_functor;
using ::cilk::internal::typed_indirect_binary_function;
using ::cilk::internal::class_is_empty;
-/** @defgroup ReducersMinMaxIsSet The “is_set optimization”
+/** @defgroup ReducersMinMaxIsSet The "is_set optimization"
*
* The obvious definition of the identity value for a max or min reducer is as
- * the smallest (or largest) value of the value type. However, for an
+ * the smallest (or largest) value of the value type. However, for an
* arbitrary comparator and/or an arbitrary value type, the largest / smallest
- * value may not be known. It may not even be defined — what is the largest
+ * value may not be known. It may not even be defined - what is the largest
* string?
*
* Therefore, min/max reducers represent their value internally as a pair
@@ -463,41 +520,41 @@ using ::cilk::internal::class_is_empty;
* smallest and largest values. Testing `is_set` for every comparison is then
* unnecessary and wasteful.
*
- * The “is_set optimization” just means generating code that doesn’t use
- * `is_set` when it isn’t needed. It is implemented using two metaprogramming
+ * The "is_set optimization" just means generating code that doesn't use
+ * `is_set` when it isn't needed. It is implemented using two metaprogramming
* classes:
*
* - do_is_set_optimization tests whether the optimization is applicable.
* - identity_value gets the appropriate identity value for a type.
*
* The is_set optimization is the reason that min/max reducers compiled with
- * Cilk library 1.0 are binary-incompatible with the same reducers compiled
- * with library 0.9, and therefore the optimization is suppressed when
- * compiling in
- * ReducersMinMaxBinComp "binary compatibility mode".
- *
+ * Intel Cilk Plus library 1.0 are binary-incompatible with the same reducers
+ * compiled with library 0.9, and therefore the optimization is suppressed when
+ * compiling in
+ * ReducersMinMaxBinComp "binary compatibility mode".
+ *
* @ingroup ReducersMinMax
*/
-/** Test whether the ReducersMinMaxIsSet "is_set optimization" is
+/** Tests whether the ReducersMinMaxIsSet "is_set optimization" is
* applicable.
*
* The @ref do_is_set_optimization class is used to test whether the is_set
* optimization should be applied for a particular reducer. It is instantiated
- * with a value type and a comparator, and defines a boolean constant,
+ * with a value type and a comparator, and defines a boolean constant,
* `value`. Then `%do_is_set_optimization<Type, Comp>::%value` can be used as
* a boolean template parameter to control the specialization of another
* class.
*
- * In ReducersMinMaxBinComp "binary compatibility mode", when the
- * `CILK_LIBRARY_0_9_REDUCER_MINMAX` macro is defined, `value` will always
+ * In ReducersMinMaxBinComp "binary compatibility mode" (i.e., when the
+ * `CILK_LIBRARY_0_9_REDUCER_MINMAX` macro is defined), `value` will always
* be false.
*
* @tparam Type The value type for the reducer.
* @tparam Compare The comparator type for the reducer.
*
- * @result The `value` data member will be `true` if @a Type is a numeric
- * type, @a Compare is `std::less<Type>`, and
+ * @result The `value` data member will be `true` if @a Type is a numeric
+ * type, @a Compare is `std::less<Type>`, and
* `CILK_LIBRARY_0_9_REDUCER_MINMAX` is not defined.
*
* @see ReducersMinMaxIsSet
@@ -505,10 +562,10 @@ using ::cilk::internal::class_is_empty;
*
* @ingroup ReducersMinMaxIsSet
*/
-template < typename Type,
+template < typename Type,
typename Compare >
-struct do_is_set_optimization
-{
+struct do_is_set_optimization
+{
/// `True` if the is_set optimization should be applied to min/max reducers
/// with this value type and comparator; `false` otherwise.
static const bool value = false;
@@ -517,8 +574,8 @@ struct do_is_set_optimization
#ifndef CILK_LIBRARY_0_9_REDUCER_MINMAX
/// @cond
template <typename Type>
-struct do_is_set_optimization<Type, std::less<Type> >
-{
+struct do_is_set_optimization<Type, std::less<Type> >
+{
/// True in the special case where optimization is possible.
static const bool value = std::numeric_limits<Type>::is_specialized;
};
@@ -526,7 +583,7 @@ struct do_is_set_optimization<Type, std::less<Type> >
#endif
-/** Get the identity value when using the ReducersMinMaxIsSet
+/** Gets the identity value when using the ReducersMinMaxIsSet
* "is_set optimization".
*
* This class defines a function which assigns the appropriate identity value
@@ -534,7 +591,7 @@ struct do_is_set_optimization<Type, std::less<Type> >
*
* @tparam Type The value type for the reducer.
* @tparam Compare The comparator type for the reducer.
- * @tparam ForMax `true` to get the identity value for a max reducer (i.e.,
+ * @tparam ForMax `true` to get the identity value for a max reducer (i.e.,
* the smallest value of @a Type), `false` to get the identity
* value for a min reducer (i.e., the largest value of
* @a Type).
@@ -549,8 +606,8 @@ struct do_is_set_optimization<Type, std::less<Type> >
* @ingroup ReducersMinMaxIsSet
* @see @ref view_content
*/
-template < typename Type,
- typename Compare,
+template < typename Type,
+ typename Compare,
bool ForMax,
bool = std::numeric_limits<Type>::is_specialized,
bool = std::numeric_limits<Type>::has_infinity >
@@ -563,7 +620,7 @@ struct identity_value {
template <typename Type>
struct identity_value<Type, std::less<Type>, true, true, true> {
/// Floating max identity is negative infinity.
- static void set_identity(Type& id)
+ static void set_identity(Type& id)
{ id = -std::numeric_limits<Type>::infinity(); }
};
@@ -599,25 +656,25 @@ struct identity_value<Type, std::less<Type>, false, true, false> {
* max(x, y) == (x < y) ? y : x
* min(x, y) == (y < x) ? y : x == (x > y) ? y : x
*
- * More generally, if `c` is a predicate defining a `Strict Weak Ordering`,
+ * More generally, if `c` is a predicate defining a `Strict Weak Ordering`,
* and `c*(x, y) == c(y, x)`, then
*
* max(x, y, c) == c(x, y) ? y : x
* min(x, y, c) == c(y, x) ? y : x == c*(x, y) ? y : x == max(x, y, c*)
*
- * For any predicate `C` with argument type `T`, the template class
+ * For any predicate `C` with argument type `T`, the template class
* `%reverse_predicate<C, T>` defines a predicate which is identical to `C`,
* except that its arguments are reversed. Thus, for example, we could
* implement `%op_min_view<Type, Compare>` as
- * `%op_max_view<Type, %reverse_predicate<Compare, Type> >`.
- * (Actually, op_min_view and op_max_view are both implemented as subclasses
+ * `%op_max_view<Type, %reverse_predicate<Compare, Type> >`.
+ * (Actually, op_min_view and op_max_view are both implemented as subclasses
* of a common base class, view_base.)
*
* @note If `C` is an empty functor class, then `reverse_predicate(C)` will
* also be an empty functor class.
*
* @tparam Predicate The predicate whose arguments are to be reversed.
- * @tparam Argument @a Predicate’s argument type.
+ * @tparam Argument @a Predicate's argument type.
*
* @ingroup ReducersMinMax
*/
@@ -629,7 +686,7 @@ public:
/// Default constructor
reverse_predicate() : base() {}
/// Constructor with predicate object
- reverse_predicate(const Predicate& p) : base(p) {}
+ reverse_predicate(const Predicate& p) : base(p) {}
/// The reversed predicate operation
bool operator()(const Argument& x, const Argument& y) const
{ return base::operator()(y, x); }
@@ -638,7 +695,7 @@ public:
/** Class to represent the comparator for a min/max view class.
*
- * This class is intended to accomplish two objectives in the implementation
+ * This class is intended to accomplish two objectives in the implementation
* of min/max views.
*
* 1. To minimize data bloat, when we have a reducer with a non-stateless
@@ -646,24 +703,24 @@ public:
* in the monoid, and just call it from the views.
* 2. In ReducersMinMaxBinComp "binary compatibility mode", views for
* reducers with a stateless comparator must have the same content as in
- * Cilk library 0.9 — that is, they must contain only `value` and
+ * Intel Cilk Plus library 0.9 - that is, they must contain only `value` and
* `is_set` data members.
*
- * To achieve the first objective, we use the
+ * To achieve the first objective, we use the
* @ref internal::typed_indirect_binary_function class defined in
* metaprogramming.h to wrap a pointer to the actual comparator. If no
- * pointer is needed because the actual comparator is stateless, the
+ * pointer is needed because the actual comparator is stateless, the
* `typed_indirect_binary_function` class will be empty, too.
*
* To achieve the second objective, we make the
* `typed_indirect_binary_function` class a base class of the view rather than
- * a data member, so the “empty base class” rule will ensure no that no
+ * a data member, so the "empty base class" rule will ensure no that no
* additional space is allocated in the view unless it is needed.
*
* We could simply use typed_indirect_binary_function as the base class of the
* view, but this would mean writing comparisons as `(*this)(x, y)`, which is
* just weird. So, instead, we comparator_base as a subclass of
- * typed_indirect_binary_function which provides function `compare()`
+ * typed_indirect_binary_function which provides function `compare()`
* as a synonym for `operator()`.
*
* @tparam Type The value type of the comparator class.
@@ -679,13 +736,13 @@ class comparator_base : private typed_indirect_binary_function<Compare, Type, Ty
typedef typed_indirect_binary_function<Compare, Type, Type, bool> base;
protected:
comparator_base(const Compare* f) : base(f) {} ///< Constructor.
-
+
/// Comparison function.
bool compare(const Type& a, const Type& b) const
{
- return base::operator()(a, b);
+ return base::operator()(a, b);
}
-
+
/// Get the comparator pointer.
const Compare* compare_pointer() const { return base::pointer(); }
};
@@ -695,7 +752,7 @@ protected:
*
* @ingroup ReducersMinMax
*
- * Minimum and maximum reducer view classes inherit from a “view content”
+ * Minimum and maximum reducer view classes inherit from a "view content"
* class. The content class defines the actual data members for the view,
* and provides typedefs and member functions for accessing the data members
* as needed to support the view functionality.
@@ -708,31 +765,32 @@ protected:
*
* @note An obvious, and arguably simpler, encapsulation strategy would be
* to just let the `Type` of a min/max view be an (index, value) pair
- * structure for min_index and max_index reducers. Then all views
+ * structure for min_index and max_index reducers. Then all views
* would just have a `Type` data member and an `is_set` data member,
* and the comparator for min_index and max_index views could be
* customized to consider only the value component of the (index,
* value) `Type` pair. Unfortunately, this would break binary
* compatibility with reducer_max_index and reducer_min_index in
- * Cilk library 0.9, because the memory layout of an (index, value)
- * pair followed by a `bool` is different from the memory layout of an
- * index data member followed by a value data member followed by a
- * `bool` data member. The content class is designed to exactly
- * replicate the layout of the views in library 0.9 reducers.
+ * Intel Cilk Plus library 0.9, because the memory layout of an
+ * (index, value) pair followed by a `bool` is different from the
+ * memory layout of an index data member followed by a value data
+ * member followed by a `bool` data member. The content class is
+ * designed to exactly replicate the layout of the views in library 0.9
+ * reducers.
*
* A content class `C`, and its objects `c`, must define the following:
*
* Definition | Meaning
* ------------------------------------|--------
* `C::value_type` | A typedef for `Type` of the view. (A `std::pair<Index, Type>` for min_index and max_index views).
- * `C::comp_value_type` | A typedef for the type of value compared by the view’s `compare()` function.
+ * `C::comp_value_type` | A typedef for the type of value compared by the view's `compare()` function.
* `C()` | Constructs the content with the identity value.
* `C(const value_type&)` | Constructs the content with a specified value.
* `c.is_set()` | Returns true if the content has a known value.
- * `c.value()` | Returns the content’s value.
- * `c.set_value(const value_type&)` | Sets the content’s value. (The value becomes known.)
- * `c.comp_value()` | Returns a const reference to the value or component of the value that is to be compared by the view’s comparator.
- * `C::comp_value(const value_type&)` | Returns a const reference to a value or component of a value that is to be compared by the view’s comparator.
+ * `c.value()` | Returns the content's value.
+ * `c.set_value(const value_type&)` | Sets the content's value. (The value becomes known.)
+ * `c.comp_value()` | Returns a const reference to the value or component of the value that is to be compared by the view's comparator.
+ * `C::comp_value(const value_type&)` | Returns a const reference to a value or component of a value that is to be compared by the view's comparator.
*
* @see view_base
*/
@@ -740,20 +798,20 @@ protected:
/** Content class for op_min_view and op_max_view.
*
* @tparam Type The value type of the op_min_view or op_max_view.
- * @tparam Compare The comparator class specified for the op_min_view or
+ * @tparam Compare The comparator class specified for the op_min_view or
* op_max_view. (_Not_ the derived comparator class actually
* used by the view_base. For example, the view_content of an
- * `op_min_view<int>` will have `Compare = std::less<int>`,
- * but its comparator_base will have
+ * `op_min_view<int>` will have `Compare = std::less<int>`,
+ * but its comparator_base will have
* `Compare = reverse_predicate< std::less<int> >`.)
* @tparam ForMax `true` if this is the content class for an op_max_view,
* `false` if it is for an op_min_view.
*
* @note The general implementation of view_content uses an `is_set` data
- * member. There is also a specialization which implements the
+ * member. There is also a specialization which implements the
* ReducersMinMaxIsSet "is_set optimization". View classes that
* inherit from view_content do not need to know anything about the
- * difference, though; the details are abstracted away in the
+ * difference, though; the details are abstracted away in the
* view_content interface.
*
* @see ReducersMinMaxViewContent
@@ -767,96 +825,94 @@ template < typename Type
, bool = do_is_set_optimization<Type, Compare>::value
>
class view_content {
+protected:
+/// @cond
Type m_value;
bool m_is_set;
+/// @endcond
public:
/// The value type of the view.
typedef Type value_type;
-
- /// The type compared by the view’s `compare()` function (which is the same
+
+ /// The type compared by the view's `compare()` function (which is the same
/// as the value type for view_content).
typedef Type comp_value_type;
-
+
/// Construct with the identity value.
view_content() : m_value(), m_is_set(false) {}
-
+
/// Construct with a defined value.
view_content(const value_type& value) : m_value(value), m_is_set(true) {}
-
- /// Get the value.
+
+ /// Gets the value.
value_type value() const { return m_value; }
-
- /// Set the value.
- void set_value(const value_type& value)
- {
+
+ /// Sets the value.
+ void set_value(const value_type& value)
+ {
m_value = value;
+ }
+
+ /// Sets the is_set flag.
+ void set_is_set()
+ {
m_is_set = true;
}
-
- /// Get the comparison value (which is the same as the value for
- /// view_content).
+
+ /// Sets the index part of the value (which is meaningless for non-index
+ ///reducers, but required for view_base).
+ void set_default_index(const value_type&) {}
+
+ /// Gets the comparison value (which, for view_content, is the same as the
+ /// value).
const comp_value_type& comp_value() const { return m_value; }
- /// Given an arbitrary value, get the corresponding comparison value (which
- /// is the same as the value for view_content).
- static const comp_value_type& comp_value(const value_type& value)
+ /// Given an arbitrary value, gets the corresponding comparison value
+ /// (which, for view_content, is the same as the value).
+ static const comp_value_type& comp_value(const value_type& value)
{
- return value;
+ return value;
}
-
- /// Get a const reference to value part of the value (which is the same as
+
+ /// Gets a const reference to value part of the value (which is the same as
/// the value for view_content).
const Type& get_reference() const { return m_value; }
-
- /// Get a const reference to the index part of the value (which is
+
+ /// Gets a const reference to the index part of the value (which is
/// meaningless for non-index reducers, but required for view_base.
const Type& get_index_reference() const { return m_value; }
-
- /// Test if the value is defined.
+
+ /// Tests if the value is defined.
bool is_set() const { return m_is_set; }
+
+ /// Tests if the view has a comparable value.
+ bool has_value() const { return is_set(); }
};
/// @cond
/* This is the specialization of the view_content class for cases where
- * `AssumeIsSet` is true (i.e., where the is_set optimization is applicable).
+ * the is_set optimization is applicable).
*/
template < typename Type
, typename Compare
- , bool ForMax
+ , bool ForMax
>
-class view_content<Type, Compare, ForMax, true> {
+class view_content<Type, Compare, ForMax, true> :
+ public view_content<Type, Compare, ForMax, false>
+{
+ typedef view_content<Type, Compare, ForMax, false> base;
typedef identity_value<Type, Compare, ForMax> Identity;
- Type m_value;
+
public:
- typedef Type value_type;
- typedef Type comp_value_type;
-
- /// Construct with identity value.
- view_content() { Identity::set_identity(m_value); }
-
- view_content(const value_type& value) : m_value(value) {}
-
- value_type value() const { return m_value; }
-
- void set_value(const value_type& value)
- {
- m_value = value;
- }
-
- const comp_value_type& comp_value() const { return m_value; }
+ typedef typename base::value_type value_type;;
+ typedef typename base::comp_value_type comp_value_type;;
- static const comp_value_type& comp_value(const value_type& value)
- {
- return value;
- }
-
- const Type& get_reference() const { return m_value; }
-
- const Type& get_index_reference() const { return m_value; }
-
- /// Test if the value is defined.
- bool is_set() const { return true; }
+ view_content() : base() { Identity::set_identity(this->m_value); }
+
+ view_content(const value_type& value) : base(value) {}
+
+ bool has_value() const { return true; }
};
/// @endcond
@@ -866,10 +922,10 @@ public:
*
* @tparam Index The index type of the op_min_index_view or
op_max_index_view.
- * @tparam Type The value type of the op_min_view or op_max_view. (_Not_
+ * @tparam Type The value type of the op_min_view or op_max_view. (_Not_
* the value type of the view, which will be
* `std::pair<Index, Type>`.)
- * @tparam Compare The comparator class specified for the op_min_index_view or
+ * @tparam Compare The comparator class specified for the op_min_index_view or
* op_max_index_view. (_Not_ the derived comparator class
* actually used by the view_base. For example, the
* index_view_content of an `op_min_index_view<int>` will have
@@ -887,93 +943,147 @@ public:
template < typename Index
, typename Type
, typename Compare
- , bool ForMax
+ , bool ForMax
+ , bool = do_is_set_optimization<Type, Compare>::value
>
class index_view_content {
- typedef identity_value<Type, Compare, ForMax> Identity;
-
+protected:
+/// @cond
Index m_index;
Type m_value;
bool m_is_set;
+/// @endcond
public:
- /// The value type of the view (which is an <index, value> pair for
+ /// The value type of the view (which is an <index, value> pair for
/// index_view_content).
typedef std::pair<Index, Type> value_type;
-
- /// The type compared by the view’s `compare()` function (which is the data
+
+ /// The type compared by the view's `compare()` function (which is the data
/// value type for index_view_content).
typedef Type comp_value_type;
-
+
/// Construct with the identity value.
index_view_content() : m_index(), m_value(), m_is_set(false) {}
-
+
/// Construct with an index/value pair.
- index_view_content(const value_type& value) :
+ index_view_content(const value_type& value) :
m_index(value.first), m_value(value.second), m_is_set(true) {}
-
+
/// Construct with an index and a value.
- index_view_content(const Index& index, const Type& value) :
+ index_view_content(const Index& index, const Type& value) :
m_index(index), m_value(value), m_is_set(true) {}
-
+
/// Construct with just an index.
- index_view_content(const Index& index) :
+ index_view_content(const Index& index) :
m_index(index), m_value(), m_is_set(false) {}
-
- /// Get the value.
+
+ /// Gets the value.
value_type value() const { return value_type(m_index, m_value); }
-
- /// Set value.
- void set_value(const value_type& value)
- {
- m_index = value.first;
+
+ /// Sets the value.
+ void set_value(const value_type& value)
+ {
+ m_index = value.first;
m_value = value.second;
+ }
+
+ /// Sets the is_set flag.
+ void set_is_set()
+ {
m_is_set = true;
}
-
- /// Get the comparison value (which is the value component of the
- /// index/value pair for index_view_content).
+
+ /// Sets the (initial) index, without marking the view as set.
+ void set_default_index(const Index& index)
+ {
+ m_index = index;
+ }
+
+ /// Gets the comparison value (which, for index_view_content, is the value
+ /// component of the index/value pair).
const comp_value_type& comp_value() const { return m_value; }
-
- /// Given an arbitrary value (i.e., index/value pair), get the
- /// corresponding comparison value (which is the value component of the
- /// index/value pair for index_view_content).
- static const comp_value_type& comp_value(const value_type& value)
+
+ /// Given an arbitrary value (i.e., index/value pair), gets the
+ /// corresponding comparison value (which, for index_view_content, is the
+ /// value component of the index/value pair).
+ static const comp_value_type& comp_value(const value_type& value)
{ return value.second; }
-
- /// Get a const reference to value part of the value.
+
+ /// Gets a const reference to the value part of the value.
const Type& get_reference() const { return m_value; }
-
- /// Get a const reference to the index part of the value.
+
+ /// Gets a const reference to the index part of the value.
const Index& get_index_reference() const { return m_index; }
-
- /// Test if the value is defined.
+
+ /// Tests if the value is defined.
bool is_set() const { return m_is_set; }
+
+ /// Tests if the view has a comparable value.
+ bool has_value() const { return is_set(); }
+};
+
+
+/// @cond
+
+/* This is the specialization of the index_view_content class for cases where
+ * the is_set optimization is applicable).
+ */
+template < typename Index
+ , typename Type
+ , typename Compare
+ , bool ForMax
+ >
+class index_view_content<Index, Type, Compare, ForMax, true> :
+ public index_view_content<Index, Type, Compare, ForMax, false>
+{
+ typedef index_view_content<Index, Type, Compare, ForMax, false> base;
+ typedef identity_value<Type, Compare, ForMax> Identity;
+public:
+ typedef typename base::value_type value_type;;
+ typedef typename base::comp_value_type comp_value_type;;
+
+ index_view_content() : base() { Identity::set_identity(this->m_value); }
+
+ index_view_content(const value_type& value) : base(value) {}
+
+ index_view_content(const Index& index, const Type& value) :
+ base(index, value) {}
+
+ index_view_content(const Index& index) : base() {
+ Identity::set_identity(this->m_value);
+ this->m_index = index;
+ }
+
+ /// Test if the view has a comparable value.
+ bool has_value() const { return true; }
};
+/// @endcond
+
template <typename View> class rhs_proxy;
-/** Create an rhs_proxy.
+/** Creates an rhs_proxy.
*/
template <typename View>
-inline rhs_proxy<View>
+inline rhs_proxy<View>
make_proxy(const typename View::value_type& value, const View& view);
template <typename Content, typename Less, typename Compare> class view_base;
-/** Class to represent the right-hand side of
+/** Class to represent the right-hand side of
* `*reducer = {min|max}_of(*reducer, value)`.
*
* The only assignment operator for a min/max view class takes a rhs_proxy as
* its operand. This results in the syntactic restriction that the only
* expressions that can be assigned to a min/max view are ones which generate
- * an rhs_proxy — that is, expressions of the form `max_of(view, value)` and
+ * an rhs_proxy - that is, expressions of the form `max_of(view, value)` and
* `min_of(view, value)`.
*
* @warning
- * The lhs and rhs views in such an assignment must be the same; otherwise,
- * the behavior will be undefined. (I.e., `*r1 = min_of(*r1, x)` is legal;
+ * The lhs and rhs views in such an assignment must be the same; otherwise,
+ * the behavior will be undefined. (I.e., `*r1 = min_of(*r1, x)` is legal;
* `*r1 = min_of(*r2, x)` is illegal.) This condition will be checked with a
* runtime assertion when compiled in debug mode.
*
@@ -991,12 +1101,12 @@ class rhs_proxy {
typedef typename View::value_type value_type;
typedef typename View::content_type content_type;
typedef typename content_type::comp_value_type comp_value_type;
-
+
friend class view_base<content_type, less_type, compare_type>;
friend rhs_proxy make_proxy<View>(
- const typename View::value_type& value,
+ const typename View::value_type& value,
const View& view);
-
+
typed_indirect_binary_function<
compare_type, comp_value_type, comp_value_type, bool>
m_comp;
@@ -1005,38 +1115,38 @@ class rhs_proxy {
rhs_proxy& operator=(const rhs_proxy&); // Disable assignment operator
rhs_proxy(); // Disable default constructor
-
+
// Constructor (called from view_base::make_proxy).
- rhs_proxy(const View* view,
+ rhs_proxy(const View* view,
const value_type& value,
- const compare_type* compare) :
+ const compare_type* compare) :
m_view(view), m_value(value), m_comp(compare) {}
-
- // Check matching view, then return value (called from view_base::assign).
+
+ // Checks matching view, then return value (called from view_base::assign).
value_type value(const typename View::base* view) const
- {
- __CILKRTS_ASSERT(view == m_view);
- return m_value;
+ {
+ __CILKRTS_ASSERT(view == m_view);
+ return m_value;
}
public:
- /** Support max_of(max_of(view, value), value) and the like.
+ /** Supports max_of(max_of(view, value), value) and the like.
*/
rhs_proxy calc(const value_type& x) const
{
return rhs_proxy(
- m_view,
- m_comp( content_type::comp_value(m_value),
+ m_view,
+ m_comp( content_type::comp_value(m_value),
content_type::comp_value(x)
) ? x : m_value,
m_comp.pointer());
}
};
-
-
+
+
template <typename View>
-inline rhs_proxy<View>
+inline rhs_proxy<View>
make_proxy(const typename View::value_type& value, const View& view)
{
return rhs_proxy<View>(&view, value, view.compare_pointer());
@@ -1058,14 +1168,14 @@ make_proxy(const typename View::value_type& value, const View& view)
* which is equivalent to `std::greater`, then the accumulated value is the
* first argument value which is not greater than any other argument value,
* i.e., the minimum.
- *
+ *
* @note This class provides the definitions that are required for a class
- * that will be used as the parameter of a
- * min_max_internal::monoid_base specialization.
+ * that will be used as the parameter of a
+ * min_max_internal::monoid_base specialization.
*
* @tparam Content A content class that provides the value types and data
* members for the view.
- * @tparam Less A “less than” binary predicate that defines the min or
+ * @tparam Less A "less than" binary predicate that defines the min or
* max function.
* @tparam Compare A binary predicate to be used to compare the values.
* (The same as @a Less for max reducers; its reversal for
@@ -1081,73 +1191,76 @@ make_proxy(const typename View::value_type& value, const View& view)
* @ingroup ReducersMinMax
*/
template <typename Content, typename Less, typename Compare>
-class view_base :
+class view_base :
// comparator_base comes first to ensure that it will get empty base class
// treatment
- private comparator_base<typename Content::comp_value_type, Compare>,
+ private comparator_base<typename Content::comp_value_type, Compare>,
private Content
{
typedef comparator_base<typename Content::comp_value_type, Compare> base;
using base::compare;
using Content::value;
using Content::set_value;
+ using Content::has_value;
+ using Content::set_is_set;
using Content::comp_value;
typedef Content content_type;
-
+
template <typename View> friend class rhs_proxy;
template <typename View>
friend rhs_proxy<View> make_proxy(const typename View::value_type& value, const View& view);
-
+
public:
-
+
/** @name Monoid support.
*/
//@{
-
+
/** Value type. Required by @ref monoid_with_view.
*/
typedef typename Content::value_type value_type;
-
- /** The type of the comparator specified by the user, that defines the
+
+ /** The type of the comparator specified by the user, that defines the
* ordering on @a Type. Required by min_max::monoid_base.
*/
typedef Less less_type;
-
- /** The type of the comparator actually used by the view. Required by
- * min_max::monoid_base. (This is the same as the @ref less_type for a
+
+ /** The type of the comparator actually used by the view. Required by
+ * min_max::monoid_base. (This is the same as the @ref less_type for a
* max reducer, or `reverse_predicate<less_type>` for a min reducer.)
*/
typedef Compare compare_type;
- /** Reduce operation. Required by @ref monoid_with_view.
+ /** Reduces two views. Required by @ref monoid_with_view.
*/
void reduce(view_base* other)
{
if ( other->is_set() &&
- ( !this->is_set() ||
+ ( !this->is_set() ||
compare(this->comp_value(), other->comp_value()) ) )
{
this->set_value(other->value());
+ this->set_is_set();
}
}
-
+
//@}
-
+
/** Default constructor. Initializes to identity value.
*/
- explicit view_base(const compare_type* compare) :
+ explicit view_base(const compare_type* compare) :
base(compare), Content() {}
-
+
/** Value constructor.
*/
template <typename T1>
- view_base(const T1& x1, const compare_type* compare) :
+ view_base(const T1& x1, const compare_type* compare) :
base(compare), Content(x1) {}
/** Value constructor.
*/
template <typename T1, typename T2>
- view_base(const T1& x1, const T2& x2, const compare_type* compare) :
+ view_base(const T1& x1, const T2& x2, const compare_type* compare) :
base(compare), Content(x1, x2) {}
@@ -1155,44 +1268,54 @@ public:
*/
explicit view_base(move_in_wrapper<value_type> w, const compare_type* compare) :
base(compare), Content(w.value()) {}
-
+
/** @name Reducer support.
*/
//@{
-
- void view_move_in(value_type& v) { set_value(v); }
- void view_move_out(value_type& v) { v = value(); }
- void view_set_value(const value_type& v) { set_value(v); }
- value_type view_get_value() const { return value(); }
+
+ void view_move_in(value_type& v)
+ { set_value(v); set_is_set();}
+ void view_move_out(value_type& v)
+ { v = value(); }
+ void view_set_value(const value_type& v)
+ { set_value(v); set_is_set(); }
+ value_type view_get_value() const
+ { return value(); }
// view_get_reference() NOT SUPPORTED
-
+
//@}
-
+
+ /** Sets the contained index data member, without marking the view as set.
+ * (Meaningless for non-index reducers.)
+ */
+ using Content::set_default_index;
+
/** Is the value defined?
*/
using Content::is_set;
-
+
/** Reference to contained value data member.
* @deprecated For legacy reducers only.
*/
using Content::get_reference;
-
+
/** Reference to contained index data member.
* (Meaningless for non-index reducers.)
* @deprecated For legacy reducers only.
*/
using Content::get_index_reference;
-
+
protected:
- /** Update the min/max value.
+ /** Updates the min/max value.
*/
void calc(const value_type& x)
{
- if (!is_set() || compare(comp_value(), comp_value(x))) set_value(x);
+ if (!has_value() || compare(comp_value(), comp_value(x))) set_value(x);
+ set_is_set();
}
-
- /** Assign the result of a `{min|max}_of(view, value)` expression to the
+
+ /** Assigns the result of a `{min|max}_of(view, value)` expression to the
* view.
*
* @see rhs_proxy
@@ -1202,21 +1325,21 @@ protected:
{
calc(rhs.value(this));
}
-
+
};
/** Base class for min and max monoid classes.
*
- * The unique characteristic of minimum and maximum reducers is that they
- * incorporate a comparator functor that defines what “minimum” or “maximum”
+ * The unique characteristic of minimum and maximum reducers is that they
+ * incorporate a comparator functor that defines what "minimum" or "maximum"
* means. The monoid for a reducer contains the comparator that will be used
* for the reduction. If the comparator is a function or a class with state,
* then each view will have a pointer to the comparator.
*
* This means that the `construct()` functions first construct the monoid
- * (possibly with an explicit comparator argument), and then construct the
- * view with a pointer to the monoid’s comparator.
+ * (possibly with an explicit comparator argument), and then construct the
+ * view with a pointer to the monoid's comparator.
*
* @tparam View The view class.
* @tparam Align If true, reducers instantiated on this monoid will be
@@ -1230,14 +1353,13 @@ protected:
template <typename View, bool Align = false>
class monoid_base : public monoid_with_view<View, Align>
{
- typedef typename View::compare_type compare_type;
- typedef typename View::less_type less_type;
- const compare_type m_compare;
+ typedef typename View::compare_type compare_type;
+ typedef typename View::less_type less_type;
+
+ const compare_type m_compare;
const compare_type* compare_pointer() const { return &m_compare; }
-
- using cilk::monoid_base<typename View::value_type, View>::provisional;
-
+
public:
/** Default constructor uses default comparator.
@@ -1250,51 +1372,68 @@ public:
*/
monoid_base(const compare_type& compare) : m_compare(compare) {}
- /** Create an identity view.
+ /** Creates an identity view.
*
* List view identity constructors take the list allocator as an argument.
*
- * @param v The address of the uninitialized memory in which the view
+ * @param v The address of the uninitialized memory in which the view
* will be constructed.
*/
void identity(View *v) const { ::new((void*) v) View(compare_pointer()); }
-
+
/** @name construct functions
*
* Min/max monoid `construct()` functions optionally take one or two value
* arguments, a @ref move_in argument, and/or a comparator argument.
*/
//@{
-
+
template <typename Monoid>
static void construct(Monoid* monoid, View* view)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(monoid->compare_pointer()) ); }
+ {
+ provisional_guard<Monoid> mg( new((void*) monoid) Monoid );
+ mg.confirm_if( new((void*) view) View(monoid->compare_pointer()) );
+ }
template <typename Monoid, typename T1>
static void construct(Monoid* monoid, View* view, const T1& x1)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1, monoid->compare_pointer()) ); }
+ {
+ provisional_guard<Monoid> mg( new((void*) monoid) Monoid );
+ mg.confirm_if( new((void*) view) View(x1, monoid->compare_pointer()) );
+ }
template <typename Monoid, typename T1, typename T2>
- static void construct(Monoid* monoid, View* view, const T1& x1, const T2& x2)
- { provisional( new ((void*)monoid) Monoid() ).confirm_if(
- new ((void*)view) View(x1, x2, monoid->compare_pointer()) ); }
+ static void construct(Monoid* monoid, View* view,
+ const T1& x1, const T2& x2)
+ {
+ provisional_guard<Monoid> mg( new((void*) monoid) Monoid );
+ mg.confirm_if( new((void*) view) View(x1, x2,
+ monoid->compare_pointer()) );
+ }
template <typename Monoid>
static void construct(Monoid* monoid, View* view, const less_type& compare)
- { provisional( new ((void*)monoid) Monoid(compare) ).confirm_if(
- new ((void*)view) View(monoid->compare_pointer()) ); }
+ {
+ provisional_guard<Monoid> mg( new((void*) monoid) Monoid(compare) );
+ mg.confirm_if( new((void*) view) View(monoid->compare_pointer()) );
+ }
template <typename Monoid, typename T1>
- static void construct(Monoid* monoid, View* view, const T1& x1, const less_type& compare)
- { provisional( new ((void*)monoid) Monoid(compare) ).confirm_if(
- new ((void*)view) View(x1, monoid->compare_pointer()) ); }
+ static void construct(Monoid* monoid, View* view, const T1& x1,
+ const less_type& compare)
+ {
+ provisional_guard<Monoid> mg( new((void*) monoid) Monoid(compare) );
+ mg.confirm_if( new((void*) view) View(x1, monoid->compare_pointer()) );
+ }
template <typename Monoid, typename T1, typename T2>
- static void construct(Monoid* monoid, View* view, const T1& x1, const T2& x2, const less_type& compare)
- { provisional( new ((void*)monoid) Monoid(compare) ).confirm_if(
- new ((void*)view) View(x1, x2, monoid->compare_pointer()) ); }
+ static void construct(Monoid* monoid, View* view,
+ const T1& x1, const T2& x2, const less_type& compare)
+ {
+ provisional_guard<Monoid> mg( new((void*) monoid) Monoid(compare) );
+ mg.confirm_if( new((void*) view) View(x1, x2,
+ monoid->compare_pointer()) );
+ }
//@}
};
@@ -1312,7 +1451,7 @@ public:
/** The maximum reducer view class.
*
- * This is the view class for reducers created with
+ * This is the view class for reducers created with
* `cilk::reducer< cilk::op_max<Type, Compare> >`. It accumulates the maximum,
* as determined by a comparator, of a set of values which have occurred as
* arguments to the `calc_max()` function. The accumulated value will be the
@@ -1323,16 +1462,16 @@ public:
* argument value which is not less than any other argument value, i.e., the
* maximum.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `calc_max()` function would be used in an expression like
* `r->calc_max(a)` where `r` is an op_max reducer variable.
*
* @tparam Type The type of the values compared by the reducer. This will
- * be the value type of a monoid_with_view that is
+ * be the value type of a monoid_with_view that is
* instantiated with this view.
* @tparam Compare A `Strict Weak Ordering` whose argument type is @a Type. It
- * defines the “less than” relation used to compute the
+ * defines the "less than" relation used to compute the
* maximum.
*
* @see ReducersMinMax
@@ -1340,56 +1479,54 @@ public:
*/
template <typename Type, typename Compare>
class op_max_view : public min_max_internal::view_base<
- min_max_internal::view_content<Type, Compare, true>,
+ min_max_internal::view_content<Type, Compare, true>,
Compare,
Compare>
{
typedef min_max_internal::view_base<
- min_max_internal::view_content<Type, Compare, true>,
+ min_max_internal::view_content<Type, Compare, true>,
Compare,
Compare> base;
using base::calc;
using base::assign;
friend class min_max_internal::rhs_proxy<op_max_view>;
-
+
public:
/** @name Constructors.
*
- * All op_max_view constructors simply pass their arguments on to the
+ * All op_max_view constructors simply pass their arguments on to the
* @ref view_base base class.
*/
//@{
-
- op_max_view() : base() {}
-
+
template <typename T1>
op_max_view(const T1& x1) : base(x1) {}
-
+
template <typename T1, typename T2>
op_max_view(const T1& x1, const T2& x2) : base(x1, x2) {}
-
- //@}
+
+ //@}
/** @name View modifier operations.
*/
//@{
-
- /** Maximize with a value.
+
+ /** Maximizes with a value.
*
- * If @a x is greater than the current value of the view (as defined by
- * the reducer’s comparator), or if the view was created without an
- * initial value and its value has never been updated (with `calc_max()`
+ * If @a x is greater than the current value of the view (as defined by
+ * the reducer's comparator), or if the view was created without an
+ * initial value and its value has never been updated (with `calc_max()`
* or `= max_of()`), then the value of the view is set to @a x.
*
- * @param x The value to maximize the view’s value with.
+ * @param x The value to maximize the view's value with.
*
* @return A reference to the view. (Allows chaining
* `view.comp_max(a).comp_max(b)…`.)
*/
op_max_view& calc_max(const Type& x) { calc(x); return *this; }
- /** Assign the result of a `max_of(view, value)` expression to the view.
+ /** Assigns the result of a `max_of(view, value)` expression to the view.
*
* @param rhs An rhs_proxy value created by a `max_of(view, value)`
* expression.
@@ -1398,16 +1535,16 @@ public:
*
* @see min_max_internal::view_base::rhs_proxy
*/
- op_max_view& operator=(const min_max_internal::rhs_proxy<op_max_view>& rhs)
+ op_max_view& operator=(const min_max_internal::rhs_proxy<op_max_view>& rhs)
{ assign(rhs); return *this; }
-
+
//@}
};
-/** Compute the maximum of the value in an op_max_view and another value.
+/** Computes the maximum of the value in an op_max_view and another value.
*
- * The result of this computation can only be assigned back to the original
+ * The result of this computation can only be assigned back to the original
* view or used in another max_of() call. For example,
*
* *reducer = max_of(*reducer, x);
@@ -1430,7 +1567,7 @@ max_of(const Type& value, const op_max_view<Type, Compare>& view)
return min_max_internal::make_proxy(value, view);
}
-/** Nested maximum computation.
+/** Computes nested maximum.
*
* Compute the maximum of the result of a max_of() call and another value.
*
@@ -1444,7 +1581,7 @@ max_of(const Type& value, const op_max_view<Type, Compare>& view)
*/
template <typename Type, typename Compare>
inline min_max_internal::rhs_proxy< op_max_view<Type, Compare> >
-max_of(const min_max_internal::rhs_proxy< op_max_view<Type, Compare> >& proxy,
+max_of(const min_max_internal::rhs_proxy< op_max_view<Type, Compare> >& proxy,
const Type& value)
{
return proxy.calc(value);
@@ -1453,7 +1590,7 @@ max_of(const min_max_internal::rhs_proxy< op_max_view<Type, Compare> >& proxy,
/// @copydoc max_of(const min_max_internal::rhs_proxy< op_max_view<Type, Compare> >&, const Type&)
template <typename Type, typename Compare>
inline min_max_internal::rhs_proxy< op_max_view<Type, Compare> >
-max_of(const Type& value,
+max_of(const Type& value,
const min_max_internal::rhs_proxy< op_max_view<Type, Compare> >& proxy)
{
return proxy.calc(value);
@@ -1470,8 +1607,8 @@ max_of(const Type& value,
* @see op_max_view
*/
template <typename Type, typename Compare=std::less<Type>, bool Align = false>
-class op_max :
- public min_max_internal::monoid_base<op_max_view<Type, Compare>, Align>
+class op_max :
+ public min_max_internal::monoid_base<op_max_view<Type, Compare>, Align>
{
typedef min_max_internal::monoid_base<op_max_view<Type, Compare>, Align>
base;
@@ -1495,7 +1632,7 @@ public:
/** The minimum reducer view class.
*
- * This is the view class for reducers created with
+ * This is the view class for reducers created with
* `cilk::reducer< cilk::op_min<Type, Compare> >`. It accumulates the minimum,
* as determined by a comparator, of a set of values which have occurred as
* arguments to the `calc_min()` function. The accumulated value will be the
@@ -1506,16 +1643,16 @@ public:
* argument value which no other argument value is less than, i.e., the
* minimum.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `calc_min()` function would be used in an expression like
* `r->calc_min(a)` where `r` is an op_min reducer variable.
*
- * @tparam Type The type of the values compared by the reducer. This will
- * be the value type of a monoid_with_view that is
+ * @tparam Type The type of the values compared by the reducer. This will
+ * be the value type of a monoid_with_view that is
* instantiated with this view.
- * @tparam Compare A `Strict Weak Ordering` whose argument type is @a Type. It
- * defines the “less than” relation used to compute the
+ * @tparam Compare A `Strict Weak Ordering` whose argument type is @a Type. It
+ * defines the "less than" relation used to compute the
* minimum.
*
* @see ReducersMinMax
@@ -1523,12 +1660,12 @@ public:
*/
template <typename Type, typename Compare>
class op_min_view : public min_max_internal::view_base<
- min_max_internal::view_content<Type, Compare, false>,
+ min_max_internal::view_content<Type, Compare, false>,
Compare,
min_max_internal::reverse_predicate<Compare, Type> >
{
typedef min_max_internal::view_base<
- min_max_internal::view_content<Type, Compare, false>,
+ min_max_internal::view_content<Type, Compare, false>,
Compare,
min_max_internal::reverse_predicate<Compare, Type> > base;
using base::calc;
@@ -1538,40 +1675,38 @@ class op_min_view : public min_max_internal::view_base<
public:
/** @name Constructors.
*
- * All op_min_view constructors simply pass their arguments on to the
+ * All op_min_view constructors simply pass their arguments on to the
* @ref view_base base class.
*/
//@{
-
- op_min_view() : base() {}
-
+
template <typename T1>
op_min_view(const T1& x1) : base(x1) {}
-
+
template <typename T1, typename T2>
op_min_view(const T1& x1, const T2& x2) : base(x1, x2) {}
-
- //@}
+
+ //@}
/** @name View modifier operations.
*/
//@{
-
- /** Minimize with a value.
+
+ /** Minimizes with a value.
*
* If @a x is less than the current value of the view (as defined by the
- * reducer’s comparator), or if the view was created without an initial
+ * reducer's comparator), or if the view was created without an initial
* value and its value has never been updated (with `calc_min()` or
* `= min_of()`), then the value of the view is set to @a x.
*
- * @param x The value to minimize the view’s value with.
+ * @param x The value to minimize the view's value with.
*
* @return A reference to the view. (Allows chaining
* `view.comp_min(a).comp_min(b)…`.)
*/
op_min_view& calc_min(const Type& x) { calc(x); return *this; }
- /** Assign the result of a `min_of(view, value)` expression to the view.
+ /** Assigns the result of a `min_of(view, value)` expression to the view.
*
* @param rhs An rhs_proxy value created by a `min_of(view, value)`
* expression.
@@ -1580,12 +1715,12 @@ public:
*
* @see min_max_internal::view_base::rhs_proxy
*/
- op_min_view& operator=(const min_max_internal::rhs_proxy<op_min_view>& rhs)
+ op_min_view& operator=(const min_max_internal::rhs_proxy<op_min_view>& rhs)
{ assign(rhs); return *this; }
};
-/** Compute the minimum of the value in a view and another value.
+/** Computes the minimum of the value in a view and another value.
*
* The result of this computation can only be assigned back to the original
* view or used in another min_of() call. For example,
@@ -1610,7 +1745,7 @@ min_of(const Type& value, const op_min_view<Type, Compare>& view)
return min_max_internal::make_proxy(value, view);
}
-/** Nested minimum computation.
+/** Computes nested minimum.
*
* Compute the minimum of the result of a min_of() call and another value.
*
@@ -1624,7 +1759,7 @@ min_of(const Type& value, const op_min_view<Type, Compare>& view)
*/
template <typename Type, typename Compare>
inline min_max_internal::rhs_proxy< op_min_view<Type, Compare> >
-min_of(const min_max_internal::rhs_proxy< op_min_view<Type, Compare> >& proxy,
+min_of(const min_max_internal::rhs_proxy< op_min_view<Type, Compare> >& proxy,
const Type& value)
{
return proxy.calc(value);
@@ -1633,7 +1768,7 @@ min_of(const min_max_internal::rhs_proxy< op_min_view<Type, Compare> >& proxy,
/// @copydoc min_of(const min_max_internal::rhs_proxy< op_min_view<Type, Compare> >&, const Type&)
template <typename Type, typename Compare>
inline min_max_internal::rhs_proxy< op_min_view<Type, Compare> >
-min_of(const Type& value,
+min_of(const Type& value,
const min_max_internal::rhs_proxy< op_min_view<Type, Compare> >& proxy)
{
return proxy.calc(value);
@@ -1673,7 +1808,7 @@ public:
/** The maximum index reducer view class.
*
- * This is the view class for reducers created with
+ * This is the view class for reducers created with
* `cilk::reducer< cilk::op_max_index<Index, Type, Compare> >`. It accumulates
* the maximum, as determined by a comparator, of a set of values which have
* occurred as arguments to the `calc_max()` function, and records the index
@@ -1684,33 +1819,33 @@ public:
* argument value which is not less than any other argument value, i.e., the
* maximum.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `calc_max()` function would be used in an expression like
* `r->calc_max(i, a)`where `r` is an op_max_index reducer
* variable.
*
- * @note The word “index” suggests an integer index into an array, but there
+ * @note The word "index" suggests an integer index into an array, but there
* is no restriction on the index type or how it should be used. In
- * general, it may be convenient to use it for any kind of key that
+ * general, it may be convenient to use it for any kind of key that
* can be used to locate the maximum value in the collection that it
- * came from — for example:
+ * came from - for example:
* - An index into an array.
* - A key into an STL map.
* - An iterator into any STL container.
*
- * @note A max_index reducer is essentially a max reducer whose value type
+ * @note A max_index reducer is essentially a max reducer whose value type
* is a `std::pair<Index, Type>`. This fact is camouflaged in the view
* `calc_max` function, the global `max_of` functions, and the reducer
* value constructor, which can all take an index argument and a value
* argument as an alternative to a single `std::pair` argument.
* However, the reducer `set_value()`, `get_value()`, `move_in()`, and
- * `move_out()` functions work only with pairs, not with individual
+ * `move_out()` functions work only with pairs, not with individual
* value and/or index arguments.
*
* @tparam Index The type of the indices associated with the values.
- * @tparam Type The type of the values compared by the reducer. This will
- * be the value type of a monoid_with_view that is
+ * @tparam Type The type of the values compared by the reducer. This will
+ * be the value type of a monoid_with_view that is
* instantiated with this view.
* @tparam Compare Used to compare the values. It must be a binary predicate.
* If it is omitted, then the view computes the conventional
@@ -1737,65 +1872,65 @@ class op_max_index_view : public min_max_internal::view_base<
public:
/** @name Constructors.
*
- * All op_max_index_view constructors simply pass their arguments on to the
+ * All op_max_index_view constructors simply pass their arguments on to the
* @ref view_base base class, except for the `(index, value [, compare])`
* constructors, which create a `std::pair` containing the index and value.
*/
//@{
-
+
op_max_index_view() : base() {}
-
+
template <typename T1>
op_max_index_view(const T1& x1) : base(x1) {}
-
+
template <typename T1, typename T2>
op_max_index_view(const T1& x1, const T2& x2) : base(x1, x2) {}
-
+
template <typename T1, typename T2, typename T3>
op_max_index_view(const T1& x1, const T2& x2, const T3& x3) : base(x1, x2, x3) {}
-
+
op_max_index_view(const Index& i, const Type& v) : base(pair_type(i, v)) {}
-
- op_max_index_view(const Index& i, const Type& v, const typename base::compare_type* c) :
+
+ op_max_index_view(const Index& i, const Type& v, const typename base::compare_type* c) :
base(pair_type(i, v), c) {}
-
- //@}
- /** Maximize with a value and index.
+ //@}
+
+ /** Maximizes with a value and index.
*
- * If @a x is greater than the current value of the view (as defined by
- * the reducer’s comparator), or if the view was created without an
- * initial value and its value has never been updated (with `calc_max()`
+ * If @a x is greater than the current value of the view (as defined by
+ * the reducer's comparator), or if the view was created without an
+ * initial value and its value has never been updated (with `calc_max()`
* or `= max_of()`), then the value of the view is set to @a x, and the
* index is set to @a i..
*
* @param i The index of the value @a x.
- * @param x The value to maximize the view’s value with.
+ * @param x The value to maximize the view's value with.
*
- * @return A reference to the view. (Allows
+ * @return A reference to the view. (Allows
* `view.comp_max(i, a).comp_max(j, b)…`.)
*/
- op_max_index_view& calc_max(const Index& i, const Type& x)
+ op_max_index_view& calc_max(const Index& i, const Type& x)
{ calc(pair_type(i, x)); return *this; }
- /** Maximize with an index/value pair.
+ /** Maximizes with an index/value pair.
*
* If @a pair.second is greater than the current value of the view (as
- * defined by the reducer’s comparator), or if the view was created
+ * defined by the reducer's comparator), or if the view was created
* without an initial value and its value has never been updated (with
* `calc_max()` or `= max_of()`), then the value of the view is set to
* @a pair.second, and the index is set to @a pair.first.
*
- * @param pair A pair containing a value to maximize the view’s value
+ * @param pair A pair containing a value to maximize the view's value
* with and its associated index.
*
* @return A reference to the view. (Allows
* `view.comp_max(p1).comp_max(p2)…`.)
*/
- op_max_index_view& calc_max(const pair_type& pair)
+ op_max_index_view& calc_max(const pair_type& pair)
{ calc(pair); return *this; }
- /** Assign the result of a `max_of(view, index, value)` expression to the
+ /** Assigns the result of a `max_of(view, index, value)` expression to the
* view.
*
* @param rhs An rhs_proxy value created by a `max_of(view, index, value)`
@@ -1805,12 +1940,12 @@ public:
*
* @see min_max_internal::view_base::rhs_proxy
*/
- op_max_index_view& operator=(const min_max_internal::rhs_proxy<op_max_index_view>& rhs)
+ op_max_index_view& operator=(const min_max_internal::rhs_proxy<op_max_index_view>& rhs)
{ assign(rhs); return *this; }
};
-/** Compute the maximum of the value in a view and another value.
+/** Computes the maximum of the value in a view and another value.
*
* The result of this computation can only be assigned back to the original
* view or used in another max_of() call. For example,
@@ -1855,7 +1990,7 @@ max_of(const std::pair<Index, Type>& pair,
return min_max_internal::make_proxy(pair, view);
}
-/** Nested computation of the maximum of the value in a view and other values.
+/** Computes the nested maximum between the value in a view and other values.
*
* Compute the maximum of the result of a max_of() call and another value.
*
@@ -1918,7 +2053,7 @@ template < typename Index
, typename Compare=std::less<Type>
, bool Align = false
>
-class op_max_index : public min_max_internal::monoid_base<op_max_index_view<Index, Type, Compare>, Align>
+class op_max_index : public min_max_internal::monoid_base<op_max_index_view<Index, Type, Compare>, Align>
{
typedef min_max_internal::monoid_base<
op_max_index_view<Index, Type, Compare>, Align> base;
@@ -1944,7 +2079,7 @@ public:
/** The minimum index reducer view class.
*
- * This is the view class for reducers created with
+ * This is the view class for reducers created with
* `cilk::reducer<cilk::op_min_index<Index, Type, Compare> >`. It accumulates
* the minimum, as determined by a comparator, of a set of values which have
* occurred as arguments to the `calc_min()` function, and records the index
@@ -1955,22 +2090,22 @@ public:
* argument value which no other argument value is less than, i.e., the
* minimum.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `calc_min()` function would be
* used in an expression like `r->calc_min(i, a)`where `r` is an
* op_min_index reducer variable.
*
- * @note The word “index” suggests an integer index into an array, but there
+ * @note The word "index" suggests an integer index into an array, but there
* is no restriction on the index type or how it should be used. In
- * general, it may be convenient to use it for any kind of key that
+ * general, it may be convenient to use it for any kind of key that
* can be used to locate the minimum value in the collection that it
- * came from — for example:
+ * came from - for example:
* - An index into an array.
* - A key into an STL map.
* - An iterator into any STL container.
*
- * @note A min_index reducer is essentially a min reducer whose value type
+ * @note A min_index reducer is essentially a min reducer whose value type
* is a `std::pair<Index, Type>`. This fact is camouflaged in the view
* `calc_min` function, the global `min_of` functions, and the reducer
* value constructor, which can all take an index argument and a value
@@ -1980,8 +2115,8 @@ public:
* value and/or index arguments.
*
* @tparam Index The type of the indices associated with the values.
- * @tparam Type The type of the values compared by the reducer. This will
- * be the value type of a monoid_with_view that is
+ * @tparam Type The type of the values compared by the reducer. This will
+ * be the value type of a monoid_with_view that is
* instantiated with this view.
* @tparam Compare Used to compare the values. It must be a binary predicate.
* If it is omitted, then the view computes the conventional
@@ -2008,65 +2143,65 @@ class op_min_index_view : public min_max_internal::view_base<
public:
/** @name Constructors.
*
- * All op_min_index_view constructors simply pass their arguments on to the
+ * All op_min_index_view constructors simply pass their arguments on to the
* @ref view_base base class, except for the `(index, value [, compare])`
* constructors, which create a `std::pair` containing the index and value.
*/
//@{
-
+
op_min_index_view() : base() {}
-
+
template <typename T1>
op_min_index_view(const T1& x1) : base(x1) {}
-
+
template <typename T1, typename T2>
op_min_index_view(const T1& x1, const T2& x2) : base(x1, x2) {}
-
+
template <typename T1, typename T2, typename T3>
op_min_index_view(const T1& x1, const T2& x2, const T3& x3) : base(x1, x2, x3) {}
-
+
op_min_index_view(const Index& i, const Type& v) : base(pair_type(i, v)) {}
-
- op_min_index_view(const Index& i, const Type& v, const typename base::compare_type* c) :
+
+ op_min_index_view(const Index& i, const Type& v, const typename base::compare_type* c) :
base(pair_type(i, v), c) {}
-
- //@}
- /** Minimize with a value and index.
+ //@}
+
+ /** Minimizes with a value and index.
*
- * If @a x is greater than the current value of the view (as defined by
- * the reducer’s comparator), or if the view was created without an
- * initial value and its value has never been updated (with `calc_min()`
+ * If @a x is greater than the current value of the view (as defined by
+ * the reducer's comparator), or if the view was created without an
+ * initial value and its value has never been updated (with `calc_min()`
* or `= min_of()`), then the value of the view is set to @a x, and the
* index is set to @a i..
*
* @param i The index of the value @a x.
- * @param x The value to minimize the view’s value with.
+ * @param x The value to minimize the view's value with.
*
- * @return A reference to the view. (Allows
+ * @return A reference to the view. (Allows
* `view.comp_min(i, a).comp_min(j, b)…`.)
*/
- op_min_index_view& calc_min(const Index& i, const Type& x)
+ op_min_index_view& calc_min(const Index& i, const Type& x)
{ calc(pair_type(i, x)); return *this; }
- /** Maximize with an index/value pair.
+ /** Maximizes with an index/value pair.
*
* If @a pair.second is less than the current value of the view (as
- * defined by the reducer’s comparator), or if the view was created
+ * defined by the reducer's comparator), or if the view was created
* without an initial value and its value has never been updated (with
* `calc_min()` or `= min_of()`), then the value of the view is set to
* @a pair.second, and the index is set to @a pair.first.
*
- * @param pair A pair containing a value to minimize the view’s value
+ * @param pair A pair containing a value to minimize the view's value
* with and its associated index.
*
* @return A reference to the view. (Allows
* `view.comp_min(p1).comp_min(p2)…`.)
*/
- op_min_index_view& calc_min(const pair_type& pair)
+ op_min_index_view& calc_min(const pair_type& pair)
{ calc(pair); return *this; }
- /** Assign the result of a `min_of(view, index, value)` expression to the
+ /** Assigns the result of a `min_of(view, index, value)` expression to the
* view.
*
* @param rhs An rhs_proxy value created by a `min_of(view, index, value)`
@@ -2076,12 +2211,12 @@ public:
*
* @see min_max_internal::view_base::rhs_proxy
*/
- op_min_index_view& operator=(const min_max_internal::rhs_proxy<op_min_index_view>& rhs)
+ op_min_index_view& operator=(const min_max_internal::rhs_proxy<op_min_index_view>& rhs)
{ assign(rhs); return *this; }
};
-/** Compute the minimum of the value in a view and another value.
+/** Computes the minimum of the value in a view and another value.
*
* The result of this computation can only be assigned back to the original
* view or used in another min_of() call. For example,
@@ -2126,7 +2261,7 @@ min_of(const std::pair<Index, Type>& pair,
return min_max_internal::make_proxy(pair, view);
}
-/** Nested computation of the minimum of the value in a view and other values.
+/** Computes nested minimum between the value in a view and other values.
*
* Compute the minimum of the result of a min_of() call and another value.
*
@@ -2176,7 +2311,7 @@ min_of(const std::pair<Index, Type>& pair,
/** Monoid class for minimum reductions with index. Instantiate the
* cilk::reducer template class with an op_min_index monoid to create a
- * min_index reducer class. For example, to compute the minimum of an array of
+ * min_index reducer class. For example, to compute the minimum of an array of
* `double` values and the array index of the min value:
*
* cilk::reducer< cilk::op_min_index<unsigned, double> > r;
@@ -2189,7 +2324,7 @@ template < typename Index
, typename Compare=std::less<Type>
, bool Align = false
>
-class op_min_index : public min_max_internal::monoid_base<op_min_index_view<Index, Type, Compare>, Align>
+class op_min_index : public min_max_internal::monoid_base<op_min_index_view<Index, Type, Compare>, Align>
{
typedef min_max_internal::monoid_base<
op_min_index_view<Index, Type, Compare>, Align> base;
@@ -2209,18 +2344,18 @@ public:
* reducer_max is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
* example, a value is maximized with a `reducer<%op_max>` with
- * `r->calc_max(a)`, but a value can be maximized with a `%reducer_max` with
+ * `r->calc_max(a)`, but a value can be maximized with a `%reducer_max` with
* `r.calc_max(a)`.
*
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_max.
+ * reducers rather than the old wrappers like reducer_max.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_max`
+ * @note Implicit conversions are provided between `%reducer_max`
* and `reducer<%op_max>`. This allows incremental code
* conversion: old code that used `%reducer_max` can pass a
* `%reducer_max` to a converted function that now expects a
@@ -2228,7 +2363,7 @@ public:
* versa. **But see @ref redminmax_compatibility.**
*
* @tparam Type The value type of the reducer.
- * @tparam Compare The “less than” comparator type for the reducer.
+ * @tparam Compare The "less than" comparator type for the reducer.
*
* @see op_max
* @see op_max_view
@@ -2240,53 +2375,53 @@ template <typename Type, typename Compare=std::less<Type> >
class reducer_max : public reducer< op_max<Type, Compare, true> >
{
__CILKRTS_STATIC_ASSERT(
- ::cilk::internal::class_is_empty<
- typename ::cilk::internal::binary_functor<Compare>::type >::value,
+ ::cilk::internal::class_is_empty<
+ typename ::cilk::internal::binary_functor<Compare>::type >::value,
"cilk::reducer_max<Type, Compare> only works with "
"an empty Compare class");
typedef reducer< op_max<Type, Compare, true> > base;
public:
-
+
/// Type of data in a reducer_max.
typedef Type basic_value_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type View;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type monoid_type;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
- /// The view’s rhs proxy type.
+ /// The view's rhs proxy type.
typedef min_max_internal::rhs_proxy<View> rhs_proxy;
-
+
using base::view;
/** @name Constructors
*/
//@{
-
- /// Construct the wrapper in its identity state (either `!is_set()`, or
+
+ /// Constructs the wrapper in its identity state (either `!is_set()`, or
/// `value() == identity value`).
reducer_max() : base() {}
- /// Construct the wrapper with a specified initial value.
+ /// Constructs the wrapper with a specified initial value.
explicit reducer_max(const Type& initial_value) : base(initial_value) {}
- /// Construct the wrapper in its identity state with a specified
+ /// Constructs the wrapper in its identity state with a specified
/// comparator.
explicit reducer_max(const Compare& comp) : base(comp) {}
- /// Construct the wrapper with a specified initial value and a specified
+ /// Constructs the wrapper with a specified initial value and a specified
/// comparator.
reducer_max(const Type& initial_value, const Compare& comp)
: base(initial_value, comp) {}
-
+
//@}
/** @name Forwarded functions
@@ -2294,25 +2429,25 @@ public:
* simply forwarded to the contained @ref op_max_view. */
//@{
- /// @copydoc cilk_lib_1_0::min_max_internal::view_content::is_set() const
+ /// @copydoc cilk_lib_1_1::min_max_internal::view_content::is_set() const
bool is_set() const { return view().is_set(); }
/// @copydoc op_max_view::calc_max(const Type&)
- reducer_max& calc_max(const Type& x)
+ reducer_max& calc_max(const Type& x)
{ view().calc_max(x); return *this; }
- /// @copydoc op_max_view::operator=(const min_max_internal::rhs_proxy<op_max_view>&)
+ /// @copydoc op_max_view::operator=(const min_max_internal::rhs_proxy<op_max_view>&)
reducer_max& operator=(const rhs_proxy& rhs)
{ view() = rhs; return *this; }
-
+
//@}
- /** Allow read-only access to the value within the current view.
- *
+ /** Allows read-only access to the value within the current view.
+ *
* @returns A const reference to the value within the current view.
*/
const Type& get_reference() const { return view().get_reference(); }
-
+
/// @name Dereference
/** Dereferencing a wrapper is a no-op. It simply returns the wrapper.
* Combined with the rule that a wrapper forwards view operations to the
@@ -2336,12 +2471,12 @@ public:
reducer_max* operator->() { return this; }
reducer_max const* operator->() const { return this; }
//@}
-
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
@@ -2352,7 +2487,7 @@ public:
{
return *reinterpret_cast< reducer< op_max<Type, Compare, false> >* >(this);
}
-
+
operator const reducer< op_max<Type, Compare, false> >& () const
{
return *reinterpret_cast< const reducer< op_max<Type, Compare, false> >* >(this);
@@ -2363,18 +2498,18 @@ public:
/// @cond internal
// The legacy definition of max_of(reducer_max, value) has different
-// behavior and a different return type than this definition. We add an
+// behavior and a different return type than this definition. We add an
// unused third argument to this version of the function to give it a different
-// signature, so that they won’t end up sharing a single object file entry.
+// signature, so that they won't end up sharing a single object file entry.
struct max_of_1_0_t {};
const max_of_1_0_t max_of_1_0 = {};
/// @endcond
-/** Compute the maximum of the value in a reducer_max and another value.
+/** Computes the maximum of the value in a reducer_max and another value.
*
* @deprecated Because reducer_max is deprecated.
*
- * The result of this computation can only be assigned back to the original
+ * The result of this computation can only be assigned back to the original
* reducer or used in another max_of() call. For example,
*
* reducer = max_of(reducer, x);
@@ -2409,18 +2544,18 @@ max_of(const Type& value, const reducer_max<Type, Compare>& r,
* reducer_min is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
* example, a value is minimized with a `reducer<%op_min>` with
- * `r->calc_min(a)`, but a value can be minimized with a `%reducer_min` with
+ * `r->calc_min(a)`, but a value can be minimized with a `%reducer_min` with
* `r.calc_min(a)`.
*
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_min.
+ * reducers rather than the old wrappers like reducer_min.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_min`
+ * @note Implicit conversions are provided between `%reducer_min`
* and `reducer<%op_min>`. This allows incremental code
* conversion: old code that used `%reducer_min` can pass a
* `%reducer_min` to a converted function that now expects a
@@ -2428,7 +2563,7 @@ max_of(const Type& value, const reducer_max<Type, Compare>& r,
* versa. **But see @ref redminmax_compatibility.**
*
* @tparam Type The value type of the reducer.
- * @tparam Compare The “less than” comparator type for the reducer.
+ * @tparam Compare The "less than" comparator type for the reducer.
*
* @see op_min
* @see op_min_view
@@ -2441,52 +2576,52 @@ class reducer_min : public reducer< op_min<Type, Compare, true> >
{
__CILKRTS_STATIC_ASSERT(
::cilk::internal::class_is_empty<
- typename ::cilk::internal::binary_functor<Compare>::type >::value,
+ typename ::cilk::internal::binary_functor<Compare>::type >::value,
"cilk::reducer_min<Type, Compare> only works with "
"an empty Compare class");
typedef reducer< op_min<Type, Compare, true> > base;
public:
-
+
/// Type of data in a reducer_min.
typedef Type basic_value_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type View;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type monoid_type;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
- /// The view’s rhs proxy type.
+ /// The view's rhs proxy type.
typedef min_max_internal::rhs_proxy<View> rhs_proxy;
-
+
using base::view;
/** @name Constructors
*/
//@{
-
- /// Construct the wrapper in its identity state (either `!is_set()`, or
+
+ /// Constructs the wrapper in its identity state (either `!is_set()`, or
/// `value() == identity value`).
reducer_min() : base() {}
- /// Construct the wrapper with a specified initial value.
+ /// Constructs the wrapper with a specified initial value.
explicit reducer_min(const Type& initial_value) : base(initial_value) {}
- /// Construct the wrapper in its identity state with a specified
+ /// Constructs the wrapper in its identity state with a specified
/// comparator.
explicit reducer_min(const Compare& comp) : base(comp) {}
- /// Construct the wrapper with a specified initial value and a specified
+ /// Constructs the wrapper with a specified initial value and a specified
/// comparator.
reducer_min(const Type& initial_value, const Compare& comp)
: base(initial_value, comp) {}
-
+
//@}
/** @name Forwarded functions
@@ -2494,25 +2629,25 @@ public:
* simply forwarded to the contained @ref op_min_view. */
//@{
- /// @copydoc cilk_lib_1_0::min_max_internal::view_content::is_set() const
+ /// @copydoc cilk_lib_1_1::min_max_internal::view_content::is_set() const
bool is_set() const { return view().is_set(); }
/// @copydoc op_min_view::calc_min(const Type&)
- reducer_min& calc_min(const Type& x)
+ reducer_min& calc_min(const Type& x)
{ view().calc_min(x); return *this; }
- /// @copydoc op_min_view::operator=(const min_max_internal::rhs_proxy<op_min_view>&)
+ /// @copydoc op_min_view::operator=(const min_max_internal::rhs_proxy<op_min_view>&)
reducer_min& operator=(const rhs_proxy& rhs)
{ view() = rhs; return *this; }
-
+
//@}
- /** Allow read-only access to the value within the current view.
- *
+ /** Allows read-only access to the value within the current view.
+ *
* @returns A const reference to the value within the current view.
*/
const Type& get_reference() const { return view().get_reference(); }
-
+
/// @name Dereference
/** Dereferencing a wrapper is a no-op. It simply returns the wrapper.
* Combined with the rule that a wrapper forwards view operations to the
@@ -2536,12 +2671,12 @@ public:
reducer_min* operator->() { return this; }
reducer_min const* operator->() const { return this; }
//@}
-
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
@@ -2552,7 +2687,7 @@ public:
{
return *reinterpret_cast< reducer< op_min<Type, Compare, false> >* >(this);
}
-
+
operator const reducer< op_min<Type, Compare, false> >& () const
{
return *reinterpret_cast< const reducer< op_min<Type, Compare, false> >* >(this);
@@ -2561,15 +2696,15 @@ public:
};
-/** Compute the minimum of a reducer and a value.
+/** Computes the minimum of a reducer and a value.
*
* @deprecated Because reducer_min is deprecated.
*/
//@{
// The legacy definition of min_of(reducer_min, value) has different
-// behavior and a different return type than this definition. We add an
+// behavior and a different return type than this definition. We add an
// unused third argument to this version of the function to give it a different
-// signature, so that they won’t end up sharing a single object file entry.
+// signature, so that they won't end up sharing a single object file entry.
struct min_of_1_0_t {};
const min_of_1_0_t min_of_1_0 = {};
@@ -2597,18 +2732,18 @@ min_of(const Type& value, const reducer_min<Type, Compare>& r,
* that reducer_max_index is a proxy for the contained view, so that
* accumulator variable update operations can be applied directly to the
* reducer. For example, a value is maximized with a `reducer<%op_max_index>`
- * with `r->calc_max(i, a)`, but a value can be maximized with a
+ * with `r->calc_max(i, a)`, but a value can be maximized with a
* `%reducer_max` with `r.calc_max(i, aa)`.
*
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_max.
+ * reducers rather than the old wrappers like reducer_max.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_max_index`
+ * @note Implicit conversions are provided between `%reducer_max_index`
* and `reducer<%op_max_index>`. This allows incremental code
* conversion: old code that used `%reducer_max_index` can pass a
* `%reducer_max_index` to a converted function that now expects a
@@ -2617,7 +2752,7 @@ min_of(const Type& value, const reducer_min<Type, Compare>& r,
*
* @tparam Index The index type of the reducer.
* @tparam Type The value type of the reducer.
- * @tparam Compare The “less than” comparator type for the reducer.
+ * @tparam Compare The "less than" comparator type for the reducer.
*
* @see op_max_index
* @see op_max_index_view
@@ -2629,42 +2764,42 @@ template < typename Index
, typename Type
, typename Compare = std::less<Type>
>
-class reducer_max_index :
+class reducer_max_index :
public reducer< op_max_index<Index, Type, Compare, true> >
{
__CILKRTS_STATIC_ASSERT(
- ::cilk::internal::class_is_empty<
- typename ::cilk::internal::binary_functor<Compare>::type >::value,
+ ::cilk::internal::class_is_empty<
+ typename ::cilk::internal::binary_functor<Compare>::type >::value,
"cilk::reducer_max_index<Type, Compare> only works with "
"an empty Compare class");
typedef reducer< op_max_index<Index, Type, Compare, true> > base;
public:
-
+
/// Type of data in a reducer_max_index.
typedef Type basic_value_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type View;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type monoid_type;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
- /// The view’s rhs proxy type.
+ /// The view's rhs proxy type.
typedef min_max_internal::rhs_proxy<View> rhs_proxy;
-
+
using base::view;
/** @name Constructors
*/
//@{
-
- /// Construct the wrapper in its identity state (`!is_set()`).
+
+ /// Constructs the wrapper in its identity state (`!is_set()`).
reducer_max_index() : base() {}
/// Construct with a specified initial index and value.
@@ -2672,10 +2807,10 @@ public:
const Type& initial_value)
: base(initial_index, initial_value) {}
- /// Construct the wrapper with a specified comparator.
+ /// Constructs the wrapper with a specified comparator.
explicit reducer_max_index(const Compare& comp) : base(comp) {}
- /// Construct the wrapper with a specified initial index, value,
+ /// Constructs the wrapper with a specified initial index, value,
/// and comparator.
reducer_max_index(const Index& initial_index,
const Type& initial_value,
@@ -2683,49 +2818,49 @@ public:
: base(initial_index, initial_value, comp) {}
//@}
-
+
/** @name Set / Get
*/
//@{
-
- /// Set the index and value of this object.
+
+ /// Sets the index and value of this object.
void set_value(const Index& index, const Type& value)
{ base::set_value(std::make_pair(index, value)); }
- /// Return the maximum value.
- const Type& get_value() const
+ /// Returns the maximum value.
+ const Type& get_value() const
{ return view().get_reference(); }
- /// Return the maximum index.
- const Index& get_index() const
+ /// Returns the maximum index.
+ const Index& get_index() const
{ return view().get_index_reference(); }
- /// Return a const reference to value data member in the view.
+ /// Returns a const reference to value data member in the view.
const Type& get_reference() const
{ return view().get_reference(); }
-
- /// Return a const reference to index data member in the view.
- const Index& get_index_reference() const
+
+ /// Returns a const reference to index data member in the view.
+ const Index& get_index_reference() const
{ return view().get_index_reference(); }
-
+
//@}
-
+
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_max_view. */
//@{
- /// @copydoc cilk_lib_1_0::min_max_internal::view_content::is_set() const
+ /// @copydoc cilk_lib_1_1::min_max_internal::view_content::is_set() const
bool is_set() const { return view().is_set(); }
/// @copydoc op_max_index_view::calc_max(const Index&, const Type&)
- reducer_max_index& calc_max(const Index& i, const Type& x)
+ reducer_max_index& calc_max(const Index& i, const Type& x)
{ view().calc_max(i, x); return *this; }
- /// @copydoc op_max_view::operator=(const min_max_internal::rhs_proxy<op_max_view>&)
+ /// @copydoc op_max_view::operator=(const min_max_internal::rhs_proxy<op_max_view>&)
reducer_max_index& operator=(const rhs_proxy& rhs)
{ view() = rhs; return *this; }
-
+
//@}
/// @name Dereference
@@ -2751,12 +2886,12 @@ public:
reducer_max_index* operator->() { return this; }
reducer_max_index const* operator->() const { return this; }
//@}
-
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
@@ -2767,13 +2902,13 @@ public:
{
return *reinterpret_cast< reducer< op_max_index<Index, Type, Compare, false> >* >(this);
}
-
+
operator const reducer< op_max_index<Index, Type, Compare, false> >& () const
{
return *reinterpret_cast< const reducer< op_max_index<Index, Type, Compare, false> >* >(this);
}
//@}
-
+
};
@@ -2783,18 +2918,18 @@ public:
* that reducer_min_index is a proxy for the contained view, so that
* accumulator variable update operations can be applied directly to the
* reducer. For example, a value is minimized with a `reducer<%op_min_index>`
- * with `r->calc_min(i, a)`, but a value can be minimized with a
+ * with `r->calc_min(i, a)`, but a value can be minimized with a
* `%reducer_min` with `r.calc_min(i, aa)`.
*
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_min.
+ * reducers rather than the old wrappers like reducer_min.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_min_index`
+ * @note Implicit conversions are provided between `%reducer_min_index`
* and `reducer<%op_min_index>`. This allows incremental code
* conversion: old code that used `%reducer_min_index` can pass a
* `%reducer_min_index` to a converted function that now expects a
@@ -2803,7 +2938,7 @@ public:
*
* @tparam Index The index type of the reducer.
* @tparam Type The value type of the reducer.
- * @tparam Compare The “less than” comparator type for the reducer.
+ * @tparam Compare The "less than" comparator type for the reducer.
*
* @see op_min_index
* @see op_min_index_view
@@ -2815,42 +2950,42 @@ template < typename Index
, typename Type
, typename Compare = std::less<Type>
>
-class reducer_min_index :
+class reducer_min_index :
public reducer< op_min_index<Index, Type, Compare, true> >
{
__CILKRTS_STATIC_ASSERT(
- ::cilk::internal::class_is_empty<
- typename ::cilk::internal::binary_functor<Compare>::type >::value,
+ ::cilk::internal::class_is_empty<
+ typename ::cilk::internal::binary_functor<Compare>::type >::value,
"cilk::reducer_min_index<Type, Compare> only works with "
"an empty Compare class");
typedef reducer< op_min_index<Index, Type, Compare, true> > base;
public:
-
+
/// Type of data in a reducer_min_index.
typedef Type basic_value_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
+
/// The view type for the reducer.
typedef typename base::view_type View;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type monoid_type;
-
+
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
- /// The view’s rhs proxy type.
+ /// The view's rhs proxy type.
typedef min_max_internal::rhs_proxy<View> rhs_proxy;
-
+
using base::view;
/** @name Constructors
*/
//@{
-
- /// Construct the wrapper in its identity state (`!is_set()`).
+
+ /// Constructs the wrapper in its identity state (`!is_set()`).
reducer_min_index() : base() {}
/// Construct with a specified initial index and value.
@@ -2858,10 +2993,10 @@ public:
const Type& initial_value)
: base(initial_index, initial_value) {}
- /// Construct the wrapper with a specified comparator.
+ /// Constructs the wrapper with a specified comparator.
explicit reducer_min_index(const Compare& comp) : base(comp) {}
- /// Construct the wrapper with a specified initial index, value,
+ /// Constructs the wrapper with a specified initial index, value,
/// and comparator.
reducer_min_index(const Index& initial_index,
const Type& initial_value,
@@ -2869,49 +3004,49 @@ public:
: base(initial_index, initial_value, comp) {}
//@}
-
+
/** @name Set / Get
*/
//@{
-
- /// Set the index and value of this object.
+
+ /// Sets the index and value of this object.
void set_value(const Index& index, const Type& value)
{ base::set_value(std::make_pair(index, value)); }
- /// Return the minimum value.
- const Type& get_value() const
+ /// Returns the minimum value.
+ const Type& get_value() const
{ return view().get_reference(); }
- /// Return the minimum index.
- const Index& get_index() const
+ /// Returns the minimum index.
+ const Index& get_index() const
{ return view().get_index_reference(); }
- /// Return a const reference to value data member in the view.
+ /// Returns a const reference to value data member in the view.
const Type& get_reference() const
{ return view().get_reference(); }
-
- /// Return a const reference to index data member in the view.
- const Index& get_index_reference() const
+
+ /// Returns a const reference to index data member in the view.
+ const Index& get_index_reference() const
{ return view().get_index_reference(); }
-
+
//@}
-
+
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_min_view. */
//@{
- /// @copydoc cilk_lib_1_0::min_max_internal::view_content::is_set() const
+ /// @copydoc cilk_lib_1_1::min_max_internal::view_content::is_set() const
bool is_set() const { return view().is_set(); }
/// @copydoc op_min_index_view::calc_min(const Index&, const Type&)
- reducer_min_index& calc_min(const Index& i, const Type& x)
+ reducer_min_index& calc_min(const Index& i, const Type& x)
{ view().calc_min(i, x); return *this; }
- /// @copydoc op_min_view::operator=(const min_max_internal::rhs_proxy<op_min_view>&)
+ /// @copydoc op_min_view::operator=(const min_max_internal::rhs_proxy<op_min_view>&)
reducer_min_index& operator=(const rhs_proxy& rhs)
{ view() = rhs; return *this; }
-
+
//@}
/// @name Dereference
@@ -2937,12 +3072,12 @@ public:
reducer_min_index* operator->() { return this; }
reducer_min_index const* operator->() const { return this; }
//@}
-
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
@@ -2953,19 +3088,19 @@ public:
{
return *reinterpret_cast< reducer< op_min_index<Index, Type, Compare, false> >* >(this);
}
-
+
operator const reducer< op_min_index<Index, Type, Compare, false> >& () const
{
return *reinterpret_cast< const reducer< op_min_index<Index, Type, Compare, false> >* >(this);
}
//@}
-
+
};
#ifndef CILK_LIBRARY_0_9_REDUCER_MINMAX
-} // namespace cilk_lib_1_0
-using namespace cilk_lib_1_0;
+} // namespace cilk_lib_1_1
+using namespace cilk_lib_1_1;
#endif
@@ -3017,7 +3152,7 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
* @see @ref page_reducers_in_c
*/
//@{
-
+
#ifdef CILK_C_DEFINE_REDUCERS
@@ -3045,7 +3180,7 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
#endif
-/** Max reducer type name.
+/** Declares max reducer type name.
*
* This macro expands into the identifier which is the name of the max reducer
* type for a specified numeric type.
@@ -3058,7 +3193,7 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
#define CILK_C_REDUCER_MAX_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_max_,tn)
-/** Declare a max reducer object.
+/** Declares a max reducer object.
*
* This macro expands into a declaration of a max reducer object for a specified numeric
* type. For example:
@@ -3068,7 +3203,7 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying the type of the
* reducer.
- * @param v The initial value for the reducer. (A value which can be assigned to the
+ * @param v The initial value for the reducer. (A value which can be assigned to the
* numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
@@ -3080,7 +3215,7 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
__CILKRTS_MKIDENT(cilk_c_reducer_max_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, v)
-/** Maximize with a value.
+/** Maximizes with a value.
*
* `CILK_C_REDUCER_MAX_CALC(reducer, v)` sets the current view of the
* reducer to the max of its previous value and a specified new value.
@@ -3100,27 +3235,27 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
/// @cond internal
-/** Declare the max reducer functions for a numeric type.
+/** Declares the max reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which implement
* the reducer functionality for the max reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MAX_DECLARATION(t,tn,id) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_MAX_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_max,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_max,tn);
-
-/** Define the max reducer functions for a numeric type.
+
+/** Defines the max reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement the
* reducer functionality for the max reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MAX_DEFINITION(t,tn,id) \
@@ -3129,9 +3264,9 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
{ if (*(t*)l < *(t*)r) *(t*)l = *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_max,tn) \
{ *(t*)v = id; }
-
+
//@{
-/** @def CILK_C_REDUCER_MAX_INSTANCE
+/** @def CILK_C_REDUCER_MAX_INSTANCE
* @brief Declare or define implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS` will be defined, and
@@ -3147,7 +3282,7 @@ struct legacy_reducer_downcast< reducer< op_min_index<Index, Type, Compare, Alig
#endif
//@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declare or define an instance of the reducer type and its functions for each
* numeric type.
*/
__CILKRTS_BEGIN_EXTERN_C
@@ -3184,7 +3319,7 @@ __CILKRTS_END_EXTERN_C
#define CILK_C_REDUCER_MAX_INDEX_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_max_index_,tn)
-/** Declare an op_max_index reducer object.
+/** Declares an op_max_index reducer object.
*
* This macro expands into a declaration of a max_index reducer object for a specified
* numeric type. For example:
@@ -3194,7 +3329,7 @@ __CILKRTS_END_EXTERN_C
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying the type of the
* reducer.
- * @param v The initial value for the reducer. (A value which can be assigned to the
+ * @param v The initial value for the reducer. (A value which can be assigned to the
* numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
@@ -3206,7 +3341,7 @@ __CILKRTS_END_EXTERN_C
__CILKRTS_MKIDENT(cilk_c_reducer_max_index_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, {0, v})
-/** Maximize with a value.
+/** Maximizes with a value.
*
* `CILK_C_REDUCER_MAX_INDEX_CALC(reducer, i, v)` sets the current view of the
* reducer to the max of its previous value and a specified new value.
@@ -3215,7 +3350,7 @@ __CILKRTS_END_EXTERN_C
* REDUCER_VIEW(reducer) = max_index(REDUCER_VIEW(reducer), v)
*
* If the value of the reducer is changed to @a v, then the index of the reducer is
- * changed to @a i.
+ * changed to @a i.
*
* @param reducer The reducer whose contained value and index are to be updated.
* @param i The index associated with the new value.
@@ -3231,7 +3366,7 @@ __CILKRTS_END_EXTERN_C
/// @cond internal
-/** Declare the max_index view type.
+/** Declares the max_index view type.
*
* The view of a max_index reducer is a structure containing both the
* maximum value for the reducer and the index that was associated with
@@ -3243,13 +3378,13 @@ __CILKRTS_END_EXTERN_C
t value; \
} __CILKRTS_MKIDENT(cilk_c_reducer_max_index_view_,tn)
-/** Declare the max_index reducer functions for a numeric type.
+/** Declares the max_index reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which implement
* the reducer functionality for the max_index reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MAX_INDEX_DECLARATION(t,tn,id) \
@@ -3259,14 +3394,14 @@ __CILKRTS_END_EXTERN_C
CILK_C_REDUCER_MAX_INDEX_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_max_index,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_max_index,tn);
-
-/** Define the max_index reducer functions for a numeric type.
+
+/** Defines the max_index reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement the
* reducer functionality for the max_index reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MAX_INDEX_DEFINITION(t,tn,id) \
@@ -3281,9 +3416,9 @@ __CILKRTS_END_EXTERN_C
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_max_index,tn) \
{ typedef __CILKRTS_MKIDENT(cilk_c_reducer_max_index_view_,tn) view_t; \
((view_t*)v)->index = 0; ((view_t*)v)->value = id; }
-
+
//@{
-/** @def CILK_C_REDUCER_MAX_INDEX_INSTANCE
+/** @def CILK_C_REDUCER_MAX_INDEX_INSTANCE
* @brief Declare or define implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS` will be defined, and
@@ -3299,7 +3434,7 @@ __CILKRTS_END_EXTERN_C
#endif
//@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
__CILKRTS_BEGIN_EXTERN_C
@@ -3323,7 +3458,7 @@ __CILKRTS_END_EXTERN_C
/// @endcond
-/** Min reducer type name.
+/** Declares min reducer type name.
*
* This macro expands into the identifier which is the name of the min reducer
* type for a specified numeric type.
@@ -3336,7 +3471,7 @@ __CILKRTS_END_EXTERN_C
#define CILK_C_REDUCER_MIN_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_min_,tn)
-/** Declare a min reducer object.
+/** Declares a min reducer object.
*
* This macro expands into a declaration of a min reducer object for a specified numeric
* type. For example:
@@ -3346,7 +3481,7 @@ __CILKRTS_END_EXTERN_C
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying the type of the
* reducer.
- * @param v The initial value for the reducer. (A value which can be assigned to the
+ * @param v The initial value for the reducer. (A value which can be assigned to the
* numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
@@ -3358,7 +3493,7 @@ __CILKRTS_END_EXTERN_C
__CILKRTS_MKIDENT(cilk_c_reducer_min_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, v)
-/** Minimize with a value.
+/** Minimizes with a value.
*
* `CILK_C_REDUCER_MIN_CALC(reducer, v)` sets the current view of the
* reducer to the min of its previous value and a specified new value.
@@ -3378,27 +3513,27 @@ __CILKRTS_END_EXTERN_C
/// @cond internal
-/** Declare the min reducer functions for a numeric type.
+/** Declares the min reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which implement
* the reducer functionality for the min reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MIN_DECLARATION(t,tn,id) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_MIN_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_min,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_min,tn);
-
-/** Define the min reducer functions for a numeric type.
+
+/** Defines the min reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement the
* reducer functionality for the min reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MIN_DEFINITION(t,tn,id) \
@@ -3407,9 +3542,9 @@ __CILKRTS_END_EXTERN_C
{ if (*(t*)l > *(t*)r) *(t*)l = *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_min,tn) \
{ *(t*)v = id; }
-
+
//@{
-/** @def CILK_C_REDUCER_MIN_INSTANCE
+/** @def CILK_C_REDUCER_MIN_INSTANCE
* @brief Declare or define implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS` will be defined, and
@@ -3425,7 +3560,7 @@ __CILKRTS_END_EXTERN_C
#endif
//@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
__CILKRTS_BEGIN_EXTERN_C
@@ -3449,7 +3584,7 @@ __CILKRTS_END_EXTERN_C
/// @endcond
-/** Min_index reducer type name.
+/** Declares `min_index` reducer type name.
*
* This macro expands into the identifier which is the name of the min_index reducer
* type for a specified numeric type.
@@ -3462,7 +3597,7 @@ __CILKRTS_END_EXTERN_C
#define CILK_C_REDUCER_MIN_INDEX_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_min_index_,tn)
-/** Declare an op_min_index reducer object.
+/** Declares an op_min_index reducer object.
*
* This macro expands into a declaration of a min_index reducer object for a specified
* numeric type. For example:
@@ -3472,7 +3607,7 @@ __CILKRTS_END_EXTERN_C
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying the type of the
* reducer.
- * @param v The initial value for the reducer. (A value which can be assigned to the
+ * @param v The initial value for the reducer. (A value which can be assigned to the
* numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
@@ -3484,7 +3619,7 @@ __CILKRTS_END_EXTERN_C
__CILKRTS_MKIDENT(cilk_c_reducer_min_index_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, {0, v})
-/** Minimize with a value.
+/** Minimizes with a value.
*
* `CILK_C_REDUCER_MIN_INDEX_CALC(reducer, i, v)` sets the current view of the
* reducer to the min of its previous value and a specified new value.
@@ -3493,7 +3628,7 @@ __CILKRTS_END_EXTERN_C
* REDUCER_VIEW(reducer) = min_index(REDUCER_VIEW(reducer), v)
*
* If the value of the reducer is changed to @a v, then the index of the reducer is
- * changed to @a i.
+ * changed to @a i.
*
* @param reducer The reducer whose contained value and index are to be updated.
* @param i The index associated with the new value.
@@ -3509,7 +3644,7 @@ __CILKRTS_END_EXTERN_C
/// @cond internal
-/** Declare the min_index view type.
+/** Declares the min_index view type.
*
* The view of a min_index reducer is a structure containing both the
* minimum value for the reducer and the index that was associated with
@@ -3521,13 +3656,13 @@ __CILKRTS_END_EXTERN_C
t value; \
} __CILKRTS_MKIDENT(cilk_c_reducer_min_index_view_,tn)
-/** Declare the min_index reducer functions for a numeric type.
+/** Declares the min_index reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which implement
* the reducer functionality for the min_index reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MIN_INDEX_DECLARATION(t,tn,id) \
@@ -3537,14 +3672,14 @@ __CILKRTS_END_EXTERN_C
CILK_C_REDUCER_MIN_INDEX_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_min_index,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_min_index,tn);
-
-/** Define the min_index reducer functions for a numeric type.
+
+/** Defines the min_index reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement the
* reducer functionality for the min_index reducer type for a specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer type name,
+ * @param tn The value "type name" identifier, used to construct the reducer type name,
* function names, etc.
*/
#define CILK_C_REDUCER_MIN_INDEX_DEFINITION(t,tn,id) \
@@ -3559,10 +3694,10 @@ __CILKRTS_END_EXTERN_C
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_min_index,tn) \
{ typedef __CILKRTS_MKIDENT(cilk_c_reducer_min_index_view_,tn) view_t; \
((view_t*)v)->index = 0; ((view_t*)v)->value = id; }
-
+
//@{
-/** @def CILK_C_REDUCER_MIN_INDEX_INSTANCE
- * @brief Declare or define implementation functions for a reducer type.
+/** @def CILK_C_REDUCER_MIN_INDEX_INSTANCE
+ * @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS` will be defined, and
* this macro will generate reducer implementation functions. Everywhere else, `CILK_C_DEFINE_REDUCERS`
@@ -3577,7 +3712,7 @@ __CILKRTS_END_EXTERN_C
#endif
//@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
__CILKRTS_BEGIN_EXTERN_C
@@ -3603,4 +3738,4 @@ __CILKRTS_END_EXTERN_C
//@}
-#endif // defined REDUCER_MAX_H_INCLUDED
+#endif // defined REDUCER_MIN_MAX_H_INCLUDED
diff --git a/libcilkrts/include/cilk/reducer_opadd.h b/libcilkrts/include/cilk/reducer_opadd.h
index 4b7a83f845d..46d4b6e9b57 100644
--- a/libcilkrts/include/cilk/reducer_opadd.h
+++ b/libcilkrts/include/cilk/reducer_opadd.h
@@ -1,10 +1,8 @@
/* reducer_opadd.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,6 +29,20 @@
* 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.
*/
/** @file reducer_opadd.h
@@ -55,9 +66,9 @@
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file `reducers.md`, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file `reducers.md`, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
*
* @section redopadd_usage Usage Example
*
@@ -78,11 +89,11 @@
* @subsection redopadd_monoid_operator Operator
*
* The operator of an addition reducer is the addition operator, defined by
- * the “`+`” binary operator on `Type`.
+ * the "`+`" binary operator on `Type`.
*
* @subsection redopadd_monoid_identity Identity
*
- * The identity value of the reducer is the numeric value “`0`”. This is
+ * The identity value of the reducer is the numeric value "`0`". This is
* expected to be the value of the default constructor `Type()`.
*
* @section redopadd_operations Operations
@@ -130,22 +141,22 @@
* @section redopadd_floating_point Issues with Floating-Point Types
*
* Because of precision and round-off issues, floating-point addition is not
- * really associative. For example, `(1e30 + -1e30) + 1 == 1`, but
+ * really associative. For example, `(1e30 + -1e30) + 1 == 1`, but
* `1e30 + (-1e30 + 1) == 0`.
*
- * In many cases, this won’t matter, but computations which have been
+ * In many cases, this won't matter, but computations which have been
* carefully ordered to control round-off errors may not deal well with
* being reassociated. In general, you should be sure to understand the
- * floating-point behavior of your program before doing any transformation
- * that will reassociate its computations.
+ * floating-point behavior of your program before doing any transformation
+ * that will reassociate its computations.
*
* @section redopadd_types Type and Operator Requirements
*
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
- * The operator “`+=`” must be defined on `Type`, with `x += a` having the
- * same meaning as `x = x + a`. In addition, if the code uses the “`-=`”,
+ * The operator "`+=`" must be defined on `Type`, with `x += a` having the
+ * same meaning as `x = x + a`. In addition, if the code uses the "`-=`",
* pre-increment, post-increment, pre-decrement, or post-decrement operators,
* then the corresponding operators must be defined on `Type`.
*
@@ -174,18 +185,18 @@ namespace cilk {
/** The addition reducer view class.
*
- * This is the view class for reducers created with
- * `cilk::reducer< cilk::op_add<Type> >`. It holds the accumulator variable
- * for the reduction, and allows only addition and subtraction operations to
+ * This is the view class for reducers created with
+ * `cilk::reducer< cilk::op_add<Type> >`. It holds the accumulator variable
+ * for the reduction, and allows only addition and subtraction operations to
* be performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `+=` operation would be used in an expression like `*r += a`, where
* `r` is an op_add reducer variable.
*
- * @tparam Type The type of the contained accumulator variable. This will
- * be the value type of a monoid_with_view that is
+ * @tparam Type The type of the contained accumulator variable. This will
+ * be the value type of a monoid_with_view that is
* instantiated with this view.
*
* @see ReducersAdd
@@ -197,19 +208,19 @@ template <typename Type>
class op_add_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
-
+
public:
- /** Class to represent the right-hand side of
+ /** Class to represent the right-hand side of
* `*reducer = *reducer ± value`.
*
* The only assignment operator for the op_add_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_add_view are
- * ones which generate an rhs_proxy — that is, expressions of the form
+ * ones which generate an rhs_proxy - that is, expressions of the form
* `op_add_view ± value ... ± value`.
*
* @warning
- * The lhs and rhs views in such an assignment must be the same;
+ * The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 + x` is
* legal; `v1 = v2 + x` is illegal.) This condition will be checked with a
* runtime assertion when compiled in debug mode.
@@ -222,7 +233,7 @@ public:
const op_add_view* m_view;
Type m_value;
- // Constructor is invoked only from op_add_view::operator+() and
+ // Constructor is invoked only from op_add_view::operator+() and
// op_add_view::operator-().
//
rhs_proxy(const op_add_view* view, const Type& value) :
@@ -232,13 +243,13 @@ public:
rhs_proxy(); // Disable default constructor
public:
- //@{
- /** Add or subtract an additional rhs value. If `v` is an op_add_view
- * and `a1` is a value, then the expression `v + a1` invokes the view’s
- * `operator+()` to create an rhs_proxy for `(v, a1)`; then
- * `v + a1 + a2` invokes the rhs_proxy’s `operator+()` to create a new
+ ///@{
+ /** Adds or subtracts an additional rhs value. If `v` is an op_add_view
+ * and `a1` is a value, then the expression `v + a1` invokes the view's
+ * `operator+()` to create an rhs_proxy for `(v, a1)`; then
+ * `v + a1 + a2` invokes the rhs_proxy's `operator+()` to create a new
* rhs_proxy for `(v, a1+a2)`. This allows the right-hand side of an
- * assignment to be not just `view ± value`, but
+ * assignment to be not just `view ± value`, but
* `view ± value ± value ... ± value`. The effect is that
*
* v = v ± a1 ± a2 ... ± an;
@@ -249,11 +260,11 @@ public:
*/
rhs_proxy& operator+(const Type& x) { m_value += x; return *this; }
rhs_proxy& operator-(const Type& x) { m_value -= x; return *this; }
- //@}
+ ///@}
};
-
- /** Default/identity constructor. This constructor initializes the
+
+ /** Default/identity constructor. This constructor initializes the
* contained value to `Type()`, which is expected to be the identity value
* for addition on `Type`.
*/
@@ -262,8 +273,8 @@ public:
/** Construct with a specified initial value.
*/
explicit op_add_view(const Type& v) : base(v) {}
-
- /** Reduction operation.
+
+ /** Reduces the views of two strands.
*
* This function is invoked by the @ref op_add monoid to combine the views
* of two strands when the right strand merges with the left one. It adds
@@ -284,13 +295,13 @@ public:
* These functions support the various syntaxes for incrementing or
* decrementing the accumulator variable contained in the view.
*/
- //@{
+ ///@{
- /** Increment the accumulator variable by @a x.
+ /** Increments the accumulator variable by @a x.
*/
op_add_view& operator+=(const Type& x) { this->m_value += x; return *this; }
- /** Decrement the accumulator variable by @a x.
+ /** Decrements the accumulator variable by @a x.
*/
op_add_view& operator-=(const Type& x) { this->m_value -= x; return *this; }
@@ -298,7 +309,7 @@ public:
*/
op_add_view& operator++() { ++this->m_value; return *this; }
- /** Post-increment.
+ /** Post-increments.
*
* @note Conventionally, post-increment operators return the old value
* of the incremented variable. However, reducer views do not
@@ -307,11 +318,11 @@ public:
*/
void operator++(int) { this->m_value++; }
- /** Pre-decrement.
+ /** Pre-decrements.
*/
op_add_view& operator--() { --this->m_value; return *this; }
- /** Post-decrement.
+ /** Post-decrements.
*
* @note Conventionally, post-decrement operators return the old value
* of the decremented variable. However, reducer views do not
@@ -320,19 +331,19 @@ public:
*/
void operator--(int) { this->m_value--; }
- /** Create an object representing `*this + x`.
+ /** Creates an object representing `*this + x`.
*
* @see rhs_proxy
*/
rhs_proxy operator+(const Type& x) const { return rhs_proxy(this, x); }
- /** Create an object representing `*this - x`.
+ /** Creates an object representing `*this - x`.
*
* @see rhs_proxy
*/
rhs_proxy operator-(const Type& x) const { return rhs_proxy(this, -x); }
- /** Assign the result of a `view ± value` expression to the view. Note that
+ /** Assigns the result of a `view ± value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
@@ -342,12 +353,12 @@ public:
this->m_value += rhs.m_value;
return *this;
}
-
- //@}
+
+ ///@}
};
-/** Monoid class for addition reductions. Instantiate the cilk::reducer
+/** Monoid class for addition reductions. Instantiate the cilk::reducer
* template class with an op_add monoid to create an addition reducer class.
* For example, to compute
* the sum of a set of `int` values:
@@ -356,10 +367,10 @@ public:
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersAdd
* @see op_add_view
@@ -378,13 +389,13 @@ struct op_add : public monoid_with_view<op_add_view<Type>, Align> {};
* value can be added to a `%reducer_opadd` with `r += a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_opadd.
+ * reducers rather than the old wrappers like reducer_opadd.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_opadd`
+ * @note Implicit conversions are provided between `%reducer_opadd`
* and `reducer<%op_add>`. This allows incremental code
* conversion: old code that used `%reducer_opadd` can pass a
* `%reducer_opadd` to a converted function that now expects a
@@ -408,8 +419,8 @@ class reducer_opadd : public reducer< op_add<Type, true> >
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
- /// The view’s rhs proxy type.
+
+ /// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
/// The view type for the reducer.
@@ -420,8 +431,8 @@ class reducer_opadd : public reducer< op_add<Type, true> >
/** @name Constructors
*/
- //@{
-
+ ///@{
+
/** Default (identity) constructor.
*
* Constructs the wrapper with the default initial value of `Type()`.
@@ -433,29 +444,29 @@ class reducer_opadd : public reducer< op_add<Type, true> >
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opadd(const Type& initial_value) : base(initial_value) {}
-
- //@}
+
+ ///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_add_view. */
- //@{
-
+ ///@{
+
/// @copydoc op_add_view::operator+=(const Type&)
reducer_opadd& operator+=(const Type& x) { view() += x; return *this; }
-
+
/// @copydoc op_add_view::operator-=(const Type&)
reducer_opadd& operator-=(const Type& x) { view() -= x; return *this; }
-
+
/// @copydoc op_add_view::operator++()
reducer_opadd& operator++() { ++view(); return *this; }
-
+
/// @copydoc op_add_view::operator++(int)
void operator++(int) { view()++; }
-
+
/// @copydoc op_add_view::operator-\-()
reducer_opadd& operator--() { --view(); return *this; }
-
+
/// @copydoc op_add_view::operator-\-(int)
void operator--(int) { view()--; }
@@ -463,26 +474,26 @@ class reducer_opadd : public reducer< op_add<Type, true> >
// reducer_opadd::operator-() have different behavior and a different
// return type than this definition. The legacy version is defined as a
// member function, so this new version is defined as a free function to
- // give it a different signature, so that they won’t end up sharing a
+ // give it a different signature, so that they won't end up sharing a
// single object file entry.
/// @copydoc op_add_view::operator+(const Type&) const
friend rhs_proxy operator+(const reducer_opadd& r, const Type& x)
- {
- return r.view() + x;
+ {
+ return r.view() + x;
}
/// @copydoc op_add_view::operator-(const Type&) const
friend rhs_proxy operator-(const reducer_opadd& r, const Type& x)
- {
- return r.view() - x;
+ {
+ return r.view() - x;
}
/// @copydoc op_add_view::operator=(const rhs_proxy&)
- reducer_opadd& operator=(const rhs_proxy& temp)
+ reducer_opadd& operator=(const rhs_proxy& temp)
{
view() = temp;
- return *this;
+ return *this;
}
- //@}
+ ///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
@@ -501,25 +512,25 @@ class reducer_opadd : public reducer< op_add<Type, true> >
* // operator += is a wrapper member function that
* // calls the corresponding view function
*/
- //@{
+ ///@{
reducer_opadd& operator*() { return *this; }
reducer_opadd const& operator*() const { return *this; }
reducer_opadd* operator->() { return this; }
reducer_opadd const* operator->() const { return this; }
- //@}
-
+ ///@}
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
- //@{
+ ///@{
operator reducer< op_add<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_add<Type, false> >* >(this);
@@ -528,15 +539,15 @@ class reducer_opadd : public reducer< op_add<Type, true> >
{
return *reinterpret_cast< const reducer< op_add<Type, false> >* >(this);
}
- //@}
+ ///@}
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
- * This specialization of the @ref legacy_reducer_downcast template class
- * defined in reducer.h causes the `reducer< op_add<Type> >` class to have an
- * `operator reducer_opadd<Type>& ()` conversion operator that statically
+ * This specialization of the @ref legacy_reducer_downcast template class
+ * defined in reducer.h causes the `reducer< op_add<Type> >` class to have an
+ * `operator reducer_opadd<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_add>` to the corresponding `reducer_opadd` type.
* (The reverse conversion, from `reducer_opadd` to `reducer<op_add>`, is just
* an upcast, which is provided for free by the language.)
@@ -557,20 +568,20 @@ struct legacy_reducer_downcast<reducer<op_add<Type, Align> > >
/** @ingroup ReducersAdd
*/
-//@{
+///@{
/** @name C Language Reducer Macros
*
- * These macros are used to declare and work with numeric op_add reducers in
+ * These macros are used to declare and work with numeric op_add reducers in
* C code.
*
* @see @ref page_reducers_in_c
*/
- //@{
-
+ ///@{
+
__CILKRTS_BEGIN_EXTERN_C
-/** Opadd reducer type name.
+/** Declares opadd reducer type name.
*
* This macro expands into the identifier which is the name of the op_add
* reducer type for a specified numeric type.
@@ -584,7 +595,7 @@ __CILKRTS_BEGIN_EXTERN_C
#define CILK_C_REDUCER_OPADD_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opadd_,tn)
-/** Declare an op_add reducer object.
+/** Declares an op_add reducer object.
*
* This macro expands into a declaration of an op_add reducer object for a
* specified numeric type. For example:
@@ -609,29 +620,29 @@ __CILKRTS_BEGIN_EXTERN_C
/// @cond internal
-/** Declare the op_add reducer functions for a numeric type.
+/** Declares the op_add reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_add reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPADD_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPADD_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opadd,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opadd,tn);
-
-/** Define the op_add reducer functions for a numeric type.
+
+/** Defines the op_add reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_add reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPADD_DEFINITION(t,tn) \
@@ -640,13 +651,13 @@ __CILKRTS_BEGIN_EXTERN_C
{ *(t*)l += *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opadd,tn) \
{ *(t*)v = 0; }
-
-//@{
-/** @def CILK_C_REDUCER_OPADD_INSTANCE
- * @brief Declare or define implementation functions for a reducer type.
+
+///@{
+/** @def CILK_C_REDUCER_OPADD_INSTANCE
+ * @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
- * will be defined, and this macro will generate reducer implementation
+ * will be defined, and this macro will generate reducer implementation
* functions. Everywhere else, `CILK_C_DEFINE_REDUCERS` will be undefined,
* and this macro will expand into external declarations for the functions.
*/
@@ -657,9 +668,9 @@ __CILKRTS_BEGIN_EXTERN_C
# define CILK_C_REDUCER_OPADD_INSTANCE(t,tn) \
CILK_C_REDUCER_OPADD_DECLARATION(t,tn)
#endif
-//@}
+///@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPADD_INSTANCE(char, char)
@@ -683,8 +694,8 @@ CILK_C_REDUCER_OPADD_INSTANCE(long double, longdouble)
__CILKRTS_END_EXTERN_C
-//@}
+///@}
-//@}
+///@}
#endif /* REDUCER_OPADD_H_INCLUDED */
diff --git a/libcilkrts/include/cilk/reducer_opand.h b/libcilkrts/include/cilk/reducer_opand.h
index 8a086c91818..44d537d4f36 100644
--- a/libcilkrts/include/cilk/reducer_opand.h
+++ b/libcilkrts/include/cilk/reducer_opand.h
@@ -1,10 +1,8 @@
/* reducer_opand.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,11 +29,25 @@
* 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.
*/
/** @file reducer_opand.h
*
- * @brief Defines classes for doing parallel bitwise and reductions.
+ * @brief Defines classes for doing parallel bitwise AND reductions.
*
* @ingroup ReducersAnd
*
@@ -48,16 +59,16 @@
#include <cilk/reducer.h>
-/** @defgroup ReducersAnd Bitwise And Reducers
+/** @defgroup ReducersAnd Bitwise AND Reducers
*
- * Bitwise and reducers allow the computation of the bitwise and of a set of
+ * Bitwise AND reducers allow the computation of the bitwise AND of a set of
* values in parallel.
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file `reducers.md`, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file `reducers.md`, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
*
* @section redopand_usage Usage Example
*
@@ -72,19 +83,18 @@
*
* @subsection redopand_monoid_values Value Set
*
- * The value set of a bitwise and reducer is the set of values of `Type`,
+ * The value set of a bitwise AND reducer is the set of values of `Type`,
* which is expected to be a builtin integer type which has a representation
* as a sequence of bits (or something like it, such as `bool` or
* `std::bitset`).
*
* @subsection redopand_monoid_operator Operator
*
- * The operator of a bitwise and reducer is the bitwise and operator, defined
- * by the “`&`” binary operator on `Type`.
+ * The bitwise AND operator is defined by the "`&`" binary operator on `Type`.
*
* @subsection redopand_monoid_identity Identity
*
- * The identity value of the reducer is the value whose representation
+ * The identity value of the reducer is the value whose representation
* contains all 1-bits. This is expected to be the value of the expression
* `~Type()` (i.e., the bitwise negation operator applied to the default value
* of the value type).
@@ -106,7 +116,7 @@
*
* @subsection redopand_initial Initial Values
*
- * If a bitwise and reducer is constructed without an explicit initial value,
+ * If a bitwise AND reducer is constructed without an explicit initial value,
* then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopand_types.
*
@@ -121,17 +131,17 @@
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
- * The operator “`&=`” must be defined on `Type`, with `x &= a` having the
+ * The operator "`&=`" must be defined on `Type`, with `x &= a` having the
* same meaning as `x = x & a`.
*
* The expression `~ Type()` must be a valid expression which yields the
* identity value (the value of `Type` whose representation consists of all
* 1-bits).
*
- * @section redopand_in_c Bitwise And Reducers in C
+ * @section redopand_in_c Bitwise AND Reducers in C
*
* The @ref CILK_C_REDUCER_OPAND and @ref CILK_C_REDUCER_OPAND_TYPE macros can
- * be used to do bitwise and reductions in C. For example:
+ * be used to do bitwise AND reductions in C. For example:
*
* CILK_C_REDUCER_OPAND(r, uint, ~0);
* CILK_C_REGISTER_REDUCER(r);
@@ -148,14 +158,14 @@
namespace cilk {
-/** The bitwise and reducer view class.
+/** The bitwise AND reducer view class.
*
- * This is the view class for reducers created with
- * `cilk::reducer< cilk::op_and<Type> >`. It holds the accumulator variable
- * for the reduction, and allows only `and` operations to be performed on it.
+ * This is the view class for reducers created with
+ * `cilk::reducer< cilk::op_and<Type> >`. It holds the accumulator variable
+ * for the reduction, and allows only AND operations to be performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `&=` operation would be used in an expression like `*r &= a`, where
* `r` is an opmod reducer variable.
*
@@ -172,18 +182,18 @@ template <typename Type>
class op_and_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
-
+
public:
/** Class to represent the right-hand side of `*reducer = *reducer & value`.
*
* The only assignment operator for the op_and_view class takes an
- * rhs_proxy as its operand. This results in the syntactic restriction
+ * rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_and_view are
- * ones which generate an rhs_proxy — that is, expressions of the form
+ * ones which generate an rhs_proxy - that is, expressions of the form
* `op_and_view & value ... & value`.
*
* @warning
- * The lhs and rhs views in such an assignment must be the same;
+ * The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 & x` is
* legal; `v1 = v2 & x` is illegal.) This condition will be checked with
* a runtime assertion when compiled in debug mode.
@@ -205,12 +215,12 @@ public:
rhs_proxy(); // Disable default constructor
public:
- /** Bitwise and with an additional rhs value. If `v` is an op_and_view
+ /** Bitwise AND with an additional `rhs` value. If `v` is an op_and_view
* and `a1` is a value, then the expression `v & a1` invokes the
- * view’s `operator&()` to create an rhs_proxy for `(v, a1)`; then
- * `v & a1 & a2` invokes the rhs_proxy’s `operator&()` to create a new
+ * view's `operator&()` to create an rhs_proxy for `(v, a1)`; then
+ * `v & a1 & a2` invokes the rhs_proxy's `operator&()` to create a new
* rhs_proxy for `(v, a1&a2)`. This allows the right-hand side of an
- * assignment to be not just `view & value`, but
+ * assignment to be not just `view & value`, but
* `view & value & value ... & value`. The effect is that
*
* v = v & a1 & a2 ... & an;
@@ -231,13 +241,13 @@ public:
/** Construct with a specified initial value.
*/
explicit op_and_view(const Type& v) : base(v) {}
-
-
- /** Reduction operation.
+
+
+ /** Reduces the views of two strands.
*
* This function is invoked by the @ref op_and monoid to combine the views
* of two strands when the right strand merges with the left one. It
- * “ands” the value contained in the left-strand view with the value
+ * "ANDs" the value contained in the left-strand view with the value
* contained in the right-strand view, and leaves the value in the
* right-strand view undefined.
*
@@ -248,25 +258,25 @@ public:
* reduce operation.
*/
void reduce(op_and_view* right) { this->m_value &= right->m_value; }
-
+
/** @name Accumulator variable updates.
*
- * These functions support the various syntaxes for “anding” the
+ * These functions support the various syntaxes for "ANDing" the
* accumulator variable contained in the view with some value.
*/
- //@{
+ ///@{
- /** And the accumulator variable with @a x.
+ /** Performs AND between the accumulator variable and @a x.
*/
op_and_view& operator&=(const Type& x) { this->m_value &= x; return *this; }
- /** Create an object representing `*this & x`.
+ /** Creates an object representing `*this & x`.
*
* @see rhs_proxy
*/
rhs_proxy operator&(const Type& x) const { return rhs_proxy(this, x); }
- /** Assign the result of a `view & value` expression to the view. Note that
+ /** Assigns the result of a `view & value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
@@ -276,23 +286,23 @@ public:
this->m_value &= rhs.m_value;
return *this;
}
-
- //@}
+
+ ///@}
};
-/** Monoid class for bitwise and reductions. Instantiate the cilk::reducer
- * template class with an op_and monoid to create a bitwise and reducer
- * class. For example, to compute the bitwise and of a set of `unsigned long`
+/** Monoid class for bitwise AND reductions. Instantiate the cilk::reducer
+ * template class with an op_and monoid to create a bitwise AND reducer
+ * class. For example, to compute the bitwise AND of a set of `unsigned long`
* values:
*
* cilk::reducer< cilk::op_and<unsigned long> > r;
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersAnd
* @see op_and_view
@@ -302,22 +312,22 @@ public:
template <typename Type, bool Align = false>
struct op_and : public monoid_with_view<op_and_view<Type>, Align> {};
-/** Deprecated bitwise and reducer class.
+/** Deprecated bitwise AND reducer class.
*
* reducer_opand is the same as @ref reducer<@ref op_and>, except that
* reducer_opand is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
- * example, a value is anded with a `reducer<%op_and>` with `*r &= a`, but a
- * value can be anded with a `%reducer_opand` with `r &= a`.
+ * example, a value is "ANDed" with a `reducer<%op_and>` with `*r &= a`, but a
+ * value can be "ANDed" with a `%reducer_opand` with `r &= a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_opand.
+ * reducers rather than the old wrappers like reducer_opand.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_opand`
+ * @note Implicit conversions are provided between `%reducer_opand`
* and `reducer<%op_and>`. This allows incremental code
* conversion: old code that used `%reducer_opand` can pass a
* `%reducer_opand` to a converted function that now expects a
@@ -341,20 +351,20 @@ class reducer_opand : public reducer< op_and<Type, true> >
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
- /// The view’s rhs proxy type.
+
+ /// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
-
+
/// The view type for the reducer.
typedef view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
-
+
/** @name Constructors
*/
- //@{
-
+ ///@{
+
/** Default constructor.
*
* Constructs the wrapper with the default initial value of `Type()`
@@ -367,13 +377,13 @@ public:
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opand(const Type& initial_value) : base(initial_value) {}
-
- //@}
+
+ ///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_and_view. */
- //@{
+ ///@{
/// @copydoc op_and_view::operator&=(const Type&)
reducer_opand& operator&=(const Type& x)
@@ -381,26 +391,26 @@ public:
view() &= x;
return *this;
}
-
+
// The legacy definition of reducer_opand::operator&() has different
// behavior and a different return type than this definition. The legacy
// version is defined as a member function, so this new version is defined
- // as a free function to give it a different signature, so that they won’t
+ // as a free function to give it a different signature, so that they won't
// end up sharing a single object file entry.
-
+
/// @copydoc op_and_view::operator&(const Type&) const
friend rhs_proxy operator&(const reducer_opand& r, const Type& x)
- {
- return r.view() & x;
+ {
+ return r.view() & x;
}
/// @copydoc op_and_view::operator=(const rhs_proxy&)
- reducer_opand& operator=(const rhs_proxy& temp)
- {
+ reducer_opand& operator=(const rhs_proxy& temp)
+ {
view() = temp;
- return *this;
+ return *this;
}
- //@}
+ ///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
@@ -419,25 +429,25 @@ public:
* // operator &= is a wrapper member function that
* // calls the corresponding view function
*/
- //@{
+ ///@{
reducer_opand& operator*() { return *this; }
reducer_opand const& operator*() const { return *this; }
reducer_opand* operator->() { return this; }
reducer_opand const* operator->() const { return this; }
- //@}
-
+ ///@}
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
- //@{
+ ///@{
operator reducer< op_and<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_and<Type, false> >* >(this);
@@ -446,14 +456,14 @@ public:
{
return *reinterpret_cast< const reducer< op_and<Type, false> >* >(this);
}
- //@}
+ ///@}
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
- * This specialization of the @ref legacy_reducer_downcast template class
- * defined in reducer.h causes the `reducer< op_and<Type> >` class to have an
+ * This specialization of the @ref legacy_reducer_downcast template class
+ * defined in reducer.h causes the `reducer< op_and<Type> >` class to have an
* `operator reducer_opand<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_and>` to the corresponding `reducer_opand` type.
* (The reverse conversion, from `reducer_opand` to `reducer<op_and>`, is just
@@ -475,7 +485,7 @@ struct legacy_reducer_downcast<reducer<op_and<Type, Align> > >
/** @ingroup ReducersAdd
*/
-//@{
+///@{
/** @name C language reducer macros
*
@@ -483,13 +493,13 @@ struct legacy_reducer_downcast<reducer<op_and<Type, Align> > >
*
* @see @ref page_reducers_in_c
*/
- //@{
-
+ ///@{
+
__CILKRTS_BEGIN_EXTERN_C
-/** Opand reducer type name.
+/** Declares `opand` reducer type name.
*
- * This macro expands into the identifier which is the name of the op_and
+ * This macro expands into the identifier which is the name of the op_and
* reducer type for a specified numeric type.
*
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
@@ -501,7 +511,7 @@ __CILKRTS_BEGIN_EXTERN_C
#define CILK_C_REDUCER_OPAND_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opand_,tn)
-/** Declare an op_and reducer object.
+/** Declares an op_and reducer object.
*
* This macro expands into a declaration of an op_and reducer object for a
* specified numeric type. For example:
@@ -526,29 +536,29 @@ __CILKRTS_BEGIN_EXTERN_C
/// @cond internal
-/** Declare the op_and reducer functions for a numeric type.
+/** Declares the op_and reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_and reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPAND_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPAND_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opand,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opand,tn);
-
-/** Define the op_and reducer functions for a numeric type.
+
+/** Defines the op_and reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_and reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPAND_DEFINITION(t,tn) \
@@ -557,10 +567,10 @@ __CILKRTS_BEGIN_EXTERN_C
{ *(t*)l &= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opand,tn) \
{ *(t*)v = ~((t)0); }
-
-//@{
-/** @def CILK_C_REDUCER_OPAND_INSTANCE
- * @brief Declare or define implementation functions for a reducer type.
+
+///@{
+/** @def CILK_C_REDUCER_OPAND_INSTANCE
+ * @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
@@ -574,9 +584,9 @@ __CILKRTS_BEGIN_EXTERN_C
# define CILK_C_REDUCER_OPAND_INSTANCE(t,tn) \
CILK_C_REDUCER_OPAND_DECLARATION(t,tn)
#endif
-//@}
+///@}
-/* Declare or define an instance of the reducer type and its functions for
+/* Declares or defines an instance of the reducer type and its functions for
* each numeric type.
*/
CILK_C_REDUCER_OPAND_INSTANCE(char, char)
@@ -597,8 +607,8 @@ CILK_C_REDUCER_OPAND_INSTANCE(unsigned long long, ulonglong)
__CILKRTS_END_EXTERN_C
-//@}
+///@}
-//@}
+///@}
#endif /* REDUCER_OPAND_H_INCLUDED */
diff --git a/libcilkrts/include/cilk/reducer_opmul.h b/libcilkrts/include/cilk/reducer_opmul.h
index 271529d787b..8a3e2d2a2a5 100644
--- a/libcilkrts/include/cilk/reducer_opmul.h
+++ b/libcilkrts/include/cilk/reducer_opmul.h
@@ -1,10 +1,8 @@
/* reducer_opmul.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2012-2013, Intel Corporation
+ * Copyright (C) 2012-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:
@@ -19,7 +17,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
@@ -32,6 +29,20 @@
* 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.
*/
/** @file reducer_opmul.h
@@ -55,9 +66,9 @@
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file `reducers.md`, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file `reducers.md`, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
*
* @section redopmul_usage Usage Example
*
@@ -79,11 +90,11 @@
* @subsection redopmul_monoid_operator Operator
*
* The operator of a multiplication reducer is the multiplication operation,
- * defined by the “`*`” binary operator on `Type`.
+ * defined by the "`*`" binary operator on `Type`.
*
* @subsection redopmul_monoid_identity Identity
*
- * The identity value of the reducer is the numeric value “`1`”. This is
+ * The identity value of the reducer is the numeric value "`1`". This is
* expected to be the value of the expression `Type(1)`.
*
* @section redopmul_operations Operations
@@ -119,18 +130,18 @@
* not really associative. For example, `(1e200 * 1e-200) * 1e-200 == 1e-200`,
* but `1e200 * (1e-200 * 1e-200 == 0.
*
- * In many cases, this won’t matter, but computations which have been
+ * In many cases, this won't matter, but computations which have been
* carefully ordered to control overflow and underflow may not deal well with
* being reassociated. In general, you should be sure to understand the
- * floating-point behavior of your program before doing any transformation
- * that will reassociate its computations.
+ * floating-point behavior of your program before doing any transformation
+ * that will reassociate its computations.
*
* @section redopmul_types Type and Operator Requirements
*
- * `Type` must be `Copy Constructible`, `Default Constructible`, and
+ * `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
- * The operator “`*=`” must be defined on `Type`, with `x *= a` having the same
+ * The operator "`*=`" must be defined on `Type`, with `x *= a` having the same
* meaning as `x = x * a`.
*
* The expression `Type(1)` must be a valid expression which yields the
@@ -158,18 +169,18 @@ namespace cilk {
/** The multiplication reducer view class.
*
- * This is the view class for reducers created with
- * `cilk::reducer< cilk::op_mul<Type> >`. It holds the accumulator variable
- * for the reduction, and allows only multiplication operations to be
+ * This is the view class for reducers created with
+ * `cilk::reducer< cilk::op_mul<Type> >`. It holds the accumulator variable
+ * for the reduction, and allows only multiplication operations to be
* performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `*=` operation would be used in an expression like `*r *= a`, where
* `r` is an op_mul reducer variable.
*
- * @tparam Type The type of the contained accumulator variable. This will
- * be the value type of a monoid_with_view that is
+ * @tparam Type The type of the contained accumulator variable. This will
+ * be the value type of a monoid_with_view that is
* instantiated with this view.
*
* @see ReducersMul
@@ -181,18 +192,18 @@ template <typename Type>
class op_mul_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
-
+
public:
/** Class to represent the right-hand side of `*reducer = *reducer * value`.
*
- * The only assignment operator for the op_mul_view class takes an
- * rhs_proxy as its operand. This results in the syntactic restriction
+ * The only assignment operator for the op_mul_view class takes an
+ * rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_mul_view are
- * ones which generate an rhs_proxy — that is, expressions of the form
+ * ones which generate an rhs_proxy - that is, expressions of the form
* `op_mul_view * value ... * value`.
*
* @warning
- * The lhs and rhs views in such an assignment must be the same;
+ * The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 * x` is
* legal; `v1 = v2 * x` is illegal.) This condition will be checked with a
* runtime assertion when compiled in debug mode.
@@ -213,12 +224,12 @@ public:
rhs_proxy(); // Disable default constructor
public:
- /** Multiply by an additional rhs value. If `v` is an op_mul_view and
- * `a1` is a value, then the expression `v * a1` invokes the view’s
- * `operator*()` to create an rhs_proxy for `(v, a1)`; then
- * `v * a1 * a2` invokes the rhs_proxy’s `operator*()` to create a
+ /** Multiplies by an additional `rhs` value. If `v` is an op_mul_view and
+ * `a1` is a value, then the expression `v * a1` invokes the view's
+ * `operator*()` to create an rhs_proxy for `(v, a1)`; then
+ * `v * a1 * a2` invokes the rhs_proxy's `operator*()` to create a
* new rhs_proxy for `(v, a1*a2)`. This allows the right-hand side of
- * an assignment to be not just `view * value`, but
+ * an assignment to be not just `view * value`, but
* `view * value * value ... * value`. The effect is that
*
* v = v * a1 * a2 ... * an;
@@ -231,7 +242,7 @@ public:
};
- /** Default/identity constructor. This constructor initializes the
+ /** Default/identity constructor. This constructor initializes the
* contained value to `Type(1)`, which is expected to be the identity
* value for multiplication on `Type`.
*/
@@ -240,8 +251,8 @@ public:
/** Construct with a specified initial value.
*/
explicit op_mul_view(const Type& v) : base(v) {}
-
- /** Reduction operation.
+
+ /** Reduces two strand views.
*
* This function is invoked by the @ref op_mul monoid to combine the views
* of two strands when the right strand merges with the left one. It
@@ -256,25 +267,25 @@ public:
* reduce operation.
*/
void reduce(op_mul_view* right) { this->m_value *= right->m_value; }
-
+
/** @name Accumulator variable updates.
*
* These functions support the various syntaxes for multiplying the
* accumulator variable contained in the view by some value.
*/
- //@{
+ ///@{
- /** Multiply the accumulator variable by @a x.
+ /** Multiplies the accumulator variable by @a x.
*/
op_mul_view& operator*=(const Type& x) { this->m_value *= x; return *this; }
- /** Create an object representing `*this * x`.
+ /** Creates an object representing `*this * x`.
*
* @see rhs_proxy
*/
rhs_proxy operator*(const Type& x) const { return rhs_proxy(this, x); }
- /** Assign the result of a `view * value` expression to the view. Note that
+ /** Assigns the result of a `view * value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
@@ -284,8 +295,8 @@ public:
this->m_value *= rhs.m_value;
return *this;
}
-
- //@}
+
+ ///@}
};
/** Monoid class for multiplication reductions. Instantiate the cilk::reducer
@@ -309,7 +320,7 @@ struct op_mul : public monoid_with_view< op_mul_view<Type> > {};
/** @ingroup ReducersAdd
*/
-//@{
+///@{
/** @name C language reducer macros
*
@@ -318,11 +329,11 @@ struct op_mul : public monoid_with_view< op_mul_view<Type> > {};
*
* @see @ref page_reducers_in_c
*/
- //@{
-
+ ///@{
+
__CILKRTS_BEGIN_EXTERN_C
-/** Opmul reducer type name.
+/** Declares `opmul` reducer type name.
*
* This macro expands into the identifier which is the name of the op_mul
* reducer type for a specified numeric type.
@@ -336,7 +347,7 @@ __CILKRTS_BEGIN_EXTERN_C
#define CILK_C_REDUCER_OPMUL_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opmul_,tn)
-/** Declare an op_mul reducer object.
+/** Declares an op_mul reducer object.
*
* This macro expands into a declaration of an op_mul reducer object for a
* specified numeric type. For example:
@@ -361,29 +372,29 @@ __CILKRTS_BEGIN_EXTERN_C
/// @cond internal
-/** Declare the op_mul reducer functions for a numeric type.
+/** Declares the op_mul reducer functions for a numeric type.
*
- * This macro expands into external function declarations for functions which
+ * This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_mul reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPMUL_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPMUL_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opmul,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opmul,tn);
-
-/** Define the op_mul reducer functions for a numeric type.
+
+/** Defines the op_mul reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_mul reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPMUL_DEFINITION(t,tn) \
@@ -392,10 +403,10 @@ __CILKRTS_BEGIN_EXTERN_C
{ *(t*)l *= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opmul,tn) \
{ *(t*)v = 1; }
-
-//@{
-/** @def CILK_C_REDUCER_OPMUL_INSTANCE
- * @brief Declare or define implementation functions for a reducer type.
+
+///@{
+/** @def CILK_C_REDUCER_OPMUL_INSTANCE
+ * @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
@@ -409,9 +420,9 @@ __CILKRTS_BEGIN_EXTERN_C
# define CILK_C_REDUCER_OPMUL_INSTANCE(t,tn) \
CILK_C_REDUCER_OPMUL_DECLARATION(t,tn)
#endif
-//@}
+///@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPMUL_INSTANCE(char, char)
@@ -435,8 +446,8 @@ CILK_C_REDUCER_OPMUL_INSTANCE(long double, longdouble)
__CILKRTS_END_EXTERN_C
-//@}
+///@}
-//@}
+///@}
#endif /* REDUCER_OPMUL_H_INCLUDED */
diff --git a/libcilkrts/include/cilk/reducer_opor.h b/libcilkrts/include/cilk/reducer_opor.h
index 5c8e7bd972e..8d6d5202488 100644
--- a/libcilkrts/include/cilk/reducer_opor.h
+++ b/libcilkrts/include/cilk/reducer_opor.h
@@ -1,10 +1,8 @@
/* reducer_opor.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,11 +29,25 @@
* 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.
*/
/** @file reducer_opor.h
*
- * @brief Defines classes for doing parallel bitwise or reductions.
+ * @brief Defines classes for doing parallel bitwise OR reductions.
*
* @ingroup ReducersOr
*
@@ -48,16 +59,16 @@
#include <cilk/reducer.h>
-/** @defgroup ReducersOr Bitwise Or Reducers
+/** @defgroup ReducersOr Bitwise `OR` Reducers
*
- * Bitwise and reducers allow the computation of the bitwise and of a set of
+ * Bitwise `OR` reducers allow the computation of the bitwise `OR` of a set of
* values in parallel.
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file `reducers.md`, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file `reducers.md`, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
*
* @section redopor_usage Usage Example
*
@@ -72,18 +83,18 @@
*
* @subsection redopor_monoid_values Value Set
*
- * The value set of a bitwise or reducer is the set of values of `Type`, which
+ * The value set of a bitwise `OR` reducer is the set of values of `Type`, which
* is expected to be a builtin integer type which has a representation as a
* sequence of bits (or something like it, such as `bool` or `std::bitset`).
*
* @subsection redopor_monoid_operator Operator
*
- * The operator of a bitwise or reducer is the bitwise or operator, defined by
- * the “`|`” binary operator on `Type`.
+ * The operator of a bitwise `OR` reducer is the bitwise OR operator, defined by
+ * the "`|`" binary operator on `Type`.
*
* @subsection redopor_monoid_identity Identity
*
- * The identity value of the reducer is the value whose representation
+ * The identity value of the reducer is the value whose representation
* contains all 0-bits. This is expected to be the value of the default
* constructor `Type()`.
*
@@ -104,8 +115,8 @@
*
* @subsection redopor_initial Initial Values
*
- * If a bitwise or reducer is constructed without an explicit initial value,
- * then its initial value will be its identity value, as long as `Type`
+ * If a bitwise OR reducer is constructed without an explicit initial value,
+ * then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopor_types.
*
* @subsection redopor_view_ops View Operations
@@ -119,17 +130,17 @@
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
- * The operator “`|=`” must be defined on `Type`, with `x |= a` having the
+ * The operator "`|=`" must be defined on `Type`, with `x |= a` having the
* same meaning as `x = x | a`.
*
* The expression `Type()` must be a valid expression which yields the
* identity value (the value of `Type` whose representation consists of all
* 0-bits).
*
- * @section redopor_in_c Bitwise Or Reducers in C
+ * @section redopor_in_c Bitwise OR Reducers in C
*
* The @ref CILK_C_REDUCER_OPOR and @ref CILK_C_REDUCER_OPOR_TYPE macros can
- * be used to do bitwise or reductions in C. For example:
+ * be used to do bitwise OR reductions in C. For example:
*
* CILK_C_REDUCER_OPOR(r, uint, 0);
* CILK_C_REGISTER_REDUCER(r);
@@ -146,14 +157,14 @@
namespace cilk {
-/** The bitwise or reducer view class.
+/** The bitwise OR reducer view class.
*
- * This is the view class for reducers created with
+ * This is the view class for reducers created with
* `cilk::reducer< cilk::op_or<Type> >`. It holds the accumulator variable for
* the reduction, and allows only `or` operations to be performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `|=` operation would be used in an expression like `*r |= a`, where
* `r` is an opmod reducer variable.
*
@@ -170,18 +181,18 @@ template <typename Type>
class op_or_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
-
+
public:
/** Class to represent the right-hand side of `*reducer = *reducer | value`.
*
- * The only assignment operator for the op_or_view class takes an
+ * The only assignment operator for the op_or_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_or_view are
- * ones which generate an rhs_proxy — that is, expressions of the form
+ * ones which generate an rhs_proxy - that is, expressions of the form
* `op_or_view | value ... | value`.
*
* @warning
- * The lhs and rhs views in such an assignment must be the same;
+ * The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 | x` is
* legal; `v1 = v2 | x` is illegal.) This condition will be checked with
* a runtime assertion when compiled in debug mode.
@@ -202,12 +213,12 @@ public:
rhs_proxy(); // Disable default constructor
public:
- /** Bitwise or with an additional rhs value. If `v` is an op_or_view
- * and `a1` is a value, then the expression `v | a1` invokes the
- * view’s `operator|()` to create an rhs_proxy for `(v, a1)`; then
- * `v | a1 | a2` invokes the rhs_proxy’s `operator|()` to create a new
+ /** bitwise OR with an additional rhs value. If `v` is an op_or_view
+ * and `a1` is a value, then the expression `v | a1` invokes the
+ * view's `operator|()` to create an rhs_proxy for `(v, a1)`; then
+ * `v | a1 | a2` invokes the rhs_proxy's `operator|()` to create a new
* rhs_proxy for `(v, a1|a2)`. This allows the right-hand side of an
- * assignment to be not just `view | value`, but
+ * assignment to be not just `view | value`, but
( `view | value | value ... | value`. The effect is that
*
* v = v | a1 | a2 ... | an;
@@ -228,12 +239,12 @@ public:
/** Construct with a specified initial value.
*/
explicit op_or_view(const Type& v) : base(v) {}
-
- /** Reduction operation.
+
+ /** Reduces the views of two strands.
*
* This function is invoked by the @ref op_or monoid to combine the views
* of two strands when the right strand merges with the left one. It
- * “ors” the value contained in the left-strand view by the value
+ * "ORs" the value contained in the left-strand view by the value
* contained in the right-strand view, and leaves the value in the
* right-strand view undefined.
*
@@ -244,25 +255,25 @@ public:
* reduce operation.
*/
void reduce(op_or_view* right) { this->m_value |= right->m_value; }
-
+
/** @name Accumulator variable updates.
*
- * These functions support the various syntaxes for “oring” the
+ * These functions support the various syntaxes for "ORing" the
* accumulator variable contained in the view with some value.
*/
- //@{
+ ///@{
- /** Or the accumulator variable with @a x.
+ /** Perfoms an OR operation between the accumulator variable and @a x.
*/
op_or_view& operator|=(const Type& x) { this->m_value |= x; return *this; }
- /** Create an object representing `*this | x`.
+ /** Creates an object representing `*this | x`.
*
* @see rhs_proxy
*/
rhs_proxy operator|(const Type& x) const { return rhs_proxy(this, x); }
- /** Assign the result of a `view | value` expression to the view. Note that
+ /** Assigns the result of a `view | value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
@@ -272,23 +283,23 @@ public:
this->m_value |= rhs.m_value;
return *this;
}
-
- //@}
+
+ ///@}
};
-/** Monoid class for bitwise or reductions. Instantiate the cilk::reducer
- * template class with an op_or monoid to create a bitwise or reducer
- * class. For example, to compute the bitwise or of a set of `unsigned long`
+/** Monoid class for bitwise OR reductions. Instantiate the cilk::reducer
+ * template class with an op_or monoid to create a bitwise OR reducer
+ * class. For example, to compute the bitwise OR of a set of `unsigned long`
* values:
*
* cilk::reducer< cilk::op_or<unsigned long> > r;
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersOr
* @see op_or_view
@@ -298,22 +309,22 @@ public:
template <typename Type, bool Align = false>
struct op_or : public monoid_with_view<op_or_view<Type>, Align> {};
-/** Deprecated bitwise or reducer class.
+/** Deprecated bitwise OR reducer class.
*
* reducer_opor is the same as @ref reducer<@ref op_or>, except that
* reducer_opor is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
- * example, a value is ored with a `reducer<%op_or>` with `*r |= a`, but a
- * value can be ored with a `%reducer_opor` with `r |= a`.
+ * example, a value is "ORed" with a `reducer<%op_or>` with `*r |= a`, but a
+ * value can be "ORed" with a `%reducer_opor` with `r |= a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_opor.
+ * reducers rather than the old wrappers like reducer_opor.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_opor`
+ * @note Implicit conversions are provided between `%reducer_opor`
* and `reducer<%op_or>`. This allows incremental code
* conversion: old code that used `%reducer_opor` can pass a
* `%reducer_opor` to a converted function that now expects a
@@ -337,20 +348,20 @@ class reducer_opor : public reducer< op_or<Type, true> >
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
- /// The view’s rhs proxy type.
+
+ /// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
-
+
/// The view type for the reducer.
typedef view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
-
+
/** @name Constructors
*/
- //@{
-
+ ///@{
+
/** Default (identity) constructor.
*
* Constructs the wrapper with the default initial value of `Type()`.
@@ -362,38 +373,38 @@ class reducer_opor : public reducer< op_or<Type, true> >
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opor(const Type& initial_value) : base(initial_value) {}
-
- //@}
+
+ ///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_and_view. */
- //@{
+ ///@{
/// @copydoc op_or_view::operator|=(const Type&)
reducer_opor& operator|=(const Type& x)
{
- view() |= x; return *this;
+ view() |= x; return *this;
}
-
+
// The legacy definition of reducer_opor::operator|() has different
// behavior and a different return type than this definition. The legacy
// version is defined as a member function, so this new version is defined
- // as a free function to give it a different signature, so that they won’t
+ // as a free function to give it a different signature, so that they won't
// end up sharing a single object file entry.
/// @copydoc op_or_view::operator|(const Type&) const
friend rhs_proxy operator|(const reducer_opor& r, const Type& x)
- {
- return r.view() | x;
+ {
+ return r.view() | x;
}
/// @copydoc op_and_view::operator=(const rhs_proxy&)
reducer_opor& operator=(const rhs_proxy& temp)
{
- view() = temp; return *this;
+ view() = temp; return *this;
}
- //@}
+ ///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
@@ -412,25 +423,25 @@ class reducer_opor : public reducer< op_or<Type, true> >
* // operator &= is a wrapper member function that
* // calls the corresponding view function
*/
- //@{
+ ///@{
reducer_opor& operator*() { return *this; }
reducer_opor const& operator*() const { return *this; }
reducer_opor* operator->() { return this; }
reducer_opor const* operator->() const { return this; }
- //@}
-
+ ///@}
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
- //@{
+ ///@{
operator reducer< op_or<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_or<Type, false> >* >(this);
@@ -439,15 +450,15 @@ class reducer_opor : public reducer< op_or<Type, true> >
{
return *reinterpret_cast< const reducer< op_or<Type, false> >* >(this);
}
- //@}
-
+ ///@}
+
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
- * This specialization of the @ref legacy_reducer_downcast template class
- * defined in reducer.h causes the `reducer< op_or<Type> >` class to have an
+ * This specialization of the @ref legacy_reducer_downcast template class
+ * defined in reducer.h causes the `reducer< op_or<Type> >` class to have an
* `operator reducer_opor<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_or>` to the corresponding `reducer_opor` type.
* (The reverse conversion, from `reducer_opor` to `reducer<op_or>`, is just
@@ -469,7 +480,7 @@ struct legacy_reducer_downcast<reducer<op_or<Type, Align> > >
/** @ingroup ReducersOr
*/
-//@{
+///@{
/** @name C language reducer macros
*
@@ -477,11 +488,11 @@ struct legacy_reducer_downcast<reducer<op_or<Type, Align> > >
*
* @see @ref page_reducers_in_c
*/
- //@{
-
+ ///@{
+
__CILKRTS_BEGIN_EXTERN_C
-/** Opor reducer type name.
+/** Declares OPOR reducer type name.
*
* This macro expands into the identifier which is the name of the op_or
* reducer type for a specified numeric type.
@@ -495,7 +506,7 @@ __CILKRTS_BEGIN_EXTERN_C
#define CILK_C_REDUCER_OPOR_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opor_,tn)
-/** Declare an op_or reducer object.
+/** Declares an op_or reducer object.
*
* This macro expands into a declaration of an op_or reducer object for a
* specified numeric type. For example:
@@ -520,29 +531,29 @@ __CILKRTS_BEGIN_EXTERN_C
/// @cond internal
-/** Declare the op_or reducer functions for a numeric type.
+/** Declares the op_or reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_or reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPOR_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPOR_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opor,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opor,tn);
-
-/** Define the op_or reducer functions for a numeric type.
+
+/** Defines the op_or reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
- * the reducer functionality for the op_or reducer type for a specified
+ * the reducer functionality for the op_or reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPOR_DEFINITION(t,tn) \
@@ -551,10 +562,10 @@ __CILKRTS_BEGIN_EXTERN_C
{ *(t*)l |= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opor,tn) \
{ *(t*)v = 0; }
-
-//@{
-/** @def CILK_C_REDUCER_OPOR_INSTANCE
- * @brief Declare or define implementation functions for a reducer type.
+
+///@{
+/** @def CILK_C_REDUCER_OPOR_INSTANCE
+ * @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
@@ -568,9 +579,9 @@ __CILKRTS_BEGIN_EXTERN_C
# define CILK_C_REDUCER_OPOR_INSTANCE(t,tn) \
CILK_C_REDUCER_OPOR_DECLARATION(t,tn)
#endif
-//@}
+///@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declare or define an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPOR_INSTANCE(char, char)
@@ -591,8 +602,8 @@ CILK_C_REDUCER_OPOR_INSTANCE(unsigned long long, ulonglong)
__CILKRTS_END_EXTERN_C
-//@}
+///@}
-//@}
+///@}
#endif /* REDUCER_OPOR_H_INCLUDED */
diff --git a/libcilkrts/include/cilk/reducer_opxor.h b/libcilkrts/include/cilk/reducer_opxor.h
index fed49943ef6..cb6560f9c57 100644
--- a/libcilkrts/include/cilk/reducer_opxor.h
+++ b/libcilkrts/include/cilk/reducer_opxor.h
@@ -1,10 +1,8 @@
/* reducer_opxor.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,6 +29,20 @@
* 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.
*/
/** @file reducer_opxor.h
@@ -48,16 +59,16 @@
#include <cilk/reducer.h>
-/** @defgroup ReducersXor Bitwise Xor Reducers
+/** @defgroup ReducersXor Bitwise XOR Reducers
*
- * Bitwise and reducers allow the computation of the bitwise and of a set of
+ * Bitwise XOR reducers allow the computation of the bitwise XOR of a set of
* values in parallel.
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file `reducers.md`, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file `reducers.md`, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
*
* @section redopxor_usage Usage Example
*
@@ -72,18 +83,17 @@
*
* @subsection redopxor_monoid_values Value Set
*
- * The value set of a bitwise xor reducer is the set of values of `Type`, which
+ * The value set of a bitwise XOR reducer is the set of values of `Type`, which
* is expected to be a builtin integer type which has a representation as a
* sequence of bits (or something like it, such as `bool` or `std::bitset`).
*
* @subsection redopxor_monoid_operator Operator
*
- * The operator of a bitwise xor reducer is the bitwise xor operator, defined
- * by the “`^`” binary operator on `Type`.
+ * The bitwise XOR operator is defined by the "`^`" binary operator on `Type`.
*
* @subsection redopxor_monoid_identity Identity
*
- * The identity value of the reducer is the value whose representation
+ * The identity value of the reducer is the value whose representation
* contains all 0-bits. This is expected to be the value of the default
* constructor `Type()`.
*
@@ -104,8 +114,8 @@
*
* @subsection redopxor_initial Initial Values
*
- * If a bitwise xor reducer is constructed without an explicit initial value,
- * then its initial value will be its identity value, as long as `Type`
+ * If a bitwise XOR reducer is constructed without an explicit initial value,
+ * then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopxor_types.
*
* @subsection redopxor_view_ops View Operations
@@ -119,17 +129,17 @@
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
- * The operator “`^=`” must be defined on `Type`, with `x ^= a` having the
+ * The operator "`^=`" must be defined on `Type`, with `x ^= a` having the
* same meaning as `x = x ^ a`.
*
* The expression `Type()` must be a valid expression which yields the
* identity value (the value of `Type` whose representation consists of all
* 0-bits).
*
- * @section redopxor_in_c Bitwise Xor Reducers in C
+ * @section redopxor_in_c Bitwise XOR Reducers in C
*
* The @ref CILK_C_REDUCER_OPXOR and @ref CILK_C_REDUCER_OPXOR_TYPE macros can
- * be used to do bitwise xor reductions in C. For example:
+ * be used to do bitwise XOR reductions in C. For example:
*
* CILK_C_REDUCER_OPXOR(r, uint, 0);
* CILK_C_REGISTER_REDUCER(r);
@@ -146,14 +156,14 @@
namespace cilk {
-/** The bitwise xor reducer view class.
+/** The bitwise XOR reducer view class.
*
- * This is the view class for reducers created with
- * `cilk::reducer< cilk::op_xor<Type> >`. It holds the accumulator variable
+ * This is the view class for reducers created with
+ * `cilk::reducer< cilk::op_xor<Type> >`. It holds the accumulator variable
* for the reduction, and allows only `xor` operations to be performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `^=` operation would be used in an expression like `*r ^= a`, where
* `r` is an opmod reducer variable.
*
@@ -170,18 +180,18 @@ template <typename Type>
class op_xor_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
-
+
public:
/** Class to represent the right-hand side of `*reducer = *reducer ^ value`.
*
- * The only assignment operator for the op_xor_view class takes an
+ * The only assignment operator for the op_xor_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_xor_view are
- * ones which generate an rhs_proxy — that is, expressions of the form
+ * ones which generate an rhs_proxy - that is, expressions of the form
* `op_xor_view ^ value ... ^ value`.
*
* @warning
- * The lhs and rhs views in such an assignment must be the same;
+ * The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 ^ x` is
* legal; `v1 = v2 ^ x` is illegal.) This condition will be checked with
* a runtime assertion when compiled in debug mode.
@@ -202,12 +212,12 @@ public:
rhs_proxy(); // Disable default constructor
public:
- /** Bitwise xor with an additional rhs value. If `v` is an op_xor_view
- * and `a1` is a value, then the expression `v ^ a1` invokes the
- * view’s `operator^()` to create an rhs_proxy for `(v, a1)`; then
- * `v ^ a1 ^ a2` invokes the rhs_proxy’s `operator^()` to create a new
+ /** bitwise XOR with an additional rhs value. If `v` is an op_xor_view
+ * and `a1` is a value, then the expression `v ^ a1` invokes the
+ * view's `operator^()` to create an rhs_proxy for `(v, a1)`; then
+ * `v ^ a1 ^ a2` invokes the rhs_proxy's `operator^()` to create a new
* rhs_proxy for `(v, a1^a2)`. This allows the right-hand side of an
- * assignment to be not just `view ^ value`, but
+ * assignment to be not just `view ^ value`, but
( `view ^ value ^ value ... ^ value`. The effect is that
*
* v = v ^ a1 ^ a2 ... ^ an;
@@ -228,12 +238,12 @@ public:
/** Construct with a specified initial value.
*/
explicit op_xor_view(const Type& v) : base(v) {}
-
- /** Reduction operation.
+
+ /** Reduces the views of two strands.
*
* This function is invoked by the @ref op_xor monoid to combine the views
* of two strands when the right strand merges with the left one. It
- * “xors” the value contained in the left-strand view by the value
+ * "XORs" the value contained in the left-strand view by the value
* contained in the right-strand view, and leaves the value in the
* right-strand view undefined.
*
@@ -244,25 +254,25 @@ public:
* reduce operation.
*/
void reduce(op_xor_view* right) { this->m_value ^= right->m_value; }
-
+
/** @name Accumulator variable updates.
*
- * These functions support the various syntaxes for “xoring” the
+ * These functions support the various syntaxes for "XORing" the
* accumulator variable contained in the view with some value.
*/
- //@{
+ ///@{
- /** Xor the accumulator variable with @a x.
+ /** Performs XOR operation between the accumulator variable and @a x.
*/
op_xor_view& operator^=(const Type& x) { this->m_value ^= x; return *this; }
- /** Create an object representing `*this ^ x`.
+ /** Creates an object representing `*this ^ x`.
*
* @see rhs_proxy
*/
rhs_proxy operator^(const Type& x) const { return rhs_proxy(this, x); }
- /** Assign the result of a `view ^ value` expression to the view. Note that
+ /** Assigns the result of a `view ^ value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
@@ -272,23 +282,23 @@ public:
this->m_value ^= rhs.m_value;
return *this;
}
-
- //@}
+
+ ///@}
};
-/** Monoid class for bitwise xor reductions. Instantiate the cilk::reducer
- * template class with an op_xor monoid to create a bitwise xor reducer
- * class. For example, to compute the bitwise xor of a set of `unsigned long`
+/** Monoid class for bitwise XOR reductions. Instantiate the cilk::reducer
+ * template class with an op_xor monoid to create a bitwise XOR reducer
+ * class. For example, to compute the bitwise XOR of a set of `unsigned long`
* values:
*
* cilk::reducer< cilk::op_xor<unsigned long> > r;
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersXor
* @see op_xor_view
@@ -298,22 +308,22 @@ public:
template <typename Type, bool Align = false>
struct op_xor : public monoid_with_view<op_xor_view<Type>, Align> {};
-/** Deprecated bitwise xor reducer class.
+/** Deprecated bitwise XOR reducer class.
*
* reducer_opxor is the same as @ref reducer<@ref op_xor>, except that
* reducer_opxor is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
- * example, a value is xored with a `reducer<%op_xor>` with `*r ^= a`, but a
- * value can be xored with a `%reducer_opxor` with `r ^= a`.
+ * example, a value is "XORed" with a `reducer<%op_xor>` with `*r ^= a`, but a
+ * value can be "XORed" with a `%reducer_opxor` with `r ^= a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_opand.
+ * reducers rather than the old wrappers like reducer_opand.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_opxor`
+ * @note Implicit conversions are provided between `%reducer_opxor`
* and `reducer<%op_xor>`. This allows incremental code
* conversion: old code that used `%reducer_opxor` can pass a
* `%reducer_opxor` to a converted function that now expects a
@@ -337,20 +347,20 @@ class reducer_opxor : public reducer< op_xor<Type, true> >
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
-
- /// The view’s rhs proxy type.
+
+ /// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
-
+
/// The view type for the reducer.
typedef view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
-
+
/** @name Constructors
*/
- //@{
-
+ ///@{
+
/** Default (identity) constructor.
*
* Constructs the wrapper with the default initial value of `Type()`.
@@ -362,38 +372,38 @@ class reducer_opxor : public reducer< op_xor<Type, true> >
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opxor(const Type& initial_value) : base(initial_value) {}
-
- //@}
+
+ ///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_and_view. */
- //@{
+ ///@{
/// @copydoc op_xor_view::operator^=(const Type&)
reducer_opxor& operator^=(const Type& x)
{
- view() ^= x; return *this;
+ view() ^= x; return *this;
}
-
+
// The legacy definition of reducer_opxor::operator^() has different
// behavior and a different return type than this definition. The legacy
// version is defined as a member function, so this new version is defined
- // as a free function to give it a different signature, so that they won’t
+ // as a free function to give it a different signature, so that they won't
// end up sharing a single object file entry.
/// @copydoc op_xor_view::operator^(const Type&) const
friend rhs_proxy operator^(const reducer_opxor& r, const Type& x)
- {
- return r.view() ^ x;
+ {
+ return r.view() ^ x;
}
/// @copydoc op_and_view::operator=(const rhs_proxy&)
reducer_opxor& operator=(const rhs_proxy& temp)
{
- view() = temp; return *this;
+ view() = temp; return *this;
}
- //@}
+ ///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
@@ -412,25 +422,25 @@ class reducer_opxor : public reducer< op_xor<Type, true> >
* // operator &= is a wrapper member function that
* // calls the corresponding view function
*/
- //@{
+ ///@{
reducer_opxor& operator*() { return *this; }
reducer_opxor const& operator*() const { return *this; }
reducer_opxor* operator->() { return this; }
reducer_opxor const* operator->() const { return this; }
- //@}
-
+ ///@}
+
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
- //@{
+ ///@{
operator reducer< op_xor<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_xor<Type, false> >* >(this);
@@ -439,15 +449,15 @@ class reducer_opxor : public reducer< op_xor<Type, true> >
{
return *reinterpret_cast< const reducer< op_xor<Type, false> >* >(this);
}
- //@}
-
+ ///@}
+
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
- * This specialization of the @ref legacy_reducer_downcast template class
- * defined in reducer.h causes the `reducer< op_xor<Type> >` class to have an
+ * This specialization of the @ref legacy_reducer_downcast template class
+ * defined in reducer.h causes the `reducer< op_xor<Type> >` class to have an
* `operator reducer_opxor<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_xor>` to the corresponding `reducer_opxor` type.
* (The reverse conversion, from `reducer_opxor` to `reducer<op_xor>`, is just
@@ -469,7 +479,7 @@ struct legacy_reducer_downcast<reducer<op_xor<Type, Align> > >
/** @ingroup ReducersXor
*/
-//@{
+///@{
/** @name C language reducer macros
*
@@ -477,11 +487,11 @@ struct legacy_reducer_downcast<reducer<op_xor<Type, Align> > >
*
* @see @ref page_reducers_in_c
*/
- //@{
-
+ ///@{
+
__CILKRTS_BEGIN_EXTERN_C
-/** Opxor reducer type name.
+/** Declares OPXOR reducer type name.
*
* This macro expands into the identifier which is the name of the op_xor
* reducer type for a specified numeric type.
@@ -495,7 +505,7 @@ __CILKRTS_BEGIN_EXTERN_C
#define CILK_C_REDUCER_OPXOR_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opxor_,tn)
-/** Declare an op_xor reducer object.
+/** Declares an op_xor reducer object.
*
* This macro expands into a declaration of an op_xor reducer object for a
* specified numeric type. For example:
@@ -520,29 +530,29 @@ __CILKRTS_BEGIN_EXTERN_C
/// @cond internal
-/** Declare the op_xor reducer functions for a numeric type.
+/** Declares the op_xor reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_xor reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPXOR_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPXOR_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opxor,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opxor,tn);
-
-/** Define the op_xor reducer functions for a numeric type.
+
+/** Defines the op_xor reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
- * the reducer functionality for the op_xor reducer type for a specified
+ * the reducer functionality for the op_xor reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
- * @param tn The value “type name” identifier, used to construct the reducer
+ * @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPXOR_DEFINITION(t,tn) \
@@ -551,10 +561,10 @@ __CILKRTS_BEGIN_EXTERN_C
{ *(t*)l ^= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opxor,tn) \
{ *(t*)v = 0; }
-
-//@{
-/** @def CILK_C_REDUCER_OPXOR_INSTANCE
- * @brief Declare or define implementation functions for a reducer type.
+
+///@{
+/** @def CILK_C_REDUCER_OPXOR_INSTANCE
+ * @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
@@ -568,9 +578,9 @@ __CILKRTS_BEGIN_EXTERN_C
# define CILK_C_REDUCER_OPXOR_INSTANCE(t,tn) \
CILK_C_REDUCER_OPXOR_DECLARATION(t,tn)
#endif
-//@}
+///@}
-/* Declare or define an instance of the reducer type and its functions for each
+/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPXOR_INSTANCE(char, char)
@@ -591,8 +601,8 @@ CILK_C_REDUCER_OPXOR_INSTANCE(unsigned long long, ulonglong)
__CILKRTS_END_EXTERN_C
-//@}
+///@}
-//@}
+///@}
#endif /* REDUCER_OPXOR_H_INCLUDED */
diff --git a/libcilkrts/include/cilk/reducer_ostream.h b/libcilkrts/include/cilk/reducer_ostream.h
index d9addeee89f..793c3c5020c 100644
--- a/libcilkrts/include/cilk/reducer_ostream.h
+++ b/libcilkrts/include/cilk/reducer_ostream.h
@@ -1,9 +1,8 @@
-/*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+/* reducer_ostream.h -*- C++ -*-
+ *
+ * Copyright (C) 2009-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:
@@ -18,7 +17,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
@@ -31,263 +29,489 @@
* 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.
*/
-/*
- * reducer_ostream.h
- *
- * Purpose: Hyper-object to write to 'std::ostream's
- *
- * Classes: reducer_ostream
- *
- * Description:
- * ============
- * Output streams ('std::ostream's) are a convenient means of writing text to
- * files, the user console, or sockets. In a serial program, text is written
- * to an ostream in a specific, logical order. For example, computing while
- * traversing a data structure and printing them to an 'ostream' will result
- * in the values being printed in the order of traversal. In a parallel
- * version of the same program, however, different parts of the data structure
- * may be traversed in a different order, resulting in a non-deterministic
- * ordering of the stream. Worse, multiple strands may write to the same
- * stream simultaneously, resulting in a data race. Replacing the
- * 'std::ostream' with a 'cilk::reducer_ostream' will solve both problems: Data
- * will appeaer in the stream in the same order as it would for the serial
- * program, and there will be no races (no locks) on the common stream.
- *
- * Usage Example:
- * ==============
- * Assume we wish to traverse an array of objects, performing an operation on
- * each object and writing the result to a file. Without a reducer_ostream,
- * we have a race on the 'output' file stream:
- *..
- * void compute(std::ostream& os, double x)
- * {
- * // Perform some significant computation and print the result:
- * os << std::asin(x);
- * }
- *
- * int test()
- * {
- * const std::size_t ARRAY_SIZE = 1000000;
- * extern double myArray[ARRAY_SIZE];
- *
- * std::ofstream output("output.txt");
- * cilk_for (std::size_t i = 0; i < ARRAY_SIZE; ++i)
- * {
- * compute(output, myArray[i]);
- * }
+/** @file reducer_ostream.h
*
- * return 0;
- * }
- *..
- * The race is solved by using a reducer_ostream to proxy the 'output' file:
- *..
- * void compute(cilk::reducer_ostream& os, double x)
- * {
- * // Perform some significant computation and print the result:
- * *os << std::asin(x);
- * }
- *
- * int test()
- * {
- * const std::size_t ARRAY_SIZE = 1000000;
- * extern double myArray[ARRAY_SIZE];
- *
- * std::ofstream output("output.txt");
- * cilk::reducer_ostream hyper_output(output);
- * cilk_for (std::size_t i = 0; i < ARRAY_SIZE; ++i)
- * {
- * compute(hyper_output, myArray[i]);
- * }
+ * @brief Defines a class for writing to an ostream in parallel.
*
- * return 0;
- * }
- *..
- *
- * Limitations:
- * ============
- * There are two possible values for the formatting flags immediately after a
- * 'cilk_spawn' statement: they may either have the value that was set by the
- * spawn function, or they may have default values. Because of
- * non-determinism in the processor scheduling, there is no way to determine
- * which it will be. Similarly, the formatting flags after a 'cilk_sync' may
- * or may not have the same value as before the sync. Therefore, one must use
- * a disciplined coding style to avoid formatting errors. There are two
- * approaches to mitigating the problem: The first is to eliminate the
- * difference between the two possible outcomes by ensuring that the spawned
- * function always returns the flags to their initial state:
- *..
- * void compute(cilk::reducer_ostream& os, double x)
- * {
- * // Perform some significant computation and print the result:
- * int saveprec = os.precision(5);
- * os << std::asin(x);
- * os.precision(saveprec);
- * }
- *..
- * The second approach is to write your streaming operations such that they
- * don't depend on the previous state of the formatting flags by setting any
- * important flags before every block of output:
- *..
- * cilk_spawn compute(hyper_output, value);
- *
- * hyper_output->precision(2); // Don't depend on previous precision
- * *hyper_output << f();
- * *hyper_output << g();
- *..
- * Another concern is memory usage. A reducer_ostream will buffer as much text
- * as necessary to ensure that the order of output matches that of the serial
- * version of the program. If all spawn branches perform an equal amount of
- * output, then one can expect that half of the output before a sync will be
- * buffered in memory. This hyperobject is therefore not well suited for
- * serializing very large quantities of text output.
+ * @ingroup ReducersOstream
+ *
+ * @see @ref ReducersOstream
*/
#ifndef REDUCER_OSTREAM_H_INCLUDED
#define REDUCER_OSTREAM_H_INCLUDED
#include <cilk/reducer.h>
-#include <iostream>
+#include <ostream>
#include <sstream>
+/** @defgroup ReducersOstream Ostream Reducers
+ *
+ * Ostream reducers allow multiple strands to write to an ostream in parallel.
+ *
+ * @ingroup Reducers
+ *
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file reducers.md, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
+ *
+ * @section redostream_usage Usage Example
+ *
+ * One of the most common debugging techniques is adding `print` statements
+ * to the code being debugged. When the code is parallelized, the results can
+ * be less than satisfactory, as output from multiple strands is mingled in an
+ * unpredictable way. Like other reducers, an ostream reducer requires minimal
+ * recoding to guarantee that the output from parallelized computation will be
+ * ordered the same as though the computation were executed serially.
+ *
+ * cilk::reducer<cilk::op_ostream> r(std::cerr);
+ * cilk_for (int i = 0; i != data.size(); ++i) {
+ * *r << "Iteration " << i << ":\n";
+ * ... some computation ...
+ * *r << " Step 1:" << some information;
+ * ... some more computation ...
+ * *r << " Step 2:" << some more information;
+ * ... still more computation ...
+ * *r << " Step 3:" << still more information;
+ * }
+ *
+ * Output on standard error:
+ *
+ * Iteration 1:
+ * Step 1: ...
+ * Step 2: ...
+ * Step 3: ...
+ * Iteration 2:
+ * Step 1: ...
+ * Step 2: ...
+ * Step 3: ...
+ * Iteration 3:
+ * Step 1: ...
+ * Step 2: ...
+ * Step 3: ...
+ * ...
+ *
+ * @section redostream_overview Overview
+ *
+ * An "ostream reducer" is not really a reducer. It uses the reducer
+ * technology to coordinate operations on parallel strands to achieve
+ * the same behavior in a parallel computation that would be seen in a
+ * serial computation, but it does not have a monoid. It has a "monoid
+ * class," because that is part of the implementation framework, but it
+ * does not represent a mathematical monoid: there is no value type, no
+ * associative operation, and no identity value. The reducer is used for
+ * its side effect rather than to construct a value.
+ *
+ * You might think of an ostream reducer as a relative of a
+ * @ref ReducersString "string reducer" which uses stream output
+ * syntax (`stream << value`) instead of string append syntax
+ * (`string += value`), and which writes its result string to an
+ * ostream instead of making it available as the reducer value.
+ *
+ * Another difference is that "real" reducers protect their contained
+ * value quite strongly from improper access by the user. Ostream reducers,
+ * on the other hand, pretty much have to expose the ostream, since normal
+ * use of an ostream involves accessing its internal state. Furthermore,
+ * the ostream reducer just coordinates output to an existing ostream -
+ * there is nothing to keep the user from writing directly to the attached
+ * stream, with unpredictable results.
+ *
+ * @section redostream_operations Operations
+ *
+ * In the operation descriptions below, the type name `Ostream` refers to the
+ * reducer's ostream type, `std::basic_ostream<Char, Traits>`.
+ *
+ * @subsection redostream_constructors Constructors
+ *
+ * The only constructor is
+ *
+ * reducer(const Ostream& os)
+ *
+ * This creates a reducer that is associated with the existing ostream `os`.
+ * Anything "written to" the reducer will (eventually) be written to `os`.
+ *
+ * @subsection redostream_get_set Set and Get
+ *
+ * Just as a stream does not have a "value," neither does an ostream
+ * reducer. Therefore, none of the usual `set_value`, `get_value`,
+ * `move_in`, or `move_out` functions are available for ostream reducers.
+ *
+ * @subsection redostream_initial Initial Values
+ *
+ * Ostream reducers do not have default constructors.
+ *
+ * @subsection redostream_view_ops View Operations
+ *
+ * An ostream reducer view is actually a kind of `std::ostream`. Therefore,
+ * any operation that can be used on an ostream can be used on an ostream
+ * reducer view. For example:
+ *
+ * reducer<op_ostream> r(cout);
+ * *r << setw(5) << (x=1) << endl;
+ *
+ *
+ * @section redostream_performance Performance Considerations
+ *
+ * Ostream reducers work by creating a string stream for each non-leftmost
+ * view. When two strands are merged, the contents of the string buffer of the
+ * right view are written to the left view. Since all non-leftmost strands are
+ * eventually merged, all output is eventually written to the associated
+ * ostream.
+ *
+ * This implementation has two consequences.
+ *
+ * First, all output written to an ostream reducer on a stolen strand is kept
+ * in memory (in a string buffer) until the strand is merged with the leftmost
+ * strand. This means that some portion of the output written to an ostream
+ * reducer during a parallel computation - half of the total output, on
+ * average - will temporarily be held in memory during the computation.
+ * Obviously, ostream reducers will work better for small and moderate amounts
+ * of output.
+ *
+ * Second, buffered ostream reducer content must be copied at every merge.
+ * The total amount of copying is potentially proportional to the total amount
+ * of output multiplied by the number of strands stolen during the computation.
+ *
+ * In short, writing to an ostream in a parallel computation with an ostream
+ * reducer will always be less efficient than writing the same output directly
+ * to the ostream in a serial computation. The value of the ostream
+ * reducer is not in the writing of the ostream itself, but in removing the
+ * race and serialization obstacles that the ostream output would cause in an
+ * otherwise parallelizable computation.
+ *
+ *
+ * @section redostream_state Stream State
+ *
+ * The reducer implementation can correctly order the output that is written
+ * to an ostream. However, an ostream has additional state that controls its
+ * behavior, such as its formatting attributes, error state, extensible arrays, * and registered callbacks. If these are modified during the computation, the * reducer implementation cannot guarantee that they will be the same in a
+ * parallel computation as in a serial computation. In particular:
+ *
+ * - In the serial execution, the ostream state in the continuation of a
+ * spawn will be the same as the state at the end of the spawned function.
+ * In the parallel execution, if the continuation is stolen, its view will
+ * contain a newly created ostream with the default initial state.
+ * - In the serial execution, the ostream state following a sync is the same
+ * as the state before the sync. In the parallel execution, if the
+ * continuation is stolen, then the state following the sync will be the
+ * same as the state at the end of some spawned function.
+ *
+ * In short, you must not make any assumptions about the stream state of an
+ * ostream reducer:
+ *
+ * - Following a `cilk_spawn`.
+ * - Following a `cilk_sync`.
+ * - At the start of an iteration of a `cilk_for` loop.
+ * - Following the completion of a `cilk_for` loop.
+ *
+ * @section redostream_types Type and Operator Requirements
+ *
+ * `std::basic_ostream<Char, Traits>` must be a valid type.
+*/
+
namespace cilk {
-/**
- * @brief Class 'reducer_ostream' is the representation of a hyperobject for
- * output text streaming.
+/** @ingroup ReducersOstream */
+//@{
+
+/** The ostream reducer view class.
+ *
+ * This is the view class for reducers created with
+ * `cilk::reducer< cilk::op_basic_ostream<Char, Traits> >`. It holds the
+ * actual ostream for a parallel strand, and allows only stream output
+ * operations to be performed on it.
+ *
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view
+ * class's `<<` operation would be used in an expression like
+ * `*r << "x = " << x`, where `r` is an ostream reducer.
+ *
+ * @tparam Char The ostream element type (not the ostream type).
+ * @tparam Traits The character traits type.
+ *
+ * @see ReducersOstream
+ * @see op_basic_ostream
*/
-class reducer_ostream
+template<typename Char, typename Traits>
+class op_basic_ostream_view : public std::basic_ostream<Char, Traits>
{
+ typedef std::basic_ostream<Char, Traits> base;
+ typedef std::basic_ostream<Char, Traits> ostream_type;
+
+ // A non-leftmost view is associated with a private string buffer. (The
+ // leftmost view is associated with the buffer of the reducer's associated
+ // ostream, so its private buffer is unused.)
+ //
+ std::basic_stringbuf<Char, Traits> m_buffer;
+
public:
- /// Internal representation of the per-strand view of the data for reducer_ostream
- class View: public std::ostream
+
+ /** Value type. Required by @ref monoid_with_view.
+ */
+ typedef ostream_type value_type;
+
+ /** Reduce operation. Required by @ref monoid_with_view.
+ */
+ void reduce(op_basic_ostream_view* other)
{
- public:
- /// Type of the std::stream reducer_ostream is based on
- typedef std::ostream Base;
-
- friend class reducer_ostream;
-
- View():
- std::ostream(0)
- {
- Base::rdbuf(&strbuf_);
- };
-
- private:
- void use_ostream (const std::ostream &os)
- {
- Base::rdbuf(os.rdbuf());
- Base::flags(os.flags()); // Copy formatting flags
- Base::setstate(os.rdstate()); // Copy error state
+ // Writing an empty buffer results in failure. Testing `sgetc()` is the
+ // easiest way of checking for an empty buffer.
+ if (other->m_buffer.sgetc() != Traits::eof()) {
+ *this << (&other->m_buffer);
}
+ }
- private:
- std::stringbuf strbuf_;
- };
+ /** Non-leftmost (identity) view constructor. The view is associated with
+ * its internal buffer. Required by @ref monoid_base.
+ */
+ op_basic_ostream_view() : base(&m_buffer) {}
-public:
- /// Definition of data view, operation, and identity for reducer_ostream
- struct Monoid: monoid_base< View >
+ /** Leftmost view constructor. The view is associated with an existing
+ * ostream.
+ */
+ op_basic_ostream_view(const ostream_type& os) : base(0)
{
- static void reduce (View *left, View *right);
- };
+ base::rdbuf(os.rdbuf()); // Copy stream buffer
+ base::flags(os.flags()); // Copy formatting flags
+ base::setstate(os.rdstate()); // Copy error state
+ }
-private:
- // Hyperobject to serve up views
- reducer<Monoid> imp_;
+ /** Sets/gets.
+ *
+ * These are all no-ops.
+ */
+ //@{
- // Methods that provide the API for the reducer
-public:
+ void view_set_value(const value_type&)
+ { assert("set_value() is not allowed on ostream reducers" && 0); }
+ const value_type& view_get_value() const
+ { assert("get_value() is not allowed on ostream reducers" && 0);
+ return *this; }
+ typedef value_type const& return_type_for_get_value;
+ void view_move_in(const value_type&)
+ { assert("move_in() is not allowed on ostream reducers" && 0); }
+ void view_move_out(const value_type&)
+ { assert("move_out() is not allowed on ostream reducers" && 0); }
- // Construct an initial 'reducer_ostream' from an 'std::ostream'. The
- // specified 'os' stream is used as the eventual destination for all
- // text streamed to this hyperobject.
- explicit reducer_ostream(const std::ostream &os);
+ //@}
+};
- // Return a modifiable reference to the underlying 'ostream' object.
- std::ostream& get_reference();
+/** Ostream monoid class. Instantiate the cilk::reducer template class with an
+ * op_basic_ostream monoid to create an ostream reducer class:
+ *
+ * cilk::reducer< cilk::op_basic_string<char> > r;
+ *
+ * @tparam Char The stream element type (not the stream type).
+ * @tparam Traits The character traits type.
+ *
+ * @see ReducersOstream
+ * @see op_basic_ostream_view
+ * @see reducer_ostream
+ * @see op_ostream
+ * @see op_wostream
+ */
+template<typename Char,
+ typename Traits = std::char_traits<Char>,
+ bool Align = false>
+class op_basic_ostream :
+ public monoid_with_view< op_basic_ostream_view<Char, Traits>, Align >
+{
+ typedef monoid_with_view< op_basic_ostream_view<Char, Traits>, Align >
+ base;
+ typedef std::basic_ostream<Char, Traits> ostream_type;
+ typedef provisional_guard<typename base::view_type> view_guard;
- /**
- * Append data from some type to the reducer_ostream
- *
- * @param v Value to be appended to the reducer_ostream
+public:
+
+ /** View type of the monoid.
*/
- template<typename T>
- std::ostream &
- operator<< (const T &v)
- {
- return imp_.view() << v;
- }
+ typedef typename base::view_type view_type;
- /**
- * Append data from a std::ostream to the reducer_ostream
+ /** @name Construct function.
*
- * @param _Pfn std::ostream to copy from
+ * The only supported ostream reducer constructor takes a reference to
+ * an existing ostream.
+ *
+ * @param os The ostream destination for receive all data written to the
+ * reducer.
*/
- std::ostream &
- operator<< (std::ostream &(*_Pfn)(std::ostream &))
+ static void construct(
+ op_basic_ostream* monoid,
+ view_type* view,
+ const ostream_type& os)
{
- View &v = imp_.view();
-
- return ((*_Pfn)(v));
+ view_guard vg( new((void*) view) view_type(os) );
+ vg.confirm_if( new((void*) monoid) op_basic_ostream );
}
-
- reducer_ostream& operator*() { return *this; }
- reducer_ostream const& operator*() const { return *this; }
-
- reducer_ostream* operator->() { return this; }
- reducer_ostream const* operator->() const { return this; }
};
-// -------------------------------------------
-// class reducer_ostream::Monoid
-// -------------------------------------------
+/**
+ * Convenience typedef for narrow ostreams.
+ */
+typedef op_basic_ostream<char> op_ostream;
/**
- * Appends string from "right" reducer_basic_string onto the end of
- * the "left". When done, the "right" reducer_basic_string is empty.
+ * Convenience typedef for wide ostreams.
*/
-void
-reducer_ostream::Monoid::reduce(View *left, View *right)
-{
- left->operator<< (&right->strbuf_);
-}
+typedef op_basic_ostream<wchar_t> op_wostream;
-// --------------------------
-// class reducer_ostream
-// --------------------------
+/// @cond internal
-/**
- * Construct a reducer_ostream which will write to the specified std::ostream
+class reducer_ostream;
+
+/** Metafunction specialization for reducer conversion.
*
- * @param os std::ostream to write to
+ * This specialization of the @ref legacy_reducer_downcast template class
+ * defined in reducer.h causes the `reducer<op_basic_ostream<char> >` class
+ * to have an `operator reducer_ostream& ()` conversion operator that
+ * statically downcasts the `reducer<op_basic_ostream<char> >` to
+ * `reducer_ostream`. (The reverse conversion, from `reducer_ostream` to
+ * `reducer<op_basic_ostream<char> >`, is just an upcast, which is provided
+ * for free by the language.)
*/
-inline
-reducer_ostream::reducer_ostream(const std::ostream &os) :
- imp_()
+template<bool Align>
+struct legacy_reducer_downcast<
+ reducer<op_basic_ostream<char, std::char_traits<char>, Align> > >
{
- View &v = imp_.view();
+ typedef reducer_ostream type;
+};
- v.use_ostream(os);
-}
+/// @endcond
-/**
- * Get a reference to the std::ostream
+/** Deprecated ostream reducer class.
+ *
+ * reducer_ostream is the same as @ref cilk::reducer<@ref op_ostream>, except
+ * that reducer_ostream is a proxy for the contained view, so that ostream
+ * operations can be applied directly to the reducer. For example, a number is
+ * written to a `reducer<op_ostream>` with `*r << x`, but a number can be
+ * written to a `reducer_ostream` with `r << x`.
+ *
+ * @deprecated Users are strongly encouraged to use `reducer<monoid>`
+ * reducers rather than the old wrappers like reducer_ostream. The
+ * `reducer<monoid>` reducers show the reducer/monoid/view
+ * architecture more clearly, are more consistent in their
+ * implementation, and present a simpler model for new
+ * user-implemented reducers.
+ *
+ * @note Implicit conversions are provided between `%reducer_ostream`
+ * and `reducer<%op_ostream>`. This allows incremental code
+ * conversion: old code that used `%reducer_ostream` can pass a
+ * `%reducer_ostream` to a converted function that now expects a
+ * pointer or reference to a `reducer<%op_ostream>`, and vice versa.
+ *
+ * @tparam Char The stream element type (not the stream type).
+ * @tparam Traits The character traits type.
+ *
+ * @see op_ostream
+ * @see reducer
+ * @see ReducersOstream
*/
-inline
-std::ostream &
-reducer_ostream::get_reference()
+class reducer_ostream :
+ public reducer<op_basic_ostream<char, std::char_traits<char>, true> >
{
- View &v = imp_.view();
+ typedef reducer<op_basic_ostream<char, std::char_traits<char>, true> > base;
+ using base::view;
+public:
- return v;
-}
+ /// The view type for the reducer.
+ typedef base::view_type View;
-} // namespace cilk
+ /// The monoid type for the reducer.
+ typedef base::monoid_type Monoid;
+
+ /** Constructs an initial `reducer_ostream` from a `std::ostream`. The
+ * specified stream is used as the eventual destination for all text
+ * streamed to this hyperobject.
+ */
+ explicit reducer_ostream(const std::ostream &os) : base(os) {}
+
+ /** Returns a modifiable reference to the underlying 'ostream' object.
+ */
+ std::ostream& get_reference() { return view(); }
+
+ /** Writes to the ostream.
+ */
+ template<typename T>
+ std::ostream& operator<< (const T &v)
+ {
+ return view() << v;
+ }
+
+ /**
+ * Calls a manipulator.
+ *
+ * @param _Pfn Pointer to the manipulator function.
+ */
+ reducer_ostream& operator<< (std::ostream &(*_Pfn)(std::ostream &))
+ {
+ (*_Pfn)(view());
+ return *this;
+ }
+
+ /** @name Dereference
+ * @details Dereferencing a wrapper is a no-op. It simply returns the
+ * wrapper. Combined with the rule that the wrapper forwards view
+ * operations to its contained view, this means that view operations can
+ * be written the same way on reducers and wrappers, which is convenient
+ * for incrementally converting old code using wrappers to use reducers
+ * instead. That is:
+ *
+ * reducer<op_ostream> r;
+ * *r << "a"; // *r returns the view
+ * // operator<<() is a view member function
+ *
+ * reducer_ostream w;
+ * *w << "a"; // *w returns the wrapper
+ * // operator<<() is a wrapper member function
+ * // that calls the corresponding view function
+ */
+ //@{
+ reducer_ostream& operator*() { return *this; }
+ reducer_ostream const& operator*() const { return *this; }
-#endif // REDUCER_OSTREAM_H_INCLUDED
+ reducer_ostream* operator->() { return this; }
+ reducer_ostream const* operator->() const { return this; }
+ //@}
+
+ /** @name Upcast
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
+ *
+ * This means that a wrapper will automatically be upcast to its aligned
+ * reducer base class. The following conversion operators provide
+ * pseudo-upcasts to the corresponding unaligned reducer class.
+ */
+ //@{
+ operator reducer<op_ostream>& ()
+ {
+ return *reinterpret_cast< reducer<op_ostream>* >(this);
+ }
+ operator const reducer<op_ostream>& () const
+ {
+ return *reinterpret_cast< const reducer<op_ostream>* >(this);
+ }
+ //@}
+};
+
+} // namespace cilk
+#endif // REDUCER_OSTREAM_H_INCLUDED
diff --git a/libcilkrts/include/cilk/reducer_string.h b/libcilkrts/include/cilk/reducer_string.h
index 0d70dd8b30a..9af65d55341 100644
--- a/libcilkrts/include/cilk/reducer_string.h
+++ b/libcilkrts/include/cilk/reducer_string.h
@@ -1,10 +1,8 @@
/* reducer_string.h -*- C++ -*-
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,6 +29,20 @@
* 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.
*/
/** @file reducer_string.h
@@ -52,14 +63,14 @@
/** @defgroup ReducersString String Reducers
*
- * String reducers allow the creation of a string by concatenating a set of
+ * String reducers allow the creation of a string by concatenating a set of
* strings or characters in parallel.
*
* @ingroup Reducers
*
- * You should be familiar with @ref pagereducers "Cilk reducers", described in
- * file reducers.md, and particularly with @ref reducers_using, before trying
- * to use the information in this file.
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file reducers.md, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
*
* @section redstring_usage Usage Example
*
@@ -79,24 +90,24 @@
* @subsection redstring_monoid_values Value Set
*
* The value set of a string reducer is the set of values of the class
- * `std::basic_string<Char, Traits, Alloc>`, which we refer to as “the
- * reducer’s string type”.
+ * `std::basic_string<Char, Traits, Alloc>`, which we refer to as "the
+ * reducer's string type".
*
* @subsection redstring_monoid_operator Operator
*
- * The operator of a string reducer is the string concatenation operator,
- * defined by the “`+`” binary operator on the reducer’s string type.
+ * The operator of a string reducer is the string concatenation operator,
+ * defined by the "`+`" binary operator on the reducer's string type.
*
* @subsection redstring_monoid_identity Identity
*
- * The identity value of a string reducer is the empty string, which is the
+ * The identity value of a string reducer is the empty string, which is the
* value of the expression
* `std::basic_string<Char, Traits, Alloc>([allocator])`.
*
* @section redstring_operations Operations
*
* In the operation descriptions below, the type name `String` refers to the
- * reducer’s string type, `std::basic_string<Char, Traits, Alloc>`.
+ * reducer's string type, `std::basic_string<Char, Traits, Alloc>`.
*
* @subsection redstring_constructors Constructors
*
@@ -151,8 +162,8 @@
* the string computation.
*
* The strings for new views are created (by the view identity constructor)
- * using the same allocator as the string that was created when the reducer
- * was constructed. Note that this allocator is determined when the reducer is
+ * using the same allocator as the string that was created when the reducer
+ * was constructed. Note that this allocator is determined when the reducer is
* constructed. The following two examples may have very different behavior:
*
* string<Char, Traits, Allocator> a_string;
@@ -166,7 +177,7 @@
* ... parallel computation ...
* reducer2.move_out(a_string);
*
- * * `reducer1` will be constructed with the same allocator as `a_string`,
+ * * `reducer1` will be constructed with the same allocator as `a_string`,
* because the string was specified in the constructor. The `move_in`
* and `move_out` can therefore be done with a `swap` in constant time.
* * `reducer2` will be constructed with a _default_ allocator of type
@@ -175,8 +186,8 @@
* in _O(N)_ time.
*
* (All instances of an allocator type with no internal state (like
- * `std::allocator`) are “the same”. You only need to worry about the “same
- * allocator” issue when you create string reducers with custom allocator
+ * `std::allocator`) are "the same". You only need to worry about the "same
+ * allocator" issue when you create string reducers with custom allocator
* types.)
*
* @section redstring_types Type and Operator Requirements
@@ -192,12 +203,12 @@ namespace cilk {
/** The string append reducer view class.
*
* This is the view class for reducers created with
- * `cilk::reducer< cilk::op_basic_string<Type, Traits, Allocator> >`. It holds
+ * `cilk::reducer< cilk::op_basic_string<Char, Traits, Allocator> >`. It holds
* the accumulator variable for the reduction, and allows only append
* operations to be performed on it.
*
- * @note The reducer “dereference” operation (`reducer::operator *()`)
- * yields a reference to the view. Thus, for example, the view class’s
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view class's
* `append` operation would be used in an expression like
* `r->append(a)`, where `r` is a string append reducer variable.
*
@@ -215,7 +226,7 @@ class op_basic_string_view
typedef std::list<string_type> list_type;
typedef typename string_type::size_type size_type;
- // The view's value is represented by a list of strings and a single
+ // The view's value is represented by a list of strings and a single
// string. The value is the concatenation of the strings in the list with
// the single string at the end. All string operations apply to the single
// string; reduce operations cause lists of partial strings from multiple
@@ -224,7 +235,7 @@ class op_basic_string_view
mutable string_type m_string;
mutable list_type m_list;
- // Before returning the value of the reducer, concatenate all the strings
+ // Before returning the value of the reducer, concatenate all the strings
// in the list with the single string.
//
void flatten() const
@@ -263,11 +274,11 @@ public:
return m_string.get_allocator();
}
- /** Reduction operation.
+ /** Reduces the views of two strands.
*
* This function is invoked by the @ref op_basic_string monoid to combine
- * the views of two strands when the right strand merges with the left
- * one. It appends the value contained in the right-strand view to the
+ * the views of two strands when the right strand merges with the left
+ * one. It appends the value contained in the right-strand view to the
* value contained in the left-strand view, and leaves the value in the
* right-strand view undefined.
*
@@ -294,7 +305,7 @@ public:
//@}
- /** @name Pass constructor arguments through to the string constructor.
+ /** @name Passes constructor arguments to the string constructor.
*/
//@{
@@ -351,16 +362,18 @@ public:
m_string.clear();
}
- void view_set_value(const string_type& s)
+ void view_set_value(const string_type& s)
{ m_list.clear(); m_string = s; }
- string_type const& view_get_value() const
+ string_type const& view_get_value() const
{ flatten(); return m_string; }
- string_type & view_get_reference()
+ typedef string_type const& return_type_for_get_value;
+
+ string_type & view_get_reference()
{ flatten(); return m_string; }
- string_type const& view_get_reference() const
+ string_type const& view_get_reference() const
{ flatten(); return m_string; }
//@}
@@ -403,10 +416,10 @@ public:
* @tparam Traits The character traits type.
* @tparam Alloc The string allocator type.
* @tparam Align If `false` (the default), reducers instantiated on this
- * monoid will be naturally aligned (the Cilk library 1.0
+ * monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
- * will be cache-aligned for binary compatibility with
- * reducers in Cilk library version 0.9.
+ * will be cache-aligned for binary compatibility with
+ * reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersString
* @see op_basic_string_view
@@ -418,11 +431,13 @@ template<typename Char,
typename Traits = std::char_traits<Char>,
typename Alloc = std::allocator<Char>,
bool Align = false>
-class op_basic_string :
+class op_basic_string :
public monoid_with_view< op_basic_string_view<Char, Traits, Alloc>, Align >
{
typedef monoid_with_view< op_basic_string_view<Char, Traits, Alloc>, Align >
base;
+ typedef provisional_guard<typename base::view_type> view_guard;
+
Alloc m_allocator;
public:
@@ -442,7 +457,7 @@ public:
op_basic_string(const Alloc& allocator = Alloc()) : m_allocator(allocator)
{}
- /** Create an identity view.
+ /** Creates an identity view.
*
* String view identity constructors take the string allocator as an
* argument.
@@ -450,48 +465,67 @@ public:
* @param v The address of the uninitialized memory in which the view
* will be constructed.
*/
- void identity(view_type *v) const { ::new((void*) v) view_type(m_allocator); }
+ void identity(view_type *v) const
+ { ::new((void*) v) view_type(m_allocator); }
/** @name Construct functions
*
* A string append reduction monoid must have a copy of the allocator of
- * the leftmost view’s string, so that it can use it in the `identity`
+ * the leftmost view's string, so that it can use it in the `identity`
* operation. This, in turn, requires that string reduction monoids have a
* specialized `construct()` function.
*
* All string reducer monoid `construct()` functions first construct the
* leftmost view, using the arguments that were passed in from the reducer
- * constructor. They then call the view’s `get_allocator()` function to
+ * constructor. They then call the view's `get_allocator()` function to
* get the string allocator from the string in the leftmost view, and pass
* that to the monoid constructor.
*/
//@{
static void construct(op_basic_string* monoid, view_type* view)
- { provisional( new ((void*)view) view_type() ).confirm_if(
- new ((void*)monoid) op_basic_string(view->get_allocator()) ); }
+ {
+ view_guard vg( new((void*) view) view_type() );
+ vg.confirm_if(
+ new((void*) monoid) op_basic_string(view->get_allocator()) );
+ }
template <typename T1>
- static void construct(op_basic_string* monoid, view_type* view, const T1& x1)
- { provisional( new ((void*)view) view_type(x1) ).confirm_if(
- new ((void*)monoid) op_basic_string(view->get_allocator()) ); }
+ static void construct(op_basic_string* monoid, view_type* view,
+ const T1& x1)
+ {
+ view_guard vg( new((void*) view) view_type(x1) );
+ vg.confirm_if(
+ new((void*) monoid) op_basic_string(view->get_allocator()) );
+ }
template <typename T1, typename T2>
- static void construct(op_basic_string* monoid, view_type* view, const T1& x1, const T2& x2)
- { provisional( new ((void*)view) view_type(x1, x2) ).confirm_if(
- new ((void*)monoid) op_basic_string(view->get_allocator()) ); }
+ static void construct(op_basic_string* monoid, view_type* view,
+ const T1& x1, const T2& x2)
+ {
+ view_guard vg( new((void*) view) view_type(x1, x2) );
+ vg.confirm_if(
+ new((void*) monoid) op_basic_string(view->get_allocator()) );
+ }
template <typename T1, typename T2, typename T3>
- static void construct(op_basic_string* monoid, view_type* view, const T1& x1, const T2& x2,
- const T3& x3)
- { provisional( new ((void*)view) view_type(x1, x2, x3) ).confirm_if(
- new ((void*)monoid) op_basic_string(view->get_allocator()) ); }
+ static void construct(op_basic_string* monoid, view_type* view,
+ const T1& x1, const T2& x2, const T3& x3)
+ {
+ view_guard vg( new((void*) view) view_type(x1, x2, x3) );
+ vg.confirm_if(
+ new((void*) monoid) op_basic_string(view->get_allocator()) );
+ }
template <typename T1, typename T2, typename T3, typename T4>
- static void construct(op_basic_string* monoid, view_type* view, const T1& x1, const T2& x2,
- const T3& x3, const T4& x4)
- { provisional( new ((void*)view) view_type(x1, x2, x3, x4) ).confirm_if(
- new ((void*)monoid) op_basic_string(view->get_allocator()) ); }
+ static void construct(op_basic_string* monoid, view_type* view,
+ const T1& x1, const T2& x2, const T3& x3,
+ const T4& x4)
+ {
+ view_guard vg( new((void*) view) view_type(x1, x2, x3, x4) );
+ vg.confirm_if(
+ new((void*) monoid) op_basic_string(view->get_allocator()) );
+ }
//@}
};
@@ -500,7 +534,7 @@ public:
/** Convenience typedef for 8-bit strings
*/
typedef op_basic_string<char> op_string;
-
+
/** Convenience typedef for 16-bit strings
*/
typedef op_basic_string<wchar_t> op_wstring;
@@ -516,13 +550,13 @@ typedef op_basic_string<wchar_t> op_wstring;
* with `r.push_back(a)`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
- * reducers rather than the old wrappers like reducer_basic_string.
+ * reducers rather than the old wrappers like reducer_basic_string.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
- * @note Implicit conversions are provided between `%reducer_basic_string`
+ * @note Implicit conversions are provided between `%reducer_basic_string`
* and `reducer<%op_basic_string>`. This allows incremental code
* conversion: old code that used `%reducer_basic_string` can pass a
* `%reducer_basic_string` to a converted function that now expects a
@@ -540,17 +574,17 @@ typedef op_basic_string<wchar_t> op_wstring;
template<typename Char,
typename Traits = std::char_traits<Char>,
typename Alloc = std::allocator<Char> >
-class reducer_basic_string :
+class reducer_basic_string :
public reducer< op_basic_string<Char, Traits, Alloc, true> >
{
typedef reducer< op_basic_string<Char, Traits, Alloc, true> > base;
using base::view;
public:
- /// The reducer’s string type.
+ /// The reducer's string type.
typedef typename base::value_type string_type;
- /// The reducer’s primitive component type.
+ /// The reducer's primitive component type.
typedef Char basic_value_type;
/// The string size type.
@@ -566,7 +600,7 @@ public:
/** @name Constructors
*/
//@{
-
+
/** @name Forward constructor calls to the base class.
*
* All basic_string constructor forms are supported.
@@ -575,15 +609,15 @@ public:
reducer_basic_string() {}
template <typename T1>
- reducer_basic_string(const T1& x1) :
+ reducer_basic_string(const T1& x1) :
base(x1) {}
template <typename T1, typename T2>
- reducer_basic_string(const T1& x1, const T2& x2) :
+ reducer_basic_string(const T1& x1, const T2& x2) :
base(x1, x2) {}
template <typename T1, typename T2, typename T3>
- reducer_basic_string(const T1& x1, const T2& x2, const T3& x3) :
+ reducer_basic_string(const T1& x1, const T2& x2, const T3& x3) :
base(x1, x2, x3) {}
template <typename T1, typename T2, typename T3, typename T4>
@@ -591,18 +625,18 @@ public:
base(x1, x2, x3, x4) {}
//@}
- /** Allow mutable access to the string within the current view.
+ /** Allows mutable access to the string within the current view.
*
- * @warning If this method is called before the parallel calculation is
+ * @warning If this method is called before the parallel calculation is
* complete, the string returned by this method will be a
* partial result.
*
* @returns A mutable reference to the string within the current view.
*/
- string_type &get_reference()
+ string_type &get_reference()
{ return view().view_get_reference(); }
- /** Allow read-only access to the string within the current view.
+ /** Allows read-only access to the string within the current view.
*
* @warning If this method is called before the parallel calculation is
* complete, the string returned by this method will be a
@@ -610,10 +644,10 @@ public:
*
* @returns A const reference to the string within the current view.
*/
- string_type const &get_reference() const
+ string_type const &get_reference() const
{ return view().view_get_reference(); }
- /** @name Append to the string.
+ /** @name Appends to the string.
*
* These operations are simply forwarded to the view.
*/
@@ -629,7 +663,7 @@ public:
void append(size_type count, Char ch)
{ view().append(count, ch); }
- // Append to the string
+ // Appends to the string
reducer_basic_string<Char, Traits, Alloc> &operator+=(Char ch)
{ view() += ch; return *this; }
reducer_basic_string<Char, Traits, Alloc> &operator+=(const Char *ptr)
@@ -664,10 +698,10 @@ public:
//@}
/** @name Upcast
- * @details In Cilk library 0.9, reducers were always cache-aligned. In
- * library 1.0, reducer cache alignment is optional. By default, reducers
- * are unaligned (i.e., just naturally aligned), but legacy wrappers
- * inherit from cache-aligned reducers for binary compatibility.
+ * @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
+ * In library 1.0, reducer cache alignment is optional. By default,
+ * reducers are unaligned (i.e., just naturally aligned), but legacy
+ * wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
@@ -676,14 +710,14 @@ public:
//@{
operator reducer< op_basic_string<Char, Traits, Alloc, false> >& ()
{
- return *reinterpret_cast< reducer<
- op_basic_string<Char, Traits, Alloc, false> >*
+ return *reinterpret_cast< reducer<
+ op_basic_string<Char, Traits, Alloc, false> >*
>(this);
}
operator const reducer< op_basic_string<Char, Traits, Alloc, false> >& () const
{
return *reinterpret_cast< const reducer<
- op_basic_string<Char, Traits, Alloc, false> >*
+ op_basic_string<Char, Traits, Alloc, false> >*
>(this);
}
//@}
@@ -703,11 +737,11 @@ typedef reducer_basic_string<wchar_t> reducer_wstring;
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
- * This specialization of the @ref legacy_reducer_downcast template class
+ * This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the `reducer< op_basic_string<Char> >` class to
* have an `operator reducer_basic_string<Char>& ()` conversion operator that
* statically downcasts the `reducer<op_basic_string>` to the corresponding
- * `reducer_basic_string` type. (The reverse conversion, from
+ * `reducer_basic_string` type. (The reverse conversion, from
* `reducer_basic_string` to `reducer<op_basic_string>`, is just an upcast,
* which is provided for free by the language.)
*
diff --git a/libcilkrts/include/cilk/reducer_vector.h b/libcilkrts/include/cilk/reducer_vector.h
new file mode 100644
index 00000000000..fa53eee1d24
--- /dev/null
+++ b/libcilkrts/include/cilk/reducer_vector.h
@@ -0,0 +1,533 @@
+/* reducer_vector.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.
+ */
+
+/** @file reducer_vector.h
+ *
+ * @brief Defines classes for doing parallel vector creation by appending.
+ *
+ * @ingroup ReducersVector
+ *
+ * @see ReducersVector
+ */
+
+#ifndef REDUCER_VECTOR_H_INCLUDED
+#define REDUCER_VECTOR_H_INCLUDED
+
+#include <cilk/reducer.h>
+#include <vector>
+#include <list>
+
+/** @defgroup ReducersVector Vector Reducers
+ *
+ * Vector reducers allow the creation of a standard vector by
+ * appending a set of elements in parallel.
+ *
+ * @ingroup Reducers
+ *
+ * You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
+ * described in file `reducers.md`, and particularly with @ref reducers_using,
+ * before trying to use the information in this file.
+ *
+ * @section redvector_usage Usage Example
+ *
+ * typedef ... SourceData;
+ * typedef ... ResultData;
+ * vector<SourceData> input;
+ * ResultData expensive_computation(const SourceData& x);
+ * cilk::reducer< cilk::op_vector<ResultData> > r;
+ * cilk_for (int i = 0; i != input.size(); ++i) {
+ * r->push_back(expensive_computation(input[i]));
+ * }
+ * vector result;
+ * r.move_out(result);
+ *
+ * @section redvector_monoid The Monoid
+ *
+ * @subsection redvector_monoid_values Value Set
+ *
+ * The value set of a vector reducer is the set of values of the class
+ * `std::vector<Type, Alloc>`, which we refer to as "the reducer's vector
+ * type".
+ *
+ * @subsection redvector_monoid_operator Operator
+ *
+ * The operator of a vector reducer is vector concatenation.
+ *
+ * @subsection redvector_monoid_identity Identity
+ *
+ * The identity value of a vector reducer is the empty vector, which is the
+ * value of the expression `std::vector<Type, Alloc>([allocator])`.
+ *
+ * @section redvector_operations Operations
+ *
+ * In the operation descriptions below, the type name `Vector` refers to
+ * the reducer's vector type, `std::vector<Type, Alloc>`.
+ *
+ * @subsection redvector_constructors Constructors
+ *
+ * Any argument list which is valid for a `std::vector` constructor is valid
+ * for a vector reducer constructor. The usual move-in constructor is also
+ * provided:
+ *
+ * reducer(move_in(Vector& variable))
+ *
+ * @subsection redvector_get_set Set and Get
+ *
+ * void r.set_value(const Vector& value)
+ * const Vector& = r.get_value() const
+ * void r.move_in(Vector& variable)
+ * void r.move_out(Vector& variable)
+ *
+ * @subsection redvector_initial Initial Values
+ *
+ * A vector reducer with no constructor arguments, or with only an allocator
+ * argument, will initially contain the identity value, an empty vector.
+ *
+ * @subsection redvector_view_ops View Operations
+ *
+ * The view of a vector reducer provides the following member functions:
+ *
+ * void push_back(const Type& element)
+ * void insert_back(const Type& element)
+ * void insert_back(Vector::size_type n, const Type& element)
+ * template <typename Iter> void insert_back(Iter first, Iter last)
+ *
+ * The `push_back` functions is the same as the corresponding `std::vector`
+ * function. The `insert_back` function is the same as the `std::vector`
+ * `insert` function, with the first parameter fixed to the end of the vector.
+ *
+ * @section redvector_performance Performance Considerations
+ *
+ * Vector reducers work by creating a vector for each view, collecting those
+ * vectors in a list, and then concatenating them into a single result vector
+ * at the end of the computation. This last step takes place in serial code,
+ * and necessarily takes time proportional to the length of the result vector.
+ * Thus, a parallel vector reducer cannot actually speed up the time spent
+ * directly creating the vector. This trivial example would probably be slower
+ * (because of reducer overhead) than the corresponding serial code:
+ *
+ * vector<T> a;
+ * reducer<op_vector<T> > r;
+ * cilk_for (int i = 0; i != a.length(); ++i) {
+ * r->push_back(a[i]);
+ * }
+ * vector<T> result;
+ * r.move_out(result);
+ *
+ * What a vector reducer _can_ do is to allow the _remainder_ of the
+ * computation to be done in parallel, without having to worry about
+ * managing the vector computation.
+ *
+ * The vectors for new views are created (by the view identity constructor)
+ * using the same allocator as the vector that was created when the reducer
+ * was constructed. Note that this allocator is determined when the reducer
+ * is constructed. The following two examples may have very different
+ * behavior:
+ *
+ * vector<Type, Allocator> a_vector;
+ *
+ * reducer< op_vector<Type, Allocator> reducer1(move_in(a_vector));
+ * ... parallel computation ...
+ * reducer1.move_out(a_vector);
+ *
+ * reducer< op_vector<Type, Allocator> reducer2;
+ * reducer2.move_in(a_vector);
+ * ... parallel computation ...
+ * reducer2.move_out(a_vector);
+ *
+ * * `reducer1` will be constructed with the same allocator as `a_vector`,
+ * because the vector was specified in the constructor. The `move_in`
+ * and`move_out` can therefore be done with a `swap` in constant time.
+ * * `reducer2` will be constructed with a _default_ allocator of type
+ * `Allocator`, which may not be the same as the allocator of `a_vector`.
+ * Therefore, the `move_in` and `move_out` may have to be done with a
+ * copy in _O(N)_ time.
+ *
+ * (All instances of an allocator class with no internal state (like
+ * `std::allocator`) are "the same". You only need to worry about the "same
+ * allocator" issue when you create vector reducers with a custom allocator
+ * class that has data members.)
+ *
+ * @section redvector_types Type and Operator Requirements
+ *
+ * `std::vector<Type, Alloc>` must be a valid type.
+*/
+
+namespace cilk {
+
+/** @ingroup ReducersVector */
+//@{
+
+/** @brief The vector reducer view class.
+ *
+ * This is the view class for reducers created with
+ * `cilk::reducer< cilk::op_vector<Type, Allocator> >`. It holds the
+ * accumulator variable for the reduction, and allows only append operations
+ * to be performed on it.
+ *
+ * @note The reducer "dereference" operation (`reducer::operator *()`)
+ * yields a reference to the view. Thus, for example, the view
+ * class's `push_back` operation would be used in an expression like
+ * `r->push_back(a)`, where `r` is a vector reducer variable.
+ *
+ * @tparam Type The vector element type (not the vector type).
+ * @tparam Alloc The vector allocator type.
+ *
+ * @see @ref ReducersVector
+ * @see op_vector
+ */
+template<typename Type, typename Alloc>
+class op_vector_view
+{
+ typedef std::vector<Type, Alloc> vector_type;
+ typedef std::list<vector_type, typename Alloc::template rebind<vector_type>::other>
+ list_type;
+ typedef typename vector_type::size_type size_type;
+
+ // The view's value is represented by a list of vectors and a single
+ // vector. The value is the concatenation of the vectors in the list with
+ // the single vector at the end. All vector operations apply to the single
+ // vector; reduce operations cause lists of partial vectors from multiple
+ // strands to be combined.
+ //
+ mutable vector_type m_vector;
+ mutable list_type m_list;
+
+ // Before returning the value of the reducer, concatenate all the vectors
+ // in the list with the single vector.
+ //
+ void flatten() const
+ {
+ if (m_list.empty()) return;
+
+ typename list_type::iterator i;
+
+ size_type len = m_vector.size();
+ for (i = m_list.begin(); i != m_list.end(); ++i)
+ len += i->size();
+
+ vector_type result(get_allocator());
+ result.reserve(len);
+
+ for (i = m_list.begin(); i != m_list.end(); ++i)
+ result.insert(result.end(), i->begin(), i->end());
+ m_list.clear();
+
+ result.insert(result.end(), m_vector.begin(), m_vector.end());
+ result.swap(m_vector);
+ }
+
+public:
+
+ /** @name Monoid support.
+ */
+ //@{
+
+ /// Required by cilk::monoid_with_view
+ typedef vector_type value_type;
+
+ /// Required by @ref op_vector
+ Alloc get_allocator() const
+ {
+ return m_vector.get_allocator();
+ }
+
+ /** Reduces the views of two strands.
+ *
+ * This function is invoked by the @ref op_vector monoid to combine
+ * the views of two strands when the right strand merges with the left
+ * one. It appends the value contained in the right-strand view to the
+ * value contained in the left-strand view, and leaves the value in the
+ * right-strand view undefined.
+ *
+ * @param other A pointer to the right-strand view. (`this` points to
+ * the left-strand view.)
+ *
+ * @note Used only by the @ref op_vector monoid to implement the
+ * monoid reduce operation.
+ */
+ void reduce(op_vector_view* other)
+ {
+ if (!other->m_vector.empty() || !other->m_list.empty()) {
+ // (list, string) + (other_list, other_string) =>
+ // (list + {string} + other_list, other_string)
+ if (!m_vector.empty()) {
+ // simulate m_list.push_back(std::move(m_vector))
+ m_list.push_back(vector_type(get_allocator()));
+ m_list.back().swap(m_vector);
+ }
+ m_list.splice(m_list.end(), other->m_list);
+ m_vector.swap(other->m_vector);
+ }
+ }
+
+ //@}
+
+ /** @name Passes constructor arguments to the vector constructor.
+ */
+ //@{
+
+ op_vector_view() :
+ m_vector(), m_list(get_allocator()) {}
+
+ template <typename T1>
+ op_vector_view(const T1& x1) :
+ m_vector(x1), m_list(get_allocator()) {}
+
+ template <typename T1, typename T2>
+ op_vector_view(const T1& x1, const T2& x2) :
+ m_vector(x1, x2), m_list(get_allocator()) {}
+
+ template <typename T1, typename T2, typename T3>
+ op_vector_view(const T1& x1, const T2& x2, const T3& x3) :
+ m_vector(x1, x2, x3), m_list(get_allocator()) {}
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ op_vector_view(const T1& x1, const T2& x2, const T3& x3, const T4& x4) :
+ m_vector(x1, x2, x3, x4), m_list(get_allocator()) {}
+
+ //@}
+
+ /** Move-in constructor.
+ */
+ explicit op_vector_view(cilk::move_in_wrapper<value_type> w) :
+ m_vector(w.value().get_allocator()),
+ m_list(w.value().get_allocator())
+ {
+ m_vector.swap(w.value());
+ }
+
+ /** @name Reducer support.
+ */
+ //@{
+
+ void view_move_in(vector_type& v)
+ {
+ m_list.clear();
+ if (get_allocator() == v.get_allocator()) {
+ // Equal allocators. Do a (fast) swap.
+ m_vector.swap(v);
+ }
+ else {
+ // Unequal allocators. Do a (slow) copy.
+ m_vector = v;
+ }
+ v.clear();
+ }
+
+ void view_move_out(vector_type& v)
+ {
+ flatten();
+ if (get_allocator() == v.get_allocator()) {
+ // Equal allocators. Do a (fast) swap.
+ m_vector.swap(v);
+ }
+ else {
+ // Unequal allocators. Do a (slow) copy.
+ v = m_vector;
+ m_vector.clear();
+ }
+ }
+
+ void view_set_value(const vector_type& v)
+ {
+ m_list.clear();
+ m_vector = v;
+ }
+
+ vector_type const& view_get_value() const
+ {
+ flatten();
+ return m_vector;
+ }
+
+ typedef vector_type const& return_type_for_get_value;
+
+ //@}
+
+ /** @name View modifier operations.
+ *
+ * @details These simply wrap the corresponding operations on the
+ * underlying vector.
+ */
+ //@{
+
+ /** Adds an element at the end of the list.
+ *
+ * Equivalent to `vector.push_back(…)`
+ */
+ void push_back(const Type x)
+ {
+ m_vector.push_back(x);
+ }
+
+ /** @name Insert elements at the end of the vector.
+ *
+ * Equivalent to `vector.insert(vector.end(), …)`
+ */
+ //@{
+
+ void insert_back(const Type& element)
+ { m_vector.insert(m_vector.end(), element); }
+
+ void insert_back(typename vector_type::size_type n, const Type& element)
+ { m_vector.insert(m_vector.end(), n, element); }
+
+ template <typename Iter>
+ void insert_back(Iter first, Iter last)
+ { m_vector.insert(m_vector.end(), first, last); }
+
+ //@}
+
+ //@}
+};
+
+
+/** @brief The vector append monoid class.
+ *
+ * Instantiate the cilk::reducer template class with an op_vector monoid to
+ * create a vector reducer class. For example, to concatenate a
+ * collection of integers:
+ *
+ * cilk::reducer< cilk::op_vector<int> > r;
+ *
+ * @tparam Type The vector element type (not the vector type).
+ * @tparam Alloc The vector allocator type.
+ *
+ * @see ReducersVector
+ * @see op_vector_view
+ * @ingroup ReducersVector
+ */
+template<typename Type, typename Alloc = std::allocator<Type> >
+class op_vector :
+ public cilk::monoid_with_view< op_vector_view<Type, Alloc>, false >
+{
+ typedef cilk::monoid_with_view< op_vector_view<Type, Alloc>, false > base;
+ typedef provisional_guard<typename base::view_type> view_guard;
+
+ // The allocator to be used when constructing new views.
+ Alloc m_allocator;
+
+public:
+
+ /// View type.
+ typedef typename base::view_type view_type;
+
+ /** Constructor.
+ *
+ * There is no default constructor for vector monoids, because the
+ * allocator must always be specified.
+ *
+ * @param allocator The list allocator to be used when
+ * identity-constructing new views.
+ */
+ op_vector(const Alloc& allocator = Alloc()) : m_allocator(allocator) {}
+
+ /** Creates an identity view.
+ *
+ * Vector view identity constructors take the vector allocator as an
+ * argument.
+ *
+ * @param v The address of the uninitialized memory in which the view
+ * will be constructed.
+ */
+ void identity(view_type *v) const
+ {
+ ::new((void*) v) view_type(m_allocator);
+ }
+
+ /** @name construct functions
+ *
+ * A vector append monoid must have a copy of the allocator of
+ * the leftmost view's vector, so that it can use it in the `identity`
+ * operation. This, in turn, requires that vector append monoids have a
+ * specialized `construct()` function.
+ *
+ * All vector append monoid `construct()` functions first construct the
+ * leftmost view, using the arguments that were passed in from the reducer
+ * constructor. They then call the view's `get_allocator()` function to
+ * get the vector allocator from the vector in the leftmost view, and pass
+ * that to the monoid constructor.
+ */
+ //@{
+
+ static void construct(op_vector* monoid, view_type* view)
+ {
+ view_guard vg( new((void*) view) view_type() );
+ vg.confirm_if( new((void*) monoid) op_vector(view->get_allocator()) );
+ }
+
+ template <typename T1>
+ static void construct(op_vector* monoid, view_type* view, const T1& x1)
+ {
+ view_guard vg( new((void*) view) view_type(x1) );
+ vg.confirm_if( new((void*) monoid) op_vector(view->get_allocator()) );
+ }
+
+ template <typename T1, typename T2>
+ static void construct(op_vector* monoid, view_type* view,
+ const T1& x1, const T2& x2)
+ {
+ view_guard vg( new((void*) view) view_type(x1, x2) );
+ vg.confirm_if( new((void*) monoid) op_vector(view->get_allocator()) );
+ }
+
+ template <typename T1, typename T2, typename T3>
+ static void construct(op_vector* monoid, view_type* view,
+ const T1& x1, const T2& x2, const T3& x3)
+ {
+ view_guard vg( new((void*) view) view_type(x1, x2, x3) );
+ vg.confirm_if( new((void*) monoid) op_vector(view->get_allocator()) );
+ }
+
+ //@}
+};
+
+
+} // namespace cilk
+
+#endif // REDUCER_VECTOR_H_INCLUDED
diff --git a/libcilkrts/include/cilktools/cilkscreen.h b/libcilkrts/include/cilktools/cilkscreen.h
index c6986ae7b08..1e26c450ebe 100644
--- a/libcilkrts/include/cilktools/cilkscreen.h
+++ b/libcilkrts/include/cilktools/cilkscreen.h
@@ -2,11 +2,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:
@@ -21,7 +19,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
@@ -34,6 +31,20 @@
* 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.
*
**************************************************************************/
diff --git a/libcilkrts/include/cilktools/cilkview.h b/libcilkrts/include/cilktools/cilkview.h
index eb7d9d8c0e4..e98489368af 100644
--- a/libcilkrts/include/cilktools/cilkview.h
+++ b/libcilkrts/include/cilktools/cilkview.h
@@ -2,11 +2,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:
@@ -21,7 +19,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
@@ -34,6 +31,20 @@
* 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.
*
**************************************************************************/
diff --git a/libcilkrts/include/cilktools/fake_mutex.h b/libcilkrts/include/cilktools/fake_mutex.h
index 9ae0678112f..b7facf83f6d 100644
--- a/libcilkrts/include/cilktools/fake_mutex.h
+++ b/libcilkrts/include/cilktools/fake_mutex.h
@@ -2,11 +2,9 @@
*
*************************************************************************
*
- * @copyright
- * Copyright (C) 2013, Intel Corporation
+ * Copyright (C) 2013-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:
@@ -21,7 +19,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
@@ -34,6 +31,20 @@
* 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.
*
**************************************************************************
*
diff --git a/libcilkrts/include/cilktools/lock_guard.h b/libcilkrts/include/cilktools/lock_guard.h
index d513e2b9734..e2e16382b75 100644
--- a/libcilkrts/include/cilktools/lock_guard.h
+++ b/libcilkrts/include/cilktools/lock_guard.h
@@ -2,11 +2,9 @@
*
*************************************************************************
*
- * @copyright
- * Copyright (C) 2011-2013, Intel Corporation
+ * Copyright (C) 2011-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:
@@ -21,7 +19,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
@@ -34,6 +31,20 @@
* 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.
*
**************************************************************************
*
diff --git a/libcilkrts/include/internal/abi.h b/libcilkrts/include/internal/abi.h
index f45b5bcb178..3f38485d26b 100644
--- a/libcilkrts/include/internal/abi.h
+++ b/libcilkrts/include/internal/abi.h
@@ -1,11 +1,9 @@
/*
* abi.h
*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -20,7 +18,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
@@ -33,6 +30,20 @@
* 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.
*
******************************************************************************/
@@ -461,6 +472,20 @@ CILK_ABI(void) __cilkrts_enter_frame_fast_1(__cilkrts_stack_frame *sf);
CILK_ABI(void) __cilkrts_leave_frame(__cilkrts_stack_frame *sf);
/**
+ * Suspends the runtime by notifying the workers that they should not try to
+ * steal. This function is supposed to be called from a non-parallel region
+ * (i.e., after cilk_sync in the top-level spawning function). Otherwise,
+ * which workers are sleeping or busy is unpredictable in general.
+ * The runtime can be resumed by calling __cilkrts_resume().
+ */
+CILK_ABI(void) __cilkrts_suspend(void);
+
+/**
+ * Resumes the runtime by notifying the workers that they can steal.
+ */
+CILK_ABI(void) __cilkrts_resume(void);
+
+/**
* Wait for any spawned children of this function to complete before
* continuing. This function will only return when the join counter
* has gone to 0. Other workers will re-enter the scheduling loop to
diff --git a/libcilkrts/include/internal/cilk_fake.h b/libcilkrts/include/internal/cilk_fake.h
index 2386dd6bffa..7d09de29c1e 100644
--- a/libcilkrts/include/internal/cilk_fake.h
+++ b/libcilkrts/include/internal/cilk_fake.h
@@ -2,11 +2,9 @@
*
*************************************************************************
*
- * @copyright
- * Copyright (C) 2011-2013, Intel Corporation
+ * Copyright (C) 2011-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:
@@ -21,7 +19,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
@@ -34,6 +31,20 @@
* 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.
**************************************************************************/
/**
diff --git a/libcilkrts/include/internal/cilk_version.h b/libcilkrts/include/internal/cilk_version.h
index f628338f7d2..95e1f2ec544 100644
--- a/libcilkrts/include/internal/cilk_version.h
+++ b/libcilkrts/include/internal/cilk_version.h
@@ -1,10 +1,8 @@
// cilk_version.h
//
-// @copyright
-// Copyright (C) 2009-2013, Intel Corporation
+// Copyright (C) 2009-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:
@@ -19,7 +17,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
@@ -32,16 +29,30 @@
// 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.
// DO NOT EDIT THIS FILE!
//
// It was automatically generated by cilkrts/include/internal/Makefile
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
-#define VERSION_BUILD 3902
+#define VERSION_BUILD 4420
#define VERSION_REV 0
-#define VERSION_STRING "2,0,3902,0"
-#define VERSION_HASH "b4e38f4f7e3e"
-#define VERSION_BRANCH "v14.0"
-#define TBB_REV_NUMBER ""
-#define VERSION_YEAR "2013"
+#define VERSION_STRING "2,0,4420,0"
+#define VERSION_HASH "3b2d6aa9059c"
+#define VERSION_BRANCH "eng"
+#define TBB_REV_NUMBER "14788"
+#define VERSION_YEAR "2015"
diff --git a/libcilkrts/include/internal/metacall.h b/libcilkrts/include/internal/metacall.h
index 886f49f9f83..00aa0f1598a 100644
--- a/libcilkrts/include/internal/metacall.h
+++ b/libcilkrts/include/internal/metacall.h
@@ -1,11 +1,9 @@
// -*- C++ -*-
/*
- * @copyright
- * Copyright (C) 2009-2013, Intel Corporation
+ * Copyright (C) 2009-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:
@@ -20,7 +18,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
@@ -33,6 +30,20 @@
* 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.
*
******************************************************************************
*
diff --git a/libcilkrts/include/internal/rev.mk b/libcilkrts/include/internal/rev.mk
index f65ad6d57d0..96ffdc4aa4e 100644
--- a/libcilkrts/include/internal/rev.mk
+++ b/libcilkrts/include/internal/rev.mk
@@ -1,10 +1,8 @@
#########################################################################
#
-# @copyright
-# Copyright (C) 2011-2013, Intel Corporation
+# Copyright (C) 2011-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:
@@ -19,7 +17,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
@@ -32,10 +29,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.
###########################################################################
# DO NOT EDIT THIS FILE!
#
# It was automatically generated by cilkrts/include/internal/Makefile
-CILK_REVISION = 3902
+CILK_REVISION = 4420