This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[UPC 20/22] libgupc runtime library [4/9]


[NOTE: Due to email list size limits, this patch is broken into 9 parts.]

Background
----------

An overview email, describing the UPC-related changes is here:
  https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00005.html

The GUPC branch is described here:
  http://gcc.gnu.org/projects/gupc.html

The UPC-related source code differences are summarized here:
  http://gccupc.org/gupc-changes

All languages (c, c++, fortran, go, lto, objc, obj-c++) have been
bootstrapped; no test suite regressions were introduced,
relative to the GCC trunk.

If you are on the cc-list, your name was chosen either
because you are listed as a maintainer for the area that
applies to the patches described in this email, or you
were a frequent contributor of patches made to files listed
in this email.

In the change log entries included in each patch, the directory
containing the affected files is listed, followed by the files.
When the patches are applied, the change log entries will be
distributed to the appropriate ChangeLog file.

Overview
--------

Libgupc is the UPC runtime library, for GUPC.  The configuration,
makefile, and documentation related changes have been broken out into
separate patches.

As noted in the ChangeLog entry below, this is all new code.
Two communication layers are supported: (1) SMP, via 'mmap'
or (2) the Portals4 library API, which supports multi-node
operation.  Libgupc generally requires a POSIX-compliant target OS.

The 'smp' runtime is the default runtime.  The 'portals4'
runtime is experimental; it supports multi-node operation
using the Portals4 communications library.

Most of the libgupc/include/ directory contains standard headers
defined by the UPC language specification. 'make install' will
install these headers in the directory where other "C"
header files are located.

2015-11-30  Gary Funck  <gary@intrepid.com>

	libgupc/collectives/
	* upc_coll.h: New.
	* upc_coll_broadcast.upc: New.
	* upc_coll_err.upc: New.
	* upc_coll_exchange.upc: New.
	* upc_coll_gather.upc: New.
	* upc_coll_gather_all.upc: New.
	* upc_coll_init.upc: New.

Index: libgupc/collectives/upc_coll.h
===================================================================
--- libgupc/collectives/upc_coll.h	(.../trunk)	(revision 0)
+++ libgupc/collectives/upc_coll.h	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,67 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*****************************************************************************/
+/*                                                                           */
+/*  Copyright (c) 2004, Michigan Technological University                    */
+/*  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 the Michigan Technological University              */
+/*  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 OWNER */
+/*  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.             */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef _UPC_COLL_H_
+#define _UPC_COLL_H_ 1
+
+extern int upc_coll_init_flag;
+extern void upc_coll_init (void);
+
+#endif /* !_UPC_COLL_H_ */
Index: libgupc/collectives/upc_coll_broadcast.upc
===================================================================
--- libgupc/collectives/upc_coll_broadcast.upc	(.../trunk)	(revision 0)
+++ libgupc/collectives/upc_coll_broadcast.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,128 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*****************************************************************************/
+/*                                                                           */
+/*  Copyright (c) 2004, Michigan Technological University                    */
+/*  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 the Michigan Technological University              */
+/*  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 OWNER */
+/*  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.             */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <upc.h>
+#include <upc_collective.h>
+#include <upc_coll.h>
+
+/*****************************************************************************/
+/*                                                                           */
+/*        UPC collective function library, reference implementation          */
+/*                                                                           */
+/*   Steve Seidel, Dept. of Computer Science, Michigan Technological Univ.   */
+/*   steve@mtu.edu                                        March 1, 2004      */
+/*                                                                           */
+/*****************************************************************************/
+
+void
+upc_all_broadcast (shared void *dst,
+		   shared const void *src,
+		   size_t nbytes, upc_flag_t sync_mode)
+{
+
+#ifndef PULL
+#ifndef PUSH
+#define PULL TRUE
+#endif
+#endif
+#ifdef PUSH
+  int i;
+#endif
+
+  if (!upc_coll_init_flag)
+    upc_coll_init ();
+
+#ifdef _UPC_COLL_CHECK_ARGS
+  upc_coll_err (dst, src, NULL, nbytes, sync_mode, 0, 0, 0, UPC_BRDCST);
+#endif
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_IN_MYSYNC & sync_mode || !(UPC_IN_NOSYNC & sync_mode))
+
+    upc_barrier;
+
+#ifdef PULL
+
+  // Each thread "pulls" the data from the source thread.
+
+  upc_memcpy ((shared char *) dst + MYTHREAD, (shared char *) src, nbytes);
+
+#endif
+
+#ifdef PUSH
+
+  // The source thread "pushes" the data to each destination.
+
+  if (upc_threadof ((shared void *) src) == MYTHREAD)
+    {
+      for (i = 0; i < THREADS; ++i)
+	{
+	  upc_memcpy ((shared char *) dst + i, (shared char *) src, nbytes);
+	}
+    }
+
+#endif
+
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_OUT_MYSYNC & sync_mode || !(UPC_OUT_NOSYNC & sync_mode))
+
+    upc_barrier;
+}
Index: libgupc/collectives/upc_coll_err.upc
===================================================================
--- libgupc/collectives/upc_coll_err.upc	(.../trunk)	(revision 0)
+++ libgupc/collectives/upc_coll_err.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,493 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*****************************************************************************/
+/*                                                                           */
+/*  Copyright (c) 2004, Michigan Technological University                    */
+/*  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 the Michigan Technological University              */
+/*  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 OWNER */
+/*  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.             */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <upc.h>
+#include <upc_collective.h>
+#include <upc_coll.h>
+
+/*****************************************************************************/
+/*                                                                           */
+/*        UPC collective function library, reference implementation          */
+/*                                                                           */
+/*   Steve Seidel, Dept. of Computer Science, Michigan Technological Univ.   */
+/*   steve@mtu.edu                                        March 1, 2004      */
+/*                                                                           */
+/*****************************************************************************/
+
+/*
+   upc_coll_err.c is included if _UPC_COLL_CHECK_ARGS is defined.
+   This code checks for the single-valuedness of collective function
+   arguments as well as checking that all threads have called the
+   same function.  Range checking of size_t arguments is done, and
+   the perm array is checked to be a true permutation of 0..THREADS-1.
+   However, (prefix) reduce functions of different types cannot be
+   distinguished.  Overlapping src and dst arguments are not detected.
+
+   When each thread reaches its collective call it fills in
+   corresponding entries of the coll_arg_list defined below.
+   This list has affinity to thread 0.  After a barrier,
+   thread 0 does all the argument checking locally on this
+   list.  If no errors are found, all threads are released to
+   continue execution after a final barrier.
+*/
+
+#include <stdio.h>
+
+typedef struct
+{
+  shared void *dst;
+  shared const void *src;
+  shared const int *perm;
+  size_t nbytes;
+  upc_flag_t sync_mode;
+  size_t blk_size;
+  size_t nelems;
+  upc_op_t op;
+  upc_flag_t upc_coll_op;
+} coll_arg_list_type;
+
+shared coll_arg_list_type *coll_arg_list;
+
+static const char *
+upc_coll_op_name (upc_flag_t upc_coll_op)
+{
+  switch (upc_coll_op)
+    {
+    case UPC_BRDCST:
+      return "upc_all_broadcast";
+      break;
+    case UPC_SCAT:
+      return "upc_all_scatter";
+      break;
+    case UPC_GATH:
+      return "upc_all_gather";
+      break;
+    case UPC_GATH_ALL:
+      return "upc_all_gather_all";
+      break;
+    case UPC_EXCH:
+      return "upc_all_exchange";
+      break;
+    case UPC_PERM:
+      return "upc_all_permute";
+      break;
+    case UPC_RED:
+      return "upc_all_reduce";
+      break;
+    case UPC_PRED:
+      return "upc_all_prefix_reduce";
+      break;
+    case UPC_SORT:
+      return "upc_all_sort";
+      break;
+    }
+  return NULL;
+}
+
+static void
+upc_coll_chk_nbytes (void)
+{
+  int i;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].nbytes != coll_arg_list[i].nbytes)
+      {
+	printf ("%s: nbytes must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+
+  if (coll_arg_list[0].nbytes < 1)
+    {
+      printf ("%s: nbytes must be greater than 0\n",
+	      upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+      upc_global_exit (1);
+    }
+}
+
+static void
+upc_coll_chk_blk_size (void)
+{
+  int i;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].blk_size != coll_arg_list[i].blk_size)
+      {
+	printf ("%s: blk_size must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+  // Note: blk_size is an unsigned int so we do not check whether
+  // it might be negative.
+}
+
+static void
+upc_coll_chk_nelems (void)
+{
+  int i;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].nelems != coll_arg_list[i].nelems)
+      {
+	printf ("%s: nelems must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+
+  if (coll_arg_list[0].nelems < 1)
+    {
+      printf ("%s: nelems must be greater than 0\n",
+	      upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+      upc_global_exit (1);
+    }
+}
+
+static void
+upc_coll_chk_elemsize (void)
+{
+  int i;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].nbytes != coll_arg_list[i].nbytes)
+      {
+	printf ("%s: elem_size must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+
+  if (coll_arg_list[0].nbytes < 1)
+    {
+      printf ("%s: elem_size must be greater than 0\n",
+	      upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+      upc_global_exit (1);
+    }
+}
+
+static void
+upc_coll_chk_dst_affinity (void)
+{
+  int i;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].dst != coll_arg_list[i].dst)
+      {
+	printf ("%s: dst must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+
+  if (upc_threadof (coll_arg_list[0].dst) != 0)
+    {
+      printf ("%s: Target of dst pointer must have affinity to thread 0\n",
+	      upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+      upc_global_exit (1);
+    }
+}
+
+static void
+upc_coll_chk_src_affinity (void)
+{
+  int i;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].src != coll_arg_list[i].src)
+      {
+	printf ("%s: src must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+
+  if (upc_threadof ((shared void *) coll_arg_list[0].src) != 0)
+    {
+      printf ("%s: Target of src pointer must have affinity to thread 0\n",
+	      upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+      upc_global_exit (1);
+    }
+}
+
+static void
+upc_coll_chk_phase (void)
+{
+  if (upc_phaseof ((shared void *) coll_arg_list[0].src)
+      != upc_phaseof ((shared void *) coll_arg_list[0].dst))
+    {
+      printf
+	("%s: Implementation limitation - src and dst must have the same phase.\n",
+	 upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+      upc_global_exit (1);
+    }
+}
+
+static void
+upc_coll_chk_perm (void)
+{
+  int i, j;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].perm != coll_arg_list[i].perm)
+      {
+	printf ("%s: perm must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+
+  if (upc_threadof ((shared void *) coll_arg_list[0].perm) != 0)
+    {
+      printf ("%s: Target of perm pointer must have affinity to thread 0\n",
+	      upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+      upc_global_exit (1);
+    }
+
+  // Check that perm[0..THREADS-1] contains a permutation of 0..THREADS-1.
+
+  for (i = 0; i < THREADS; i++)
+    {
+      for (j = 0; j < THREADS; j++)
+	if (i == (coll_arg_list[0].perm)[j])
+	  break;
+      if (j == THREADS)
+	{
+	  printf ("%s: Permutation array must contain a"
+		  " permutation of 0..THREADS-1. \n",
+		  upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	  upc_global_exit (1);
+	}
+    }
+}
+
+static void
+upc_coll_chk_op (void)
+{
+  int i;
+
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].op != coll_arg_list[i].op)
+      {
+	printf ("%s: op must have the same value in corresponding"
+		" calls to collective function\n",
+		upc_coll_op_name (coll_arg_list[0].upc_coll_op));
+	upc_global_exit (1);
+      }
+
+  for (i = 0; i < THREADS; ++i)
+    if (coll_arg_list[i].op > UPC_MAX_COLL_OP)
+      {
+	printf ("%s: Illegal operation specified in thread %d.\n",
+		upc_coll_op_name (coll_arg_list[i].upc_coll_op), i);
+	upc_global_exit (1);
+      }
+}
+
+static void
+upc_coll_chk_sync_mode (void)
+{
+  int i;
+
+  // Check for nonsensical combinations of synchronization modes
+  // and for meaningless values of sync_mode.
+
+  for (i = 0; i < THREADS; ++i)
+    {
+      upc_flag_t in_mode = coll_arg_list[i].sync_mode &
+	(UPC_IN_NOSYNC | UPC_IN_MYSYNC | UPC_IN_ALLSYNC);
+      upc_flag_t out_mode = coll_arg_list[i].sync_mode &
+	(UPC_OUT_NOSYNC | UPC_OUT_MYSYNC | UPC_OUT_ALLSYNC);
+      if (((in_mode != 0) && (in_mode != UPC_IN_ALLSYNC) &&
+	   (in_mode != UPC_IN_MYSYNC) && (in_mode != UPC_IN_NOSYNC)) ||
+	  ((out_mode != 0) && (out_mode != UPC_OUT_ALLSYNC) &&
+	   (out_mode != UPC_OUT_MYSYNC) && (out_mode != UPC_OUT_NOSYNC)) ||
+	  ((in_mode | out_mode) != coll_arg_list[i].sync_mode))
+
+	{
+	  printf ("%s: Conflicting or unknown collective synchronization"
+		  " modes in thread %d. \n",
+		  upc_coll_op_name (coll_arg_list[i].upc_coll_op), i);
+	  upc_global_exit (1);
+	}
+    }
+  // Check for conflicting synchronization modes.
+  for (i = 1; i < THREADS; ++i)
+    if (coll_arg_list[0].sync_mode != coll_arg_list[i].sync_mode)
+      {
+	printf ("%s: Threads 0 and %d have two different synchronization"
+		" modes\n", upc_coll_op_name (coll_arg_list[i].upc_coll_op), i);
+	upc_global_exit (1);
+      }
+}
+
+void
+upc_coll_err (shared void *dst,
+	      shared const void *src,
+	      shared const int *perm,
+	      size_t nbytes,
+	      upc_flag_t sync_mode,
+	      size_t blk_size,
+	      size_t nelems, upc_op_t op, upc_flag_t upc_coll_op)
+{
+  int i;
+
+  coll_arg_list = upc_all_alloc (THREADS, sizeof (coll_arg_list_type));
+
+  coll_arg_list[MYTHREAD].dst = dst;
+  coll_arg_list[MYTHREAD].src = src;
+  coll_arg_list[MYTHREAD].perm = perm;
+  coll_arg_list[MYTHREAD].nbytes = nbytes;
+  coll_arg_list[MYTHREAD].sync_mode = sync_mode;
+  coll_arg_list[MYTHREAD].blk_size = blk_size;
+  coll_arg_list[MYTHREAD].nelems = nelems;
+  coll_arg_list[MYTHREAD].op = op;
+  coll_arg_list[MYTHREAD].upc_coll_op = upc_coll_op;
+
+  upc_barrier;
+
+  // Now thread 0 has access to the arguments of all of the collective
+  // function calls.  All other threads now wait until thread 0 checks
+  // the arguments to all threads' collective function.
+
+  if (MYTHREAD == 0)
+
+    {
+      // Check that all collective calls are to the same function.
+      // (At most one disagreement is detected.)
+      // However, mismatches between (prefix) reduce functions
+      // of different types is not detected.
+
+      for (i = 1; i < THREADS; ++i)
+	if (coll_arg_list[0].upc_coll_op != coll_arg_list[i].upc_coll_op)
+	  {
+	    printf ("Threads 0 and %d have "
+		    "called two different collective "
+		    "functions: %s \t %s \n",
+		    i, upc_coll_op_name (coll_arg_list[0].upc_coll_op),
+		    upc_coll_op_name (coll_arg_list[i].upc_coll_op));
+	    upc_global_exit (1);
+	  }
+
+      switch (upc_coll_op)
+	{
+	case UPC_BRDCST:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_nbytes ();
+	  upc_coll_chk_dst_affinity ();
+	  break;
+	case UPC_SCAT:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_nbytes ();
+	  upc_coll_chk_dst_affinity ();
+	  break;
+	case UPC_GATH:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_nbytes ();
+	  upc_coll_chk_src_affinity ();
+	  break;
+	case UPC_GATH_ALL:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_nbytes ();
+	  upc_coll_chk_src_affinity ();
+	  upc_coll_chk_dst_affinity ();
+	  break;
+	case UPC_EXCH:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_nbytes ();
+	  upc_coll_chk_src_affinity ();
+	  upc_coll_chk_dst_affinity ();
+	  break;
+	case UPC_PERM:
+	  upc_coll_chk_perm ();
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_nbytes ();
+	  upc_coll_chk_src_affinity ();
+	  upc_coll_chk_dst_affinity ();
+	  break;
+	case UPC_RED:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_op ();
+	  upc_coll_chk_blk_size ();
+	  upc_coll_chk_nelems ();
+	  break;
+	case UPC_PRED:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_op ();
+	  upc_coll_chk_blk_size ();
+	  upc_coll_chk_nelems ();
+	  upc_coll_chk_phase ();
+	  break;
+	case UPC_SORT:
+	  upc_coll_chk_sync_mode ();
+	  upc_coll_chk_blk_size ();
+	  upc_coll_chk_nelems ();
+	  // use  nbytes instead of the id elem_size as in spec
+	  upc_coll_chk_elemsize ();
+	  break;
+	}			// switch
+      upc_free (coll_arg_list);
+    }
+  // If thread 0 detected no errors, all threads are released to
+  // execute their collective functions.
+
+  upc_barrier;
+}
Index: libgupc/collectives/upc_coll_exchange.upc
===================================================================
--- libgupc/collectives/upc_coll_exchange.upc	(.../trunk)	(revision 0)
+++ libgupc/collectives/upc_coll_exchange.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,129 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*****************************************************************************/
+/*                                                                           */
+/*  Copyright (c) 2004, Michigan Technological University                    */
+/*  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 the Michigan Technological University              */
+/*  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 OWNER */
+/*  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.             */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <upc.h>
+#include <upc_collective.h>
+#include <upc_coll.h>
+
+/*****************************************************************************/
+/*                                                                           */
+/*        UPC collective function library, reference implementation          */
+/*                                                                           */
+/*   Steve Seidel, Dept. of Computer Science, Michigan Technological Univ.   */
+/*   steve@mtu.edu                                        March 1, 2004      */
+/*                                                                           */
+/*****************************************************************************/
+
+void
+upc_all_exchange (shared void *dst,
+		  shared const void *src, size_t nbytes, upc_flag_t sync_mode)
+{
+#ifndef PULL
+#ifndef PUSH
+#define PULL TRUE
+#endif
+#endif
+
+  int i;
+
+  if (!upc_coll_init_flag)
+    upc_coll_init ();
+
+#ifdef _UPC_COLL_CHECK_ARGS
+  upc_coll_err (dst, src, NULL, nbytes, sync_mode, 0, 0, 0, UPC_EXCH);
+#endif
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_IN_MYSYNC & sync_mode || !(UPC_IN_NOSYNC & sync_mode))
+
+    upc_barrier;
+#ifdef PULL
+
+  // Thread MYTHREAD copies the MYTHREADth block of thread i to
+  // its own ith block.
+
+  for (i = 0; i < THREADS; i++)
+    {
+      upc_memcpy ((shared char *) dst + i * nbytes * THREADS + MYTHREAD,
+		  (shared char *) src + MYTHREAD * nbytes * THREADS + i,
+		  nbytes);
+    }
+
+#endif
+
+#ifdef PUSH
+
+  // Thread MYTHREAD copies its ith block to the MYTHREADth block
+  // of thread i
+
+  for (i = 0; i < THREADS; i++)
+    {
+      upc_memcpy ((shared char *) dst + MYTHREAD * nbytes * THREADS + i,
+		  (shared char *) src + i * nbytes * THREADS + MYTHREAD,
+		  nbytes);
+    }
+
+#endif
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_OUT_MYSYNC & sync_mode || !(UPC_OUT_NOSYNC & sync_mode))
+
+    upc_barrier;
+}
Index: libgupc/collectives/upc_coll_gather.upc
===================================================================
--- libgupc/collectives/upc_coll_gather.upc	(.../trunk)	(revision 0)
+++ libgupc/collectives/upc_coll_gather.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,127 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*****************************************************************************/
+/*                                                                           */
+/*  Copyright (c) 2004, Michigan Technological University                    */
+/*  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 the Michigan Technological University              */
+/*  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 OWNER */
+/*  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.             */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <upc.h>
+#include <upc_collective.h>
+#include <upc_coll.h>
+
+/*****************************************************************************/
+/*                                                                           */
+/*        UPC collective function library, reference implementation          */
+/*                                                                           */
+/*   Steve Seidel, Dept. of Computer Science, Michigan Technological Univ.   */
+/*   steve@mtu.edu                                        March 1, 2004      */
+/*                                                                           */
+/*****************************************************************************/
+
+void
+upc_all_gather (shared void *dst,
+		shared const void *src, size_t nbytes, upc_flag_t sync_mode)
+{
+#ifndef PULL
+#ifndef PUSH
+#define PULL TRUE
+#endif
+#endif
+
+#ifdef PULL
+  int i;
+#endif
+  if (!upc_coll_init_flag)
+    upc_coll_init ();
+
+#ifdef _UPC_COLL_CHECK_ARGS
+  upc_coll_err (dst, src, NULL, nbytes, sync_mode, 0, 0, 0, UPC_GATH);
+#endif
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_IN_MYSYNC & sync_mode || !(UPC_IN_NOSYNC & sync_mode))
+
+    upc_barrier;
+
+#ifdef PULL
+
+  // The dst thread "pulls" a block of data from each src thread.
+
+  if ((int)upc_threadof ((shared void *) dst) == MYTHREAD)
+    {
+      for (i = 0; i < THREADS; ++i)
+	{
+	  upc_memcpy ((shared char *) dst + nbytes * i * THREADS,
+		      (shared char *) src + i, nbytes);
+	}
+    }
+#endif
+
+#ifdef PUSH
+
+  // Each src thread "pushes" the data to the dst thread.
+
+  upc_memcpy ((shared char *) dst + MYTHREAD * THREADS * nbytes,
+	      (shared char *) src + MYTHREAD, nbytes);
+
+#endif
+
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_OUT_MYSYNC & sync_mode || !(UPC_OUT_NOSYNC & sync_mode))
+
+    upc_barrier;
+}
Index: libgupc/collectives/upc_coll_gather_all.upc
===================================================================
--- libgupc/collectives/upc_coll_gather_all.upc	(.../trunk)	(revision 0)
+++ libgupc/collectives/upc_coll_gather_all.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,127 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*****************************************************************************/
+/*                                                                           */
+/*  Copyright (c) 2004, Michigan Technological University                    */
+/*  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 the Michigan Technological University              */
+/*  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 OWNER */
+/*  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.             */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <upc.h>
+#include <upc_collective.h>
+#include <upc_coll.h>
+
+/*****************************************************************************/
+/*                                                                           */
+/*        UPC collective function library, reference implementation          */
+/*                                                                           */
+/*   Steve Seidel, Dept. of Computer Science, Michigan Technological Univ.   */
+/*   steve@mtu.edu                                        March 1, 2004      */
+/*                                                                           */
+/*****************************************************************************/
+
+void
+upc_all_gather_all (shared void *dst,
+		    shared const void *src,
+		    size_t nbytes, upc_flag_t sync_mode)
+{
+#ifndef PULL
+#ifndef PUSH
+#define PULL TRUE
+#endif
+#endif
+
+  int i;
+
+  if (!upc_coll_init_flag)
+    upc_coll_init ();
+
+#ifdef _UPC_COLL_CHECK_ARGS
+  upc_coll_err (dst, src, NULL, nbytes, sync_mode, 0, 0, 0, UPC_GATH_ALL);
+#endif
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_IN_MYSYNC & sync_mode || !(UPC_IN_NOSYNC & sync_mode))
+
+    upc_barrier;
+#ifdef PULL
+
+  // Thread MYTHREAD copies the ith block from thread i to its ith block.
+
+  for (i = 0; i < THREADS; i++)
+    {
+      upc_memcpy ((shared char *) dst + i * nbytes * THREADS + MYTHREAD,
+		  (shared char *) src + i, nbytes);
+    }
+
+#endif
+
+#ifdef PUSH
+
+  // Thread MYTHREAD copies its block to all threads.
+
+  for (i = 0; i < THREADS; i++)
+    {
+      upc_memcpy ((shared char *) dst + MYTHREAD * nbytes * THREADS + i,
+		  (shared char *) src + MYTHREAD, nbytes);
+    }
+
+#endif
+  // Synchronize using barriers in the cases of MYSYNC and ALLSYNC.
+
+  if (UPC_OUT_MYSYNC & sync_mode || !(UPC_OUT_NOSYNC & sync_mode))
+
+    upc_barrier;
+
+}
Index: libgupc/collectives/upc_coll_init.upc
===================================================================
--- libgupc/collectives/upc_coll_init.upc	(.../trunk)	(revision 0)
+++ libgupc/collectives/upc_coll_init.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,94 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*****************************************************************************/
+/*                                                                           */
+/*  Copyright (c) 2004, Michigan Technological University                    */
+/*  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 the Michigan Technological University              */
+/*  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 OWNER */
+/*  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.             */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <upc.h>
+#include <upc_collective.h>
+#include <upc_coll.h>
+
+/*****************************************************************************/
+/*                                                                           */
+/*        UPC collective function library, reference implementation          */
+/*                                                                           */
+/*   Steve Seidel, Dept. of Computer Science, Michigan Technological Univ.   */
+/*   steve@mtu.edu                                        March 1, 2004      */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <stdio.h>
+
+int upc_coll_init_flag = 0;
+
+void
+upc_coll_init ()
+{
+  if (upc_coll_init_flag)
+    {
+      printf ("Internal error: Multiple attempts to initialize ");
+      printf ("\tthe collective library in the same thread.\n");
+      exit (1);
+    }
+
+  // Set the flag so that this thread never initializes again.
+
+  upc_coll_init_flag = 1;
+
+// Nothing to initialize yet.
+
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]