Index: gcc/c-parse.in
===================================================================
--- gcc/c-parse.in	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/c-parse.in	(.../trunk)	(revision 34)
@@ -2357,10 +2357,16 @@
 	save_location for_cond_expr ';' for_incr_expr
 	';' save_location upc_affinity_expr ')'
 	start_break start_continue c99_block_lineno_labeled_stmt
-		{ $15 = upc_affinity_test ($10, $15, $11);
+		{ tree t = upc_forall_gasp($5, 1);
+		  if (t != NULL_TREE)
+		    add_stmt(t);
+		  $15 = upc_affinity_test ($10, $15, $11);
 		  c_finish_loop ($5, $6, $8, $15, c_break_label,
 				 c_cont_label, true);
 		  add_stmt (c_end_compound_stmt ($2, flag_isoc99));
+		  t = upc_forall_gasp($5, 0);
+		  if (t != NULL_TREE)
+		    add_stmt(t);
 		  c_break_label = $13; c_cont_label = $14; }
 	;
 @@end_ifupc
Index: gcc/c.opt
===================================================================
--- gcc/c.opt	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/c.opt	(.../trunk)	(revision 34)
@@ -714,6 +714,14 @@
 UPC Joined RejectNegative UInteger
 Specify the number of POSIX threads per process that are mapped to UPC threads
 
+finstrument-gasp
+C UPC
+Compile with GASP instrumentation support
+
+finstrument-gasp-functions
+C UPC
+Compile with GASP function instrumentation (implies -finstrument-gasp)
+
 fuse-cxa-atexit
 C++ ObjC++
 Use __cxa_atexit to register destructors
Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/gimplify.c	(.../trunk)	(revision 34)
@@ -47,6 +47,41 @@
 #include "ggc.h"
 #include "target.h"
 
+#ifndef DISABLE_GASP
+extern int flag_gasp_instrument_functions;
+extern int get_upc_pupc_mode(void);
+extern tree lookup_name (tree);
+extern tree build_function_call (tree, tree);
+static tree add_gasp_fnargs(tree, const char *, const char *, int);
+
+/* Add source args to the tree of function arguments */
+static tree add_gasp_fnargs(tree lib_args, const char *func, const char *filename, int lineno)
+{
+  tree filename_string, func_string;
+  int filename_len, func_len;
+
+  /* translate const char * into an appropriate tree element */
+  filename_len = strlen(filename);
+  filename_string = build_string(filename_len + 1, filename);
+  TREE_TYPE (filename_string) = build_array_type
+    (char_type_node, build_index_type
+      (build_int_cst (NULL_TREE, filename_len)));
+  /* same for func */
+  func_len = strlen(func);
+  func_string = build_string(func_len + 1, func);
+  TREE_TYPE (func_string) = build_array_type
+    (char_type_node, build_index_type
+      (build_int_cst (NULL_TREE, func_len)));
+  /* append __FILE__ and __LINE__ to arglist */
+  lib_args = chainon(lib_args,
+               tree_cons (NULL_TREE, func_string,
+                 tree_cons (NULL_TREE, filename_string,
+                   tree_cons (NULL_TREE, build_int_cst(NULL_TREE, lineno),
+                     NULL_TREE))));
+  return lib_args;
+}
+#endif
+
 static struct gimplify_ctx
 {
   tree current_bind_expr;
@@ -4715,6 +4750,53 @@
       DECL_SAVED_TREE (fndecl) = bind;
     }
 
+#ifndef DISABLE_GASP
+  /* add GASP instrumentation function callbacks */
+  if (flag_gasp_instrument_functions && get_upc_pupc_mode()
+      && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl))
+    {
+      tree tf, x, pfunc, bind, libargs1, libargs2;
+
+      location_t xloc;
+      const char *file, *funcname;
+      int line;
+
+      xloc = expand_location (DECL_SOURCE_LOCATION (fndecl));
+      line = xloc.line;
+      file = xloc.file;
+      funcname = 0;
+      if (DECL_NAME(fndecl))
+        funcname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
+
+      pfunc = implicit_built_in_decls[BUILT_IN_PROFILE_GASP_FUNC];
+
+      /* use same try - finally trick above */
+      tf = build (TRY_FINALLY_EXPR, void_type_node, NULL, NULL);
+      TREE_SIDE_EFFECTS (tf) = 1;
+      x = DECL_SAVED_TREE (fndecl);
+      append_to_statement_list (x, &TREE_OPERAND (tf, 0));
+
+      libargs1 = tree_cons (NULL_TREE,
+                             build_int_cst(NULL_TREE, 0), NULL_TREE);
+      libargs1 = add_gasp_fnargs(libargs1, funcname, file, line);
+      x = build_function_call (pfunc, libargs1);
+      append_to_statement_list (x, &TREE_OPERAND (tf, 1));
+
+      bind = build (BIND_EXPR, void_type_node, NULL, NULL, NULL);
+      TREE_SIDE_EFFECTS (bind) = 1;
+
+      libargs2 = tree_cons (NULL_TREE,
+                             build_int_cst(NULL_TREE, 1), NULL_TREE);
+      libargs2 = add_gasp_fnargs(libargs2, funcname, file, line);
+      x = build_function_call (pfunc, libargs2);
+      append_to_statement_list (x, &BIND_EXPR_BODY (bind));
+
+      append_to_statement_list (tf, &BIND_EXPR_BODY (bind));
+
+      DECL_SAVED_TREE (fndecl) = bind;
+    }
+#endif
+
   current_function_decl = oldfn;
   cfun = oldfn ? DECL_STRUCT_FUNCTION (oldfn) : NULL;
 }
Index: gcc/c-pragma.c
===================================================================
--- gcc/c-pragma.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/c-pragma.c	(.../trunk)	(revision 34)
@@ -506,6 +506,46 @@
 static void init_pragma_upc PARAMS((void));
 static void handle_pragma_upc PARAMS ((cpp_reader *));
 
+#ifndef DISABLE_GASP
+static int pragma_pupc_on;
+static void init_pragma_pupc();
+static void handle_pragma_pupc(cpp_reader *);
+
+/* Pragma pupc defaults to being on */
+static void init_pragma_pupc() {
+  pragma_pupc_on = 1;
+}
+
+int get_upc_pupc_mode() {
+  return pragma_pupc_on;
+}
+
+/*
+ *  #pragma pupc on
+ *  #pragma pupc off
+ */
+static void handle_pragma_pupc (cpp_reader *dummy ATTRIBUTE_UNUSED)
+{
+  tree x;
+  enum cpp_ttype t;
+
+  t = c_lex(&x);
+  if (t == CPP_NAME) {
+    const char *op = IDENTIFIER_POINTER (x);
+    if (!strcmp (op, "on"))
+      pragma_pupc_on = 1;
+    else if (!strcmp (op, "off"))
+      pragma_pupc_on = 0;
+    else
+	    GCC_BAD2 ("unknown action '%s' for '#pragma pupc' - ignored", op);
+  }
+  
+  t = c_lex (&x);
+  if (t != CPP_EOF)
+    warning ("junk at end of #pragma pupc");
+}
+#endif
+
 /* Initialize the variables used to manage the current UPC consistency
    mode (strict/relaxed) */
 
@@ -866,6 +906,11 @@
   init_pragma_upc ();
 #endif
 
+#ifndef DISABLE_GASP
+  c_register_pragma (0, "pupc", handle_pragma_pupc);
+  init_pragma_pupc ();
+#endif
+
 #ifdef REGISTER_TARGET_PRAGMAS
   REGISTER_TARGET_PRAGMAS ();
 #endif
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/optabs.c	(.../trunk)	(revision 34)
@@ -5061,6 +5061,18 @@
   xgets_optab = init_optab (UNKNOWN);
   xputs_optab = init_optab (UNKNOWN);
 
+#ifndef DISABLE_GASP
+  /* UPC operations (profiled) */
+  getg_optab = init_optab (UNKNOWN);
+  putg_optab = init_optab (UNKNOWN);
+  getsg_optab = init_optab (UNKNOWN);
+  putsg_optab = init_optab (UNKNOWN);
+  xgetg_optab = init_optab (UNKNOWN);
+  xputg_optab = init_optab (UNKNOWN);
+  xgetsg_optab = init_optab (UNKNOWN);
+  xputsg_optab = init_optab (UNKNOWN);
+#endif
+
   vec_extract_optab = init_optab (UNKNOWN);
   vec_set_optab = init_optab (UNKNOWN);
   vec_init_optab = init_optab (UNKNOWN);
@@ -5175,6 +5187,37 @@
   init_libfuncs (xputs_optab, BLKmode, BLKmode, "puts", '3');
   init_floating_libfuncs (xputs_optab, "puts", '2');
 
+#ifndef DISABLE_GASP
+  /* UPC operations (profiled) */
+  init_all_integral_libfuncs (getg_optab, "getg", '4');
+  init_libfuncs (getg_optab, BLKmode, BLKmode, "getg", '5');
+  init_floating_libfuncs (getg_optab, "getg", '4');
+  init_all_integral_libfuncs (putg_optab, "putg", '4');
+  init_libfuncs (putg_optab, BLKmode, BLKmode, "putg", '5');
+  init_floating_libfuncs (putg_optab, "putg", '4');
+  init_all_integral_libfuncs (getsg_optab, "getsg", '4');
+  init_libfuncs (getsg_optab, BLKmode, BLKmode, "getsg", '5');
+  init_floating_libfuncs (getsg_optab, "getsg", '4');
+  init_all_integral_libfuncs (putsg_optab, "putsg", '4');
+  init_libfuncs (putsg_optab, BLKmode, BLKmode, "putsg", '5');
+  init_floating_libfuncs (putsg_optab, "putsg", '4');
+  /* 64 bit targeted functions: we don't change the library
+     call names, because multilibs will handle the overloading
+     if necessary. */
+  init_all_integral_libfuncs (xgetg_optab, "getg", '4');
+  init_libfuncs (xgetg_optab, BLKmode, BLKmode, "getg", '5');
+  init_floating_libfuncs (xgetg_optab, "getg", '4');
+  init_all_integral_libfuncs (xputg_optab, "putg", '4');
+  init_libfuncs (xputg_optab, BLKmode, BLKmode, "putg", '5');
+  init_floating_libfuncs (xputg_optab, "putg", '4');
+  init_all_integral_libfuncs (xgetsg_optab, "getsg", '4');
+  init_libfuncs (xgetsg_optab, BLKmode, BLKmode, "getsg", '5');
+  init_floating_libfuncs (xgetsg_optab, "getsg", '4');
+  init_all_integral_libfuncs (xputsg_optab, "putsg", '4');
+  init_libfuncs (xputsg_optab, BLKmode, BLKmode, "putsg", '5');
+  init_floating_libfuncs (xputsg_optab, "putsg", '4');
+#endif
+
   /* EQ etc are floating point only.  */
   init_floating_libfuncs (eq_optab, "eq", '2');
   init_floating_libfuncs (ne_optab, "ne", '2');
Index: gcc/optabs.h
===================================================================
--- gcc/optabs.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/optabs.h	(.../trunk)	(revision 34)
@@ -235,6 +235,18 @@
   OTI_upcxgets,
   OTI_upcxputs,
 
+#ifndef DISABLE_GASP
+  /* Profiled UPC-related optabs */
+  OTI_upcgetg,
+  OTI_upcputg,
+  OTI_upcgetsg,
+  OTI_upcputsg,
+  OTI_upcxgetg,
+  OTI_upcxputg,
+  OTI_upcxgetsg,
+  OTI_upcxputsg,
+#endif
+
   /* Conditional add instruction.  */
   OTI_addcc,
 
@@ -368,6 +380,18 @@
 #define xgets_optab (optab_table[OTI_upcxgets])
 #define xputs_optab (optab_table[OTI_upcxputs])
 
+#ifndef DISABLE_GASP
+/* UPC-related operation tables (profiled) */
+#define getg_optab (optab_table[OTI_upcgetg])
+#define putg_optab (optab_table[OTI_upcputg])
+#define getsg_optab (optab_table[OTI_upcgetsg])
+#define putsg_optab (optab_table[OTI_upcputsg])
+#define xgetg_optab (optab_table[OTI_upcxgetg])
+#define xputg_optab (optab_table[OTI_upcxputg])
+#define xgetsg_optab (optab_table[OTI_upcxgetsg])
+#define xputsg_optab (optab_table[OTI_upcxputsg])
+#endif
+
 /* Conversion optabs have their own table and indexes.  */
 enum convert_optab_index
 {
Index: gcc/upc/upc-act.h
===================================================================
--- gcc/upc/upc-act.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/upc/upc-act.h	(.../trunk)	(revision 34)
@@ -35,6 +35,7 @@
 /* used by yyparse */
 extern tree upc_build_sync_stmt (tree, tree);
 extern tree upc_affinity_test (location_t, tree, tree);
+extern tree upc_forall_gasp (location_t, int);
 extern struct c_expr upc_blocksizeof_expr (struct c_expr);
 extern struct c_expr upc_blocksizeof_type (struct c_type_name *);
 extern struct c_expr upc_elemsizeof_expr (struct c_expr);
Index: gcc/upc/upc-gimplify.c
===================================================================
--- gcc/upc/upc-gimplify.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/upc/upc-gimplify.c	(.../trunk)	(revision 34)
@@ -71,6 +71,29 @@
 static int upc_gimplify_shared_var_ref (tree *, tree *, tree *);
 static int upc_gimplify_sync_stmt (tree *, tree *, tree *);
 
+#ifndef DISABLE_GASP
+static tree add_gasp_srcargs(tree, const char *, int);
+
+/* Add source args to the tree of function arguments */
+static tree add_gasp_srcargs(tree lib_args, const char *filename, int lineno)
+{
+  tree filename_string;
+  int filename_len;
+  filename_len = strlen(filename);
+  /* translate const char * into an appropriate tree element */
+  filename_string = build_string(filename_len + 1, filename);
+  TREE_TYPE (filename_string) = build_array_type
+    (char_type_node, build_index_type
+      (build_int_cst (NULL_TREE, filename_len)));
+  /* append __FILE__ and __LINE__ to arglist */
+  lib_args = chainon(lib_args,
+               tree_cons (NULL_TREE, filename_string,
+                 tree_cons (NULL_TREE, build_int_cst(NULL_TREE, lineno),
+                       NULL_TREE)));
+  return lib_args;
+}
+#endif
+
 /* Generate call to runtime to implement a 'get' of a shared
  * object.  EXP is a pointer to shared value that references
  * the shared object. */
@@ -83,15 +106,33 @@
   tree result_type = TYPE_MAIN_VARIANT (type);
   int strict_mode = TYPE_STRICT (type)
 		    || (!TYPE_RELAXED (type) && get_upc_consistency_mode ());
-  optab get_op = (POINTER_SIZE == 64)
-                  ? (strict_mode ? xgets_optab : xget_optab)
-                  : (strict_mode ? gets_optab : get_optab);
   enum machine_mode mode = TYPE_MODE (type);
   enum machine_mode op_mode = (mode == TImode) ? BLKmode : mode;
-  rtx lib_op = get_op->handlers[(int) op_mode].libfunc;
   const char *libfunc_name;
   tree src = build1 (NOP_EXPR, upc_sptr_rep_type_node, exp);
   tree result, libfunc, lib_args, lib_call;
+  optab get_op;
+  rtx lib_op;
+#ifndef DISABLE_GASP
+  int doprofcall = get_upc_pupc_mode() && flag_gasp_instrument;
+  if (doprofcall)
+    {
+      get_op = (POINTER_SIZE == 64)
+                  ? (strict_mode ? xgetsg_optab : xgetg_optab)
+                  : (strict_mode ? getsg_optab : getg_optab);
+    }
+  else 
+    {
+      get_op = (POINTER_SIZE == 64)
+                  ? (strict_mode ? xgets_optab : xget_optab)
+                  : (strict_mode ? gets_optab : get_optab);
+    }
+#else
+  get_op = (POINTER_SIZE == 64)
+                  ? (strict_mode ? xgets_optab : xget_optab)
+                  : (strict_mode ? gets_optab : get_optab);
+#endif
+  lib_op = get_op->handlers[(int) op_mode].libfunc;
   if (!lib_op)
     abort ();
   libfunc_name = XSTR (lib_op, 0);
@@ -107,12 +148,24 @@
       lib_args = tree_cons (NULL_TREE, result_addr,
                    tree_cons (NULL_TREE, src,
                      tree_cons (NULL_TREE, size, NULL_TREE)));
+#ifndef DISABLE_GASP
+      if (doprofcall)
+        {
+          lib_args = add_gasp_srcargs(lib_args, input_filename, input_line);
+        }
+#endif
       lib_call = build_function_call (libfunc, lib_args);
       gimplify_and_add (lib_call, pre_p);
     }
   else
     {
       lib_args = tree_cons (NULL_TREE, src, NULL_TREE);
+#ifndef DISABLE_GASP
+      if (doprofcall)
+        {
+          lib_args = add_gasp_srcargs(lib_args, input_filename, input_line);
+        }
+#endif
       lib_call = build_function_call (libfunc, lib_args);
       if (!lang_hooks.types_compatible_p (result_type, TREE_TYPE (lib_call)))
         lib_call = build1 (NOP_EXPR, result_type, lib_call);
@@ -131,17 +184,40 @@
   tree type = TREE_TYPE (src);
   int strict_mode = TYPE_STRICT (type)
 		    || (!TYPE_RELAXED (type) && get_upc_consistency_mode ());
-  optab put_op = (POINTER_SIZE == 64)
-                  ? (strict_mode ? xputs_optab : xput_optab)
-                  : (strict_mode ? puts_optab : put_optab);
   enum machine_mode mode = TYPE_MODE (type);
   enum machine_mode op_mode = (mode == TImode) ? BLKmode : mode;
   int is_src_shared = (TREE_SHARED (src) || TYPE_SHARED (TREE_TYPE (src)));
   int is_shared_copy = (mode == BLKmode) && is_src_shared;
   const char *libfunc_name;
   tree libfunc, lib_args, lib_call;
+  optab put_op;
+#ifndef DISABLE_GASP
+  int doprofcall = get_upc_pupc_mode() && flag_gasp_instrument;
+  if (doprofcall)
+    {
+      put_op = (POINTER_SIZE == 64)
+                  ? (strict_mode ? xputsg_optab : xputg_optab)
+                  : (strict_mode ? putsg_optab : putg_optab);
+    }
+  else
+    {
+      put_op = (POINTER_SIZE == 64)
+                  ? (strict_mode ? xputs_optab : xput_optab)
+                  : (strict_mode ? puts_optab : put_optab);
+    }
+#else
+  put_op = (POINTER_SIZE == 64)
+                  ? (strict_mode ? xputs_optab : xput_optab)
+                  : (strict_mode ? puts_optab : put_optab);
+#endif
   if (is_shared_copy)
-    libfunc_name = strict_mode ? "__copysblk3" : "__copyblk3";
+    {
+      libfunc_name = strict_mode ? "__copysblk3" : "__copyblk3";
+#ifndef DISABLE_GASP
+      if (doprofcall) 
+        libfunc_name = strict_mode ? "__copygsblk5" : "__copygblk5";
+#endif
+    }
   else
     {
       rtx lib_op = put_op->handlers[(int) op_mode].libfunc;
@@ -180,6 +256,12 @@
 	              ? VIEW_CONVERT_EXPR : NOP_EXPR, src_type, src);
       lib_args = chainon (lib_args, tree_cons (NULL_TREE, src, NULL_TREE));
     }
+#ifndef DISABLE_GASP
+  if (doprofcall)
+    {
+      lib_args = add_gasp_srcargs(lib_args, input_filename, input_line);
+    }
+#endif
   lib_call = build_function_call (libfunc, lib_args);
   return lib_call;
 }
@@ -440,7 +522,10 @@
   tree sync_id = UPC_SYNC_ID (stmt);
   const int op = (int)tree_low_cst (sync_op, 1);
   const char *libfunc_name = (char *)0;
-  tree libfunc;
+#ifndef DISABLE_GASP
+  int doprofcall = get_upc_pupc_mode() && flag_gasp_instrument;
+#endif
+  tree libfunc, lib_args;
   switch (op)
     {
       case UPC_SYNC_NOTIFY_OP:
@@ -452,13 +537,32 @@
       default:
         abort();
     }
+#ifndef DISABLE_GASP
+  if (doprofcall)
+    {
+      switch (op)
+        {
+          case UPC_SYNC_NOTIFY_OP:  libfunc_name = UPC_NOTIFYG_LIBCALL;  break;
+          case UPC_SYNC_WAIT_OP:    libfunc_name = UPC_WAITG_LIBCALL;    break;
+          case UPC_SYNC_BARRIER_OP: libfunc_name = UPC_BARRIERG_LIBCALL; break;
+          default: abort();
+        }
+    }
+#endif
   libfunc = lookup_name (get_identifier (libfunc_name));
   if (!libfunc)
 	internal_error ("runtime function %s not found", libfunc_name);
   if (!sync_id)
     sync_id = build_int_cst (NULL_TREE, INT_MIN);
-  *stmt_p = build_function_call (libfunc,
-                            tree_cons (NULL_TREE, sync_id, NULL_TREE));
+
+  lib_args = tree_cons (NULL_TREE, sync_id, NULL_TREE);
+#ifndef DISABLE_GASP
+  if (doprofcall)
+    {
+      lib_args = add_gasp_srcargs(lib_args, input_filename, input_line);
+    }
+#endif
+  *stmt_p = build_function_call (libfunc, lib_args);
   return GS_UNHANDLED;
 }
 
Index: gcc/upc/upc-lang.c
===================================================================
--- gcc/upc/upc-lang.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/upc/upc-lang.c	(.../trunk)	(revision 34)
@@ -177,6 +177,11 @@
   flag_upc_pthreads = 0;
   upc_pthreads_model = upc_pthreads_no_model;
   flag_upc_pthreads_per_process = 0;
+#ifndef DISABLE_GASP
+  /* don't instrument for GASP unless someone requests it */
+  flag_gasp_instrument = 0;
+  flag_gasp_instrument_functions = 0;
+#endif
   return result;
 }
 
Index: gcc/upc/upc-act.c
===================================================================
--- gcc/upc/upc-act.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/upc/upc-act.c	(.../trunk)	(revision 34)
@@ -138,6 +138,16 @@
     case OPT_lang_upc:
       flag_upc = value;
       break;
+#ifndef DISABLE_GASP
+    case OPT_finstrument_gasp:
+      flag_gasp_instrument = value;
+      break;
+      
+    case OPT_finstrument_gasp_functions:
+      flag_gasp_instrument = value;
+      flag_gasp_instrument_functions = value;
+      break;
+#endif
     }
   return result;
 }
@@ -168,6 +178,13 @@
 {
   char def_buf[256];
   cpp_define (parse_in, "__GCC_UPC__=1");
+#ifndef DISABLE_GASP
+  cpp_define (parse_in, "__UPC_PUPC__=1");
+  if (flag_gasp_instrument)
+    {
+      cpp_define (parse_in, "__UPC_PUPC_INST__=1");
+    }
+#endif
   cpp_define (parse_in, "__UPC__=1");
   cpp_define (parse_in, "__UPC_VERSION__=200310L");
   (void) sprintf (def_buf, "UPC_MAX_BLOCK_SIZE=%s", UPC_MAX_BLOCK_SIZE_STRING);
@@ -899,6 +916,51 @@
 				       bitsize_unit_node));
 }
 
+/* 
+ * Handle UPC_FORALL GASP events.  Return a libupc function call if
+ * appropriate.
+ */
+tree
+upc_forall_gasp (location_t loc, int start)
+{
+#ifndef DISABLE_GASP
+  int docall = get_upc_pupc_mode() && flag_gasp_instrument;
+  if (docall)
+    {
+      int filename_len;
+      const char *filename, *funcname = "__upc_forallg";
+      tree lib_args, filename_string, func;
+
+      filename = loc.file;
+      filename_len = strlen(loc.file);
+
+      /* add start/end flag to arg list */
+      lib_args = tree_cons (NULL_TREE,
+                             build_int_cst(NULL_TREE, start), NULL_TREE);
+      
+      /* translate const char * into an appropriate tree element */
+      filename_string = build_string(filename_len + 1, filename);
+      TREE_TYPE (filename_string) = build_array_type
+        (char_type_node, build_index_type
+          (build_int_cst (NULL_TREE, filename_len)));
+
+      /* append __FILE__ and __LINE__ to arglist */
+      lib_args = chainon(lib_args,
+                   tree_cons (NULL_TREE, filename_string,
+                     tree_cons (NULL_TREE, build_int_cst(NULL_TREE, loc.line),
+                           NULL_TREE)));
+
+      /* assemble the call to libupc forall profiled function */
+      func = lookup_name(get_identifier(funcname));
+      if (!func)
+        internal_error ("runtime function %s not found", funcname);
+      
+      return build_function_call (func, lib_args);
+    }
+#endif
+  return NULL_TREE;
+}
+
 /* Implement UPC's upc_forall `affinity' test, by augmenting the for statement's
    for_body by rewriting it into:
      if (affinity == MYTHREAD) for_body; */
Index: gcc/genopinit.c
===================================================================
--- gcc/genopinit.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/genopinit.c	(.../trunk)	(revision 34)
@@ -172,6 +172,18 @@
   "xput_optab->handlers[$A].insn_code = CODE_FOR_$(xput$a2$)",
   "xputs_optab->handlers[$A].insn_code = CODE_FOR_$(xputs$a2$)",
 
+#ifndef DISABLE_GASP
+  /* Profiled UPC opcodes */
+  "getg_optab->handlers[$A].insn_code = CODE_FOR_$(getg$a4$)",
+  "getsg_optab->handlers[$A].insn_code = CODE_FOR_$(getsg$a4$)",
+  "putg_optab->handlers[$A].insn_code = CODE_FOR_$(putg$a4$)",
+  "putsg_optab->handlers[$A].insn_code = CODE_FOR_$(putsg$a4$)",
+  "xgetg_optab->handlers[$A].insn_code = CODE_FOR_$(xgetg$a4$)",
+  "xgetsg_optab->handlers[$A].insn_code = CODE_FOR_$(xgetsg$a4$)",
+  "xputg_optab->handlers[$A].insn_code = CODE_FOR_$(xputg$a4$)",
+  "xputsg_optab->handlers[$A].insn_code = CODE_FOR_$(xputsg$a4$)",
+#endif
+
   "reload_in_optab[$A] = CODE_FOR_$(reload_in$a$)",
   "reload_out_optab[$A] = CODE_FOR_$(reload_out$a$)",
   "movmem_optab[$A] = CODE_FOR_$(movmem$a$)",
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/tree.c	(.../trunk)	(revision 34)
@@ -5938,6 +5938,20 @@
   local_define_builtin ("__builtin_profile_func_exit", ftype,
 			BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0);
 
+#ifndef DISABLE_GASP
+  /* 
+   * arg list to __gasp_functiong:
+   *  int start, const char *func, const char *file, int line
+   */
+  tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
+  tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
+  tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
+  tmp = tree_cons (NULL_TREE, integer_type_node, tmp);
+  ftype = build_function_type (void_type_node, tmp);
+  local_define_builtin ("__builtin_gasp_functiong", ftype,
+      BUILT_IN_PROFILE_GASP_FUNC, "__gasp_functiong", 0);
+#endif
+
   /* Complex multiplication and division.  These are handled as builtins
      rather than optabs because emit_library_call_value doesn't support
      complex.  Further, we can do slightly better with folding these 
Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/c-opts.c	(.../trunk)	(revision 34)
@@ -845,6 +845,19 @@
       cpp_set_lang (parse_in, CLK_UPC);
       break;
 
+#ifndef DISABLE_GASP
+    case OPT_finstrument_gasp:
+    case OPT_finstrument_gasp_functions:
+      /* processed in UPC routine */
+      break;
+#else
+    /* no GASP support -> error */
+    case OPT_finstrument_gasp:
+    case OPT_finstrument_gasp_functions:
+      error("GASP support has been disabled in this compiler");
+      break;
+#endif
+
     case OPT_fupc_pthreads_model_tls:
     case OPT_fupc_pthreads_per_process_:
     case OPT_fupc_threads_:
Index: gcc/builtins.def
===================================================================
--- gcc/builtins.def	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/builtins.def	(.../trunk)	(revision 34)
@@ -641,3 +641,4 @@
 /* Profiling hooks.  */
 DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter")
 DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit")
+DEF_BUILTIN_STUB (BUILT_IN_PROFILE_GASP_FUNC, "__gasp_functiong")
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/c-common.c	(.../trunk)	(revision 34)
@@ -262,6 +262,14 @@
    time by the -fupc-pthreads-model-* switch. */
 upc_pthreads_model_kind upc_pthreads_model;
 
+#ifndef DISABLE_GASP
+/* Nonzero if -finstrument-gasp was given */
+int flag_gasp_instrument;
+
+/* Nonzero if -finstrument-gasp-functions was given */
+int flag_gasp_instrument_functions;
+#endif
+
 /* Nonzero if -undef was given.  It suppresses target built-in macros
    and assertions.  */
 int flag_undef;
Index: gcc/c-common.h
===================================================================
--- gcc/c-common.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/c-common.h	(.../trunk)	(revision 34)
@@ -412,6 +412,14 @@
    time by the -fupc-pthreads-model-* switch. */
 extern upc_pthreads_model_kind upc_pthreads_model;
 
+#ifndef DISABLE_GASP
+/* Nonzero if -finstrument-gasp was given */
+extern int flag_gasp_instrument;
+
+/* Nonzero if -finstrument-gasp-functions was given */
+extern int flag_gasp_instrument_functions;
+#endif
+
 /* Nonzero if -undef was given.  It suppresses target built-in macros
    and assertions.  */
 
Index: gcc/c-tree.h
===================================================================
--- gcc/c-tree.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/c-tree.h	(.../trunk)	(revision 34)
@@ -191,6 +191,11 @@
 extern void push_upc_consistency_mode PARAMS((void));
 extern void pop_upc_consistency_mode PARAMS((void));
 
+#ifndef DISABLE_GASP
+/* querying if pupc is on or off */
+extern int get_upc_pupc_mode(void);
+#endif
+
 /* A kind of type specifier.  Note that this information is currently
    only used to distinguish tag definitions, tag references and typeof
    uses.  */
Index: gcc/config/upc-conf.h
===================================================================
--- gcc/config/upc-conf.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ gcc/config/upc-conf.h	(.../trunk)	(revision 34)
@@ -111,3 +111,10 @@
 #define UPC_GETADDR_LIBCALL "__getaddr"
 #define UPC_NOTIFY_LIBCALL "__upc_notify"
 #define UPC_WAIT_LIBCALL "__upc_wait"
+
+/* Names of profiled versions of the UPC library functions */
+#ifndef DISABLE_GASP
+#define UPC_BARRIERG_LIBCALL "__upc_barrierg"
+#define UPC_NOTIFYG_LIBCALL "__upc_notifyg"
+#define UPC_WAITG_LIBCALL "__upc_waitg"
+#endif
Index: libupc/smp/gasp.h
===================================================================
--- libupc/smp/gasp.h	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/smp/gasp.h	(.../trunk)	(revision 34)
@@ -0,0 +1 @@
+link ../include/gasp.h
\ No newline at end of file

Property changes on: libupc/smp/gasp.h
___________________________________________________________________
Name: svn:special
   + *

Index: libupc/smp/upc_lock.c
===================================================================
--- libupc/smp/upc_lock.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_lock.c	(.../trunk)	(revision 34)
@@ -43,7 +43,6 @@
      }
 }
 
-
 upc_shared_ptr_t 
 upc_global_lock_alloc ()
 {
@@ -53,12 +52,36 @@
   return ptr;
 }
 
+upc_shared_ptr_t 
+upc_global_lock_allocg (const char *filename, int line)
+{
+  upc_shared_ptr_t res;
+  #define GASP_EN_ARGS
+  GASP_EN_S(GASP_UPC_GLOBAL_LOCK_ALLOC);
+  #undef GASP_EN_ARGS
+  res = upc_global_lock_alloc();
+  #define GASP_EN_ARGS , &res
+  GASP_EN_E(GASP_UPC_GLOBAL_LOCK_ALLOC);
+  #undef GASP_EN_ARGS
+  return res;
+}
+
 void
 upc_lock_free(upc_shared_ptr_t ptr)
 {
   upc_free (ptr);
 }
 
+void
+upc_lock_freeg(upc_shared_ptr_t ptr, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &ptr
+  GASP_EN_S(GASP_UPC_LOCK_FREE);
+  upc_lock_free(ptr);
+  GASP_EN_E(GASP_UPC_LOCK_FREE);
+  #undef GASP_EN_ARGS
+}
+
 upc_shared_ptr_t 
 upc_all_lock_alloc ()
 {
@@ -74,6 +97,20 @@
   return u->all_lock;
 }
 
+upc_shared_ptr_t 
+upc_all_lock_allocg (const char *filename, int line)
+{
+  upc_shared_ptr_t res;
+  #define GASP_EN_ARGS
+  GASP_EN_S(GASP_UPC_ALL_LOCK_ALLOC);
+  #undef GASP_EN_ARGS
+  res = upc_all_lock_alloc();
+  #define GASP_EN_ARGS , &res
+  GASP_EN_E(GASP_UPC_ALL_LOCK_ALLOC);
+  #undef GASP_EN_ARGS
+  return res;
+}
+
 void
 upc_lock (upc_shared_ptr_t ptr)
 {
@@ -81,6 +118,16 @@
   __upc_acquire_lock (&lock->os_lock);
 }
 
+void
+upc_lockg (upc_shared_ptr_t ptr, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &ptr
+  GASP_EN_S(GASP_UPC_LOCK);
+  upc_lock(ptr);
+  GASP_EN_E(GASP_UPC_LOCK);
+  #undef GASP_EN_ARGS
+}
+
 int
 upc_lock_attempt (upc_shared_ptr_t ptr)
 {
@@ -90,6 +137,20 @@
   return status;
 }
 
+int
+upc_lock_attemptg (upc_shared_ptr_t ptr, const char *filename, int line)
+{
+  int status;
+  #define GASP_EN_ARGS , &ptr
+  GASP_EN_S(GASP_UPC_LOCK_ATTEMPT);
+  #undef GASP_EN_ARGS
+  status = upc_lock_attempt(ptr);
+  #define GASP_EN_ARGS , &ptr, status
+  GASP_EN_E(GASP_UPC_LOCK_ATTEMPT);
+  #undef GASP_EN_ARGS
+  return status;
+}
+
 void
 upc_unlock (upc_shared_ptr_t ptr)
 {
@@ -101,6 +162,16 @@
   __upc_release_lock (&lock->os_lock);
 }
 
+void
+upc_unlockg (upc_shared_ptr_t ptr, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &ptr
+  GASP_EN_S(GASP_UPC_UNLOCK);
+  upc_unlock(ptr);
+  GASP_EN_E(GASP_UPC_UNLOCK);
+  #undef GASP_EN_ARGS
+}
+
 /* __upc_acquire_alloc_lock() and __upc_release_alloc_lock()
    are used by the dynamic memory manager to serialize
    access to the heap data structures.  They are implemented
Index: libupc/smp/upc_alloc.upc
===================================================================
--- libupc/smp/upc_alloc.upc	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_alloc.upc	(.../trunk)	(revision 34)
@@ -35,6 +35,20 @@
 #include "upc_config.h"
 #include "upc_sup.h"
 
+#ifndef DISABLE_GASP
+/* Pull in necessary external GASP defs */
+#include <stdarg.h>
+#include "gasp.h"
+#include "gasp_upc.h"
+/* GASP context pointer, has to be thread-local */
+extern THREAD_LOCAL gasp_context_t __gasp_ctx;
+/* init flag to filter UPC events that occur before gasp_init */
+extern THREAD_LOCAL int __gasp_init;
+#endif
+/* still have to include this if gasp not enabled, to compile out
+   GASP_EN_S stuff */
+#include "gasp_utils.h" 
+
 /* upc_alloc.upc implements UPC's dynamic memory allocation
    routines.  The implementation is written in UPC, because
    it needs to run above the runtime library's memory mapping
@@ -337,6 +351,20 @@
 }
 
 shared void *
+upc_global_allocg (size_t nblocks, size_t nbytes, const char *filename, int line)
+{
+  shared void *res;
+  #define GASP_EN_ARGS , nblocks, nbytes
+  GASP_EN_S(GASP_UPC_GLOBAL_ALLOC);
+  #undef GASP_EN_ARGS
+  res = upc_global_alloc(nblocks, nbytes);
+  #define GASP_EN_ARGS , nblocks, nbytes, &res
+  GASP_EN_E(GASP_UPC_GLOBAL_ALLOC);
+  #undef GASP_EN_ARGS
+  return res;
+}
+
+shared void *
 upc_all_alloc (size_t nblocks, size_t nbytes)
 {
   size_t request_size = round_up(nblocks, THREADS) * nbytes;
@@ -353,6 +381,20 @@
   return mem;
 }
 
+shared void *
+upc_all_allocg (size_t nblocks, size_t nbytes, const char *filename, int line)
+{
+  shared void *res;
+  #define GASP_EN_ARGS , nblocks, nbytes
+  GASP_EN_S(GASP_UPC_ALL_ALLOC);
+  #undef GASP_EN_ARGS
+  res = upc_all_alloc(nblocks, nbytes);
+  #define GASP_EN_ARGS , nblocks, nbytes, &res
+  GASP_EN_E(GASP_UPC_ALL_ALLOC);
+  #undef GASP_EN_ARGS
+  return res;
+}
+
 /* upc_local_alloc is deprecated, but supported in this implementation. */
 
 shared void *
@@ -374,6 +416,20 @@
   return mem;
 }
 
+shared void *
+upc_allocg (size_t nbytes, const char *filename, int line)
+{
+  shared void *val;
+  #define GASP_EN_ARGS , nbytes
+  GASP_EN_S(GASP_UPC_ALLOC);
+  #undef GASP_EN_ARGS
+  val = upc_alloc(nbytes);
+  #define GASP_EN_ARGS , nbytes, &val
+  GASP_EN_E(GASP_UPC_ALLOC);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 void
 upc_free (shared void *ptr)
 {
@@ -401,3 +457,13 @@
       __upc_release_alloc_lock ();
     }
 }
+
+void
+upc_freeg (shared void *ptr, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &ptr
+  GASP_EN_S(GASP_UPC_FREE);
+  upc_free(ptr);
+  GASP_EN_E(GASP_UPC_FREE);
+  #undef GASP_EN_ARGS
+}
Index: libupc/smp/gasp_upc.h
===================================================================
--- libupc/smp/gasp_upc.h	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/smp/gasp_upc.h	(.../trunk)	(revision 34)
@@ -0,0 +1 @@
+link ../include/gasp_upc.h
\ No newline at end of file

Property changes on: libupc/smp/gasp_upc.h
___________________________________________________________________
Name: svn:special
   + *

Index: libupc/smp/pupc.c
===================================================================
--- libupc/smp/pupc.c	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/smp/pupc.c	(.../trunk)	(revision 34)
@@ -0,0 +1,128 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the UPC runtime Library.
+
+   This library 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 2, or (at
+   your option) any later version.
+
+   This library 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.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+/* Translate PUPC calls to GASP calls as appropriate */
+#include "upc_config.h"
+#include "upc_sysdep.h"
+#include "upc_defs.h"
+
+#ifndef DISABLE_GASP
+
+int pupc_control(int on) {
+  return gasp_control(__gasp_ctx, on);
+}
+
+unsigned int pupc_create_event(const char *name, const char *desc) {
+  return gasp_create_event(__gasp_ctx, name, desc);
+}
+
+void pupc_event_start(unsigned int evttag, ...) {
+  va_list argptr;
+  va_start(argptr, evttag);
+    gasp_event_notifyVA(__gasp_ctx, evttag, GASP_START,
+      NULL, 0, 0, argptr);
+  va_end(argptr);
+}
+
+void pupc_event_end(unsigned int evttag, ...) {
+  va_list argptr;
+  va_start(argptr, evttag);
+    gasp_event_notifyVA(__gasp_ctx, evttag, GASP_END,
+      NULL, 0, 0, argptr);
+  va_end(argptr);
+}
+
+void pupc_event_atomic(unsigned int evttag, ...) {
+  va_list argptr;
+  va_start(argptr, evttag);
+    gasp_event_notifyVA(__gasp_ctx, evttag, GASP_ATOMIC,
+      NULL, 0, 0, argptr);
+  va_end(argptr);
+}
+
+void pupc_eventsrc_start(const char *file, int line, unsigned int evttag, ...) {
+  va_list argptr;
+  va_start(argptr, evttag);
+    gasp_event_notifyVA(__gasp_ctx, evttag, GASP_START,
+      file, line, 0, argptr);
+  va_end(argptr);
+}
+
+void pupc_eventsrc_end(const char *file, int line, unsigned int evttag, ...) {
+  va_list argptr;
+  va_start(argptr, evttag);
+    gasp_event_notifyVA(__gasp_ctx, evttag, GASP_END,
+      file, line, 0, argptr);
+  va_end(argptr);
+}
+
+void pupc_eventsrc_atomic(const char *file, int line, unsigned int evttag, ...) {
+  va_list argptr;
+  va_start(argptr, evttag);
+    gasp_event_notifyVA(__gasp_ctx, evttag, GASP_ATOMIC,
+      file, line, 0, argptr);
+  va_end(argptr);
+}
+
+/*
+ * Since libupc contains references to these functions, we provide dummy
+ * implementations to prevent linker warnings when GASP support has been
+ * compiled into GCC UPC, but the user compiles their app regularly.  We
+ * define these as weak symbols so tools can override them
+ * appropriately.
+ */
+
+#pragma weak gasp_init
+#pragma weak gasp_event_notify
+#pragma weak gasp_event_notifyVA
+#pragma weak gasp_control
+#pragma weak gasp_create_event
+
+gasp_context_t gasp_init(gasp_model_t srcmodel, int *argc, char ***argv)
+{
+  return 0;
+}
+
+void gasp_event_notify(gasp_context_t context, unsigned int evttag, gasp_evttype_t evttype,
+                       const char *filename, int linenum, int colnum, ...)
+{
+}
+
+void gasp_event_notifyVA(gasp_context_t context, unsigned int evttag, gasp_evttype_t evttype,
+                       const char *filename, int linenum, int colnum, va_list varargs)
+{
+}
+
+int gasp_control(gasp_context_t context, int on)
+{
+  return 0;
+}
+
+unsigned int gasp_create_event(gasp_context_t context, const char *name, const char *desc)
+{
+  return 0;
+}
+
+#endif
Index: libupc/smp/upc_access.c
===================================================================
--- libupc/smp/upc_access.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_access.c	(.../trunk)	(revision 34)
@@ -45,6 +45,13 @@
   return lib_sptr_to_addr (p);
 }
 
+/*
+ * GASP note: for each of the get functions, since we don't have access to the
+ * destination we pass in libupc-local pointers.  This is still useful since
+ * GASP tools can avoid an upcall to get the contents.  Also, in the general
+ * case, the pointers passed in might actually be compiler temporaries anyways.
+ */
+
 u_intQI_t
 __getqi2 (upc_shared_ptr_t p)
 {
@@ -52,6 +59,18 @@
   return *addr;
 }
 
+u_intQI_t
+__getgqi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intQI_t val;
+  #define GASP_EN_ARGS , 1, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getqi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 u_intHI_t
 __gethi2 (upc_shared_ptr_t p)
 {
@@ -59,6 +78,18 @@
   return *addr;
 }
 
+u_intHI_t
+__getghi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intHI_t val;
+  #define GASP_EN_ARGS , 1, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __gethi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 u_intSI_t
 __getsi2 (upc_shared_ptr_t p)
 {
@@ -66,6 +97,18 @@
   return *addr;
 }
 
+u_intSI_t
+__getgsi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intSI_t val;
+  #define GASP_EN_ARGS , 1, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getsi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 u_intDI_t
 __getdi2 (upc_shared_ptr_t p)
 {
@@ -73,6 +116,18 @@
   return *addr;
 }
 
+u_intDI_t
+__getgdi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intDI_t val;
+  #define GASP_EN_ARGS , 1, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getdi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 #if SHARED_PTR_SIZE == 128
 u_intTI_t
 __getti2 (upc_shared_ptr_t p)
@@ -80,6 +135,18 @@
   const u_intTI_t *addr = (u_intTI_t *) lib_access_sptr_to_addr (p);
   return *addr;
 }
+
+u_intTI_t
+__getgti4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intTI_t val;
+  #define GASP_EN_ARGS , 1, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getti2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
 #endif /* SHARED_PTR_SIZE == 128 */
 
 float
@@ -89,6 +156,18 @@
   return *addr;
 }
 
+float
+__getgsf4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  float val;
+  #define GASP_EN_ARGS , 1, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getsf2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 double
 __getdf2 (upc_shared_ptr_t p)
 {
@@ -96,6 +175,18 @@
   return *addr;
 }
 
+double
+__getgdf4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  double val;
+  #define GASP_EN_ARGS , 1, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getdf2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 void
 __getblk3 (void *dest, upc_shared_ptr_t src, size_t n)
 {
@@ -103,6 +194,16 @@
 }
 
 void
+__getgblk5 (void *dest, upc_shared_ptr_t src, size_t n, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, dest, &src, n
+  GASP_EN_S(GASP_UPC_GET);
+  __getblk3(dest, src, n);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putqi2 (upc_shared_ptr_t p, u_intQI_t v)
 {
   u_intQI_t * const addr = (u_intQI_t *) lib_access_sptr_to_addr (p);
@@ -110,6 +211,16 @@
 }
 
 void
+__putgqi4 (upc_shared_ptr_t p, u_intQI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putqi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __puthi2 (upc_shared_ptr_t p, u_intHI_t v)
 {
   u_intHI_t * const addr = (u_intHI_t *) lib_access_sptr_to_addr (p);
@@ -117,6 +228,16 @@
 }
 
 void
+__putghi4 (upc_shared_ptr_t p, u_intHI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __puthi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putsi2 (upc_shared_ptr_t p, u_intSI_t v)
 {
   u_intSI_t * const addr = (u_intSI_t *) lib_access_sptr_to_addr (p);
@@ -124,12 +245,32 @@
 }
 
 void
+__putgsi4 (upc_shared_ptr_t p, u_intSI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putsi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putdi2 (upc_shared_ptr_t p, u_intDI_t v)
 {
   u_intDI_t * const addr = (u_intDI_t *) lib_access_sptr_to_addr (p);
   *addr = v;
 }
 
+void
+__putgdi4 (upc_shared_ptr_t p, u_intDI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putdi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
 #if SHARED_PTR_SIZE == 128
 void
 __putti2 (upc_shared_ptr_t p, u_intTI_t v)
@@ -137,6 +278,16 @@
   u_intTI_t * const addr = (u_intTI_t *) lib_access_sptr_to_addr (p);
   *addr = v;
 }
+
+void
+__putgti4 (upc_shared_ptr_t p, u_intTI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putti2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
 #endif /* SHARED_PTR_SIZE == 128 */
 
 void
@@ -147,6 +298,16 @@
 }
 
 void
+__putgsf4 (upc_shared_ptr_t p, float v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putsf2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putdf2 (upc_shared_ptr_t p, double v)
 {
   double * const addr = (double *) lib_access_sptr_to_addr (p);
@@ -154,17 +315,51 @@
 }
 
 void
+__putgdf4 (upc_shared_ptr_t p, double v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putdf2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putblk3 (upc_shared_ptr_t dest, void *src, size_t n)
 {
   lib_upc_memput (dest, src, n);
 }
 
 void
+__putgblk5 (upc_shared_ptr_t dest, void *src, size_t n, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 1, &dest, src, n
+  GASP_EN_S(GASP_UPC_PUT);
+  __putblk3(dest, src, n);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __copyblk3 (upc_shared_ptr_t dest, upc_shared_ptr_t src, size_t n)
 {
   lib_upc_memcpy (dest, src, n);
 }
 
+/*
+ * shared -> shared inline copy == memcpy
+ * Note that this loses if it was a strict/relaxed access.
+ */
+void
+__copygblk5 (upc_shared_ptr_t dest, upc_shared_ptr_t src, size_t n, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &dest, &src, n
+  GASP_EN_S(GASP_UPC_MEMCPY);
+  __copyblk3(dest, src, n);
+  GASP_EN_E(GASP_UPC_MEMCPY);
+  #undef GASP_EN_ARGS
+}
+
 /* Strict memory accesses. */
 
 u_intQI_t
@@ -178,6 +373,18 @@
   return result;
 }
 
+u_intQI_t
+__getsgqi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intQI_t val;
+  #define GASP_EN_ARGS , 0, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getsqi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 u_intHI_t
 __getshi2 (upc_shared_ptr_t p)
 {
@@ -189,6 +396,18 @@
   return result;
 }
 
+u_intHI_t
+__getsghi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intHI_t val;
+  #define GASP_EN_ARGS , 0, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getshi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 u_intSI_t
 __getssi2 (upc_shared_ptr_t p)
 {
@@ -200,6 +419,18 @@
   return result;
 }
 
+u_intSI_t
+__getsgsi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intSI_t val;
+  #define GASP_EN_ARGS , 0, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getssi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 u_intDI_t
 __getsdi2 (upc_shared_ptr_t p)
 {
@@ -211,6 +442,18 @@
   return result;
 }
 
+u_intDI_t
+__getsgdi4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intDI_t val;
+  #define GASP_EN_ARGS , 0, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getsdi2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 #if SHARED_PTR_SIZE == 128
 u_intTI_t
 __getsti2 (upc_shared_ptr_t p)
@@ -222,6 +465,18 @@
   read_fence ();
   return result;
 }
+
+u_intTI_t
+__getsgti4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  u_intTI_t val;
+  #define GASP_EN_ARGS , 0, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getsti2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
 #endif /* SHARED_PTR_SIZE == 128 */
 
 float
@@ -235,6 +490,18 @@
   return result;
 }
 
+float
+__getsgsf4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  float val;
+  #define GASP_EN_ARGS , 0, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getsf2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 double
 __getsdf2 (upc_shared_ptr_t p)
 {
@@ -246,6 +513,18 @@
   return result;
 }
 
+double
+__getsgdf4 (upc_shared_ptr_t p, const char *filename, int line)
+{
+  double val;
+  #define GASP_EN_ARGS , 0, &val, &p, sizeof(val)
+  GASP_EN_S(GASP_UPC_GET);
+  val = __getsdf2(p);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+  return val;
+}
+
 void
 __getsblk3 (void *dest, upc_shared_ptr_t src, size_t len)
 {
@@ -255,6 +534,16 @@
 }
 
 void
+__getsgblk5 (void *dest, upc_shared_ptr_t src, size_t len, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, dest, &src, len
+  GASP_EN_S(GASP_UPC_GET);
+  __getsblk3(dest, src, len);
+  GASP_EN_E(GASP_UPC_GET);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putsqi2 (upc_shared_ptr_t p, u_intQI_t v)
 {
   u_intQI_t *addr = (u_intQI_t *) lib_access_sptr_to_addr (p);
@@ -264,6 +553,16 @@
 }
 
 void
+__putsgqi4 (upc_shared_ptr_t p, u_intQI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putsqi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putshi2 (upc_shared_ptr_t p, u_intHI_t v)
 {
   u_intHI_t *addr = (u_intHI_t *) lib_access_sptr_to_addr (p);
@@ -273,6 +572,16 @@
 }
 
 void
+__putsghi4 (upc_shared_ptr_t p, u_intHI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putshi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putssi2 (upc_shared_ptr_t p, u_intSI_t v)
 {
   u_intSI_t *addr = (u_intSI_t *) lib_access_sptr_to_addr (p);
@@ -282,6 +591,16 @@
 }
 
 void
+__putsgsi4 (upc_shared_ptr_t p, u_intSI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putssi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putsdi2 (upc_shared_ptr_t p, u_intDI_t v)
 {
   u_intDI_t *addr = (u_intDI_t *) lib_access_sptr_to_addr (p);
@@ -290,6 +609,16 @@
   memory_fence ();
 }
 
+void
+__putsgdi4 (upc_shared_ptr_t p, u_intDI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putsdi2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
 #if SHARED_PTR_SIZE == 128
 void
 __putsti2 (upc_shared_ptr_t p, u_intTI_t v)
@@ -299,6 +628,17 @@
   *addr = v;
   memory_fence ();
 }
+
+void
+__putsgti4 (upc_shared_ptr_t p, u_intTI_t v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putsti2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
 #endif /* SHARED_PTR_SIZE == 128 */
 
 void
@@ -311,6 +651,16 @@
 }
 
 void
+__putsgsf4 (upc_shared_ptr_t p, float v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putssf2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putsdf2 (upc_shared_ptr_t p, double v)
 {
   double *addr = (double *) lib_access_sptr_to_addr (p);
@@ -320,6 +670,16 @@
 }
 
 void
+__putsgdf4 (upc_shared_ptr_t p, double v, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &p, &v, sizeof(v)
+  GASP_EN_S(GASP_UPC_PUT);
+  __putsdf2(p, v);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __putsblk3 (upc_shared_ptr_t dest, void *src, size_t len)
 {
   write_fence ();
@@ -328,9 +688,34 @@
 }
 
 void
+__putsgblk5 (upc_shared_ptr_t dest, void *src, size_t len, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , 0, &dest, src, len
+  GASP_EN_S(GASP_UPC_PUT);
+  __putsblk3(dest, src, len);
+  GASP_EN_E(GASP_UPC_PUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __copysblk3 (upc_shared_ptr_t dest, upc_shared_ptr_t src, size_t len)
 {
   write_fence ();
   __copyblk3 (dest, src, len);
   memory_fence ();
 }
+
+/*
+ * shared -> shared inline copy == memcpy
+ * Note that this loses if it was a strict/relaxed access.
+ */
+void
+__copygsblk5 (upc_shared_ptr_t dest, upc_shared_ptr_t src, size_t len, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &dest, &src, len
+  GASP_EN_S(GASP_UPC_MEMCPY);
+  __copysblk3(dest, src, len);
+  GASP_EN_E(GASP_UPC_MEMCPY);
+  #undef GASP_EN_ARGS
+}
+
Index: libupc/smp/Make-defs
===================================================================
--- libupc/smp/Make-defs	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/Make-defs	(.../trunk)	(revision 34)
@@ -4,7 +4,7 @@
 OBJS = upc_access.lo upc_addr.lo upc_alloc.lo \
        upc_barrier.lo upc_lock.lo \
        upc_main.lo upc_mem.lo upc_pgm_info.lo \
-       upc_sysdep.lo upc_vm.lo
+       upc_sysdep.lo upc_vm.lo pupc.lo
 
 # Runtime library compiled for pthreads model
 
@@ -13,7 +13,7 @@
 PT_OBJS = $(PT)_upc_access.lo $(PT)_upc_addr.lo $(PT)_upc_alloc.lo \
        $(PT)_upc_barrier.lo $(PT)_upc_lock.lo \
        $(PT)_upc_main.lo $(PT)_upc_mem.lo $(PT)_upc_pgm_info.lo \
-       $(PT)_upc_sysdep.lo $(PT)_upc_vm.lo
+       $(PT)_upc_sysdep.lo $(PT)_upc_vm.lo $(PT)_pupc.lo
 
 ### runtime source directories
 
Index: libupc/smp/pupc.h
===================================================================
--- libupc/smp/pupc.h	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/smp/pupc.h	(.../trunk)	(revision 34)
@@ -0,0 +1 @@
+link ../include/pupc.h
\ No newline at end of file

Property changes on: libupc/smp/pupc.h
___________________________________________________________________
Name: svn:special
   + *

Index: libupc/smp/upc_access.h
===================================================================
--- libupc/smp/upc_access.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_access.h	(.../trunk)	(revision 34)
@@ -86,4 +86,56 @@
 extern void __putsblk3 (upc_shared_ptr_t, void *, size_t);
 extern void __copysblk3 (upc_shared_ptr_t, upc_shared_ptr_t, size_t);
 
+/* relaxed accesses, profiled */
+
+extern u_intQI_t __getgqi4 (upc_shared_ptr_t, const char *, int);
+extern u_intHI_t __getghi4 (upc_shared_ptr_t, const char *, int);
+extern u_intSI_t __getgsi4 (upc_shared_ptr_t, const char *, int);
+extern u_intDI_t __getgdi4 (upc_shared_ptr_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern u_intTI_t __getgti4 (upc_shared_ptr_t, const char *, int);
+#endif
+extern float __getgsf4 (upc_shared_ptr_t, const char *, int);
+extern double __getgdf4 (upc_shared_ptr_t, const char *, int);
+extern void __getgblk5 (void *, upc_shared_ptr_t, size_t, const char *, int);
+
+extern void __putgqi4 (upc_shared_ptr_t, u_intQI_t, const char *, int);
+extern void __putghi4 (upc_shared_ptr_t, u_intHI_t, const char *, int);
+extern void __putgsi4 (upc_shared_ptr_t, u_intSI_t, const char *, int);
+extern void __putgdi4 (upc_shared_ptr_t, u_intDI_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern void __putgti4 (upc_shared_ptr_t, u_intTI_t, const char *, int);
+#endif
+extern void __putgsf4 (upc_shared_ptr_t, float, const char *, int);
+extern void __putgdf4 (upc_shared_ptr_t, double, const char *, int);
+extern void __putgblk5 (upc_shared_ptr_t, void *, size_t, const char *, int);
+
+extern void __copygblk5 (upc_shared_ptr_t, upc_shared_ptr_t, size_t, const char *, int);
+
+/* strict accesses, profiled */
+
+extern u_intQI_t __getsgqi4 (upc_shared_ptr_t, const char *, int);
+extern u_intHI_t __getsghi4 (upc_shared_ptr_t, const char *, int);
+extern u_intSI_t __getsgsi4 (upc_shared_ptr_t, const char *, int);
+extern u_intDI_t __getsgdi4 (upc_shared_ptr_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern u_intTI_t __getsgti4 (upc_shared_ptr_t, const char *, int);
+#endif
+extern float __getsgsf4 (upc_shared_ptr_t, const char *, int);
+extern double __getsgdf4 (upc_shared_ptr_t, const char *, int);
+extern void __getsgblk5 (void *, upc_shared_ptr_t, size_t, const char *, int);
+
+extern void __putsgqi4 (upc_shared_ptr_t, u_intQI_t, const char *, int);
+extern void __putsghi4 (upc_shared_ptr_t, u_intHI_t, const char *, int);
+extern void __putsgsi4 (upc_shared_ptr_t, u_intSI_t, const char *, int);
+extern void __putsgdi4 (upc_shared_ptr_t, u_intDI_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern void __putsgti4 (upc_shared_ptr_t, u_intTI_t, const char *, int);
+#endif
+extern void __putsgsf4 (upc_shared_ptr_t, float, const char *, int);
+extern void __putsgdf4 (upc_shared_ptr_t, double, const char *, int);
+extern void __putsgblk5 (upc_shared_ptr_t, void *, size_t, const char *, int);
+
+extern void __copygsblk5 (upc_shared_ptr_t, upc_shared_ptr_t, size_t, const char *, int);
+
 #endif /* _UPC_ACCESS_H_ */
Index: libupc/smp/gasp_utils.h
===================================================================
--- libupc/smp/gasp_utils.h	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/smp/gasp_utils.h	(.../trunk)	(revision 34)
@@ -0,0 +1,55 @@
+/*
+ * GASP utility macros.
+ *
+ * Adam Leko
+ */
+
+#ifndef DISABLE_GASP
+
+  /* Compile in GASP macros */
+
+  #define GASP_INIT(ctx, ptr_argc, ptr_argv) do { \
+    ctx = gasp_init(GASP_MODEL_UPC, ptr_argc, ptr_argv); \
+    __gasp_init = 1; \
+  } while (0);
+
+  #define GASP_EN_S(tag) \
+    if (__gasp_init) { \
+      gasp_event_notify(__gasp_ctx, tag, GASP_START, filename, line, 0 GASP_EN_ARGS); \
+    }
+
+  #define GASP_EN_S_NOSRC(tag) \
+    if (__gasp_init) { \
+      gasp_event_notify(__gasp_ctx, tag, GASP_START, 0, 0, 0 GASP_EN_ARGS); \
+    }
+
+  #define GASP_EN_E(tag) \
+    if (__gasp_init) { \
+      gasp_event_notify(__gasp_ctx, tag, GASP_END, filename, line, 0 GASP_EN_ARGS); \
+    }
+
+  #define GASP_EN_E_NOSRC(tag) \
+    if (__gasp_init) { \
+      gasp_event_notify(__gasp_ctx, tag, GASP_END, 0, 0, 0 GASP_EN_ARGS); \
+    }
+
+  #define GASP_EN_A(tag) \
+    if (__gasp_init) { \
+      gasp_event_notify(__gasp_ctx, tag, GASP_ATOMIC, filename, line, 0 GASP_EN_ARGS); \
+    }
+
+  #define GASP_EN_A_NOSRC(tag) \
+    if (__gasp_init) { \
+      gasp_event_notify(__gasp_ctx, tag, GASP_ATOMIC, filename, line, 0 GASP_EN_ARGS); \
+    }
+
+#else
+
+  /* Compile out GASP macros */
+
+  #define GASP_INIT(ctx, ptr_argc, ptr_argv)
+  #define GASP_EN_S(tag)
+  #define GASP_EN_E(tag)
+  #define GASP_EN_A(tag)
+
+#endif
Index: libupc/smp/upc_sup.h
===================================================================
--- libupc/smp/upc_sup.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_sup.h	(.../trunk)	(revision 34)
@@ -49,6 +49,14 @@
 extern void *__upc_vm_map_addr (upc_shared_ptr_t);
 extern void __upc_wait (int barrier_id);
 
+/* profiled exit call */
+extern void __upc_exitg (int status);
+
+/* profiled sync calls */
+extern void __upc_barrierg (int barrier_id, const char *file, int line);
+extern void __upc_notifyg (int barrier_id, const char *file, int line);
+extern void __upc_waitg (int barrier_id, const char *file, int line);
+
 /* To speed things up, the last two unique (page, thread)
    lookups are cached.  Caller must validate the pointer
    'p' (check for NULL, etc.) before calling this routine. */
Index: libupc/smp/Make-rules
===================================================================
--- libupc/smp/Make-rules	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/Make-rules	(.../trunk)	(revision 34)
@@ -29,6 +29,9 @@
 upc_vm.lo: $(target_srcdir)/upc_vm.c
 	$(L_CC) -o upc_vm.lo $(target_srcdir)/upc_vm.c
 
+pupc.lo: $(target_srcdir)/pupc.c
+	$(L_CC) -o pupc.lo $(target_srcdir)/pupc.c
+
 #
 # Build with pthreads implementation of UPC threads
 #
@@ -61,3 +64,6 @@
 
 $(PT)_upc_vm.lo: $(target_srcdir)/upc_vm.c
 	$(L_CC) $(PT_DEFS) -o $(PT)_upc_vm.lo $(target_srcdir)/upc_vm.c
+
+$(PT)_pupc.lo: $(target_srcdir)/pupc.c
+	$(L_CC) $(PT_DEFS) -o $(PT)_pupc.lo $(target_srcdir)/pupc.c
Index: libupc/smp/Make-deps
===================================================================
--- libupc/smp/Make-deps	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/Make-deps	(.../trunk)	(revision 34)
@@ -40,6 +40,11 @@
   $(target_srcdir)/upc_config.h $(target_srcdir)/upc_defs.h \
   $(target_srcdir)/upc_lib.h $(target_srcdir)/upc_sup.h \
   $(target_srcdir)/upc_sysdep.h $(target_srcdir)/upc_sync.h
+pupc.lo: $(target_srcdir)/pupc.c \
+  $(target_srcdir)/upc_config.h $(target_srcdir)/upc_defs.h \
+  $(target_srcdir)/gasp_utils.h $(target_srcdir)/gasp.h $(target_srcdir)/gasp_upc.h \
+  $(target_srcdir)/upc_lib.h $(target_srcdir)/upc_sup.h \
+  $(target_srcdir)/upc_sysdep.h $(target_srcdir)/upc_sync.h
 
 #
 # Runtime compiled with POSIX threads model
@@ -86,3 +91,8 @@
   $(target_srcdir)/upc_config.h $(target_srcdir)/upc_defs.h \
   $(target_srcdir)/upc_lib.h $(target_srcdir)/upc_sup.h \
   $(target_srcdir)/upc_sysdep.h $(target_srcdir)/upc_sync.h
+$(PT)_pupc.lo: $(target_srcdir)/pupc.c \
+  $(target_srcdir)/upc_config.h $(target_srcdir)/upc_defs.h \
+  $(target_srcdir)/gasp_utils.h $(target_srcdir)/gasp.h $(target_srcdir)/gasp_upc.h \
+  $(target_srcdir)/upc_lib.h $(target_srcdir)/upc_sup.h \
+  $(target_srcdir)/upc_sysdep.h $(target_srcdir)/upc_sync.h
Index: libupc/smp/upc_mem.c
===================================================================
--- libupc/smp/upc_mem.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_mem.c	(.../trunk)	(revision 34)
@@ -39,19 +39,60 @@
 }
 
 void
+upc_memcpyg (upc_shared_ptr_t dest, upc_shared_ptr_t src, size_t n, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &dest, &src, n
+  GASP_EN_S(GASP_UPC_MEMCPY);  
+  lib_upc_memcpy (dest, src, n);
+  GASP_EN_E(GASP_UPC_MEMCPY);
+  #undef GASP_EN_ARGS
+}
+
+void
 upc_memget (void *dest, upc_shared_ptr_t src, size_t n)
 {
   lib_upc_memget (dest, src, n);
 }
 
 void
+upc_memgetg (void *dest, upc_shared_ptr_t src, size_t n, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &dest, &src, n
+  GASP_EN_S(GASP_UPC_MEMGET);  
+  upc_memget (dest, src, n);
+  GASP_EN_E(GASP_UPC_MEMGET);
+  #undef GASP_EN_ARGS
+}
+
+void
 upc_memput (upc_shared_ptr_t dest, const void *src, size_t n)
 {
   lib_upc_memput (dest, src, n);
 }
 
 void
+upc_memputg (upc_shared_ptr_t dest, const void *src, size_t n, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &dest, src, n
+  GASP_EN_S(GASP_UPC_MEMPUT);
+  upc_memput (dest, src, n);
+  GASP_EN_E(GASP_UPC_MEMPUT);
+  #undef GASP_EN_ARGS
+}
+
+void
 upc_memset (upc_shared_ptr_t dest, int c, size_t n)
 {
   lib_upc_memset (dest, c, n);
 }
+
+void
+upc_memsetg (upc_shared_ptr_t dest, int c, size_t n, const char *filename, int line)
+{
+  #define GASP_EN_ARGS , &dest, c, n
+  GASP_EN_S(GASP_UPC_MEMSET);
+  upc_memset (dest, c, n);
+  GASP_EN_E(GASP_UPC_MEMSET);
+  #undef GASP_EN_ARGS
+}
+
Index: libupc/smp/upc_main.c
===================================================================
--- libupc/smp/upc_main.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_main.c	(.../trunk)	(revision 34)
@@ -48,6 +48,43 @@
 /* The current thread number (range: 0..THREADS-1) */
 THREAD_LOCAL int MYTHREAD;
 
+#ifndef DISABLE_GASP
+/* GASP context pointer, has to be thread-local */
+THREAD_LOCAL gasp_context_t __gasp_ctx;
+/* init flag to filter UPC events that occur before gasp_init */
+THREAD_LOCAL int __gasp_init;
+/* 
+ * Some notes about exit GASP events:
+ *
+ * The GASP interface requires us to fire off either a UPC_COLLECTIVE_EXIT to
+ * every thread before exiting, or UPC_NONCOLLECTIVE_EXIT event to a single
+ * thread (or more) when a noncollective exit occurs.
+ * 
+ * There are several ways a program can exit in GCC UPC:
+ *
+ *  - Calling upc_global_exit: this is a noncollective exit.  In pthreads mode,
+ *    this just calls exit() on the process and kills everything.  In process
+ *    mode, this returns a special bit set in the error code, which causes
+ *    monitor_threads() to kill all other threads with a SIGKILL.  In both
+ *    cases, we can only fire off a noncollective exit event on the thread that
+ *    called it.
+ *
+ *  - Calling exit: if the code was compiled with GASP turned on
+ *    (-finstrument-gasp), then this is rewritten to a __upc_exitg() call,
+ *    which calls __upc_exit.  This is a collective exit since __upc_exit does
+ *    a barrier, so we fire off collective exit events.
+ *
+ *  - Returning from main: Always a collective exit, since if one of the other
+ *    threads didn't return we'd have a noncollective exit somewhere, unless
+ *    the program itself has a livelock which we can't do anything about.
+ *
+ *  - Crashing: in both pthread and process mode, monitor_threads may or may
+ *    not pick up on the crash.  In any case, the process/pthread who has the
+ *    GASP context pointer is probably messed up beyond repair, so we're not
+ *    able to fire off a noncollective event to whichever thread broke.
+ */
+#endif
+
 /* Executable program's name */
 char *pgm_name;
 
@@ -377,6 +414,10 @@
 upc_per_thread_init (upc_info_p u)
 {
    __upc_vm_init_per_thread ();
+   /* clear GASP init flag */
+   #ifndef DISABLE_GASP
+     __gasp_init = 0;
+   #endif
    if (!MYTHREAD)
      {
         extern void upc_memput(upc_shared_ptr_t, const void *, size_t);
@@ -431,7 +472,14 @@
 		__upc_yield_cpu ();
 	    }
 	  __upc_barrier (UPC_RUNTIME_BARRIER_ID);
-	  status = UPC_MAIN (argc, argv);
+          /* init GASP context */
+          GASP_INIT(__gasp_ctx, &argc, &argv);    
+          status = UPC_MAIN (argc, argv);
+          /* fire off collective exit, since we returned from main */
+          #define GASP_EN_ARGS , status
+          GASP_EN_S_NOSRC(GASP_UPC_COLLECTIVE_EXIT);
+          GASP_EN_E_NOSRC(GASP_UPC_COLLECTIVE_EXIT);
+          #undef GASP_EN_ARGS
 	  __upc_exit (status);
 	}
       else if (pid > 0)
@@ -525,7 +573,12 @@
 	    continue;
 	  fprintf (stderr, "thread %d terminated with signal: '%s'\n",
 		   thread_id, __upc_strsignal (child_sig));
-	  /* We'll all go away now. */
+          /* 
+           * GASP note: Here we would normally fire off a noncollective GASP
+           * exit event, but since this is a separate process and the other
+           * affected process has already been killed, we can't do anything.
+           */
+          /* We'll all go away now. */
 	  if (killpg (getpid(), SIGTERM) == -1)
 	    {
 	      perror ("killpg");
@@ -604,7 +657,14 @@
   upc_per_thread_init (u);
   status_ptr = &u->thread_info[thread_id].exit_status;
   __upc_barrier (UPC_RUNTIME_BARRIER_ID);
+  /* init GASP context */
+  GASP_INIT(__gasp_ctx, &startup_args->argc, &startup_args->argv);
   *status_ptr = UPC_MAIN (startup_args->argc, startup_args->argv);
+  /* fire off collective exit, since we returned from main */
+  #define GASP_EN_ARGS , *status_ptr
+  GASP_EN_S_NOSRC(GASP_UPC_COLLECTIVE_EXIT);
+  GASP_EN_E_NOSRC(GASP_UPC_COLLECTIVE_EXIT);
+  #undef GASP_EN_ARGS
   return status_ptr;
 }
 
@@ -734,6 +794,32 @@
 }
 
 
+/* Profiled version of __upc_exit */
+void
+__upc_exitg (int status)
+{
+  #define GASP_EN_ARGS , status
+  /* 
+   * Fire off a collective exit event.  __upc_exit doesn't return, so we just
+   * fire off the events without taking into account the final barrier time.
+   */
+  GASP_EN_S_NOSRC(GASP_UPC_COLLECTIVE_EXIT);
+  GASP_EN_E_NOSRC(GASP_UPC_COLLECTIVE_EXIT);
+  #undef GASP_EN_ARGS
+  __upc_exit(status);
+}
+
+/* Profiled version of upc_global_exit */
+void
+upc_global_exitg (int status, const char *filename, int line)
+{
+  /* fire off noncollective atomic exit event */
+  #define GASP_EN_ARGS , status
+  GASP_EN_A_NOSRC(GASP_UPC_NONCOLLECTIVE_EXIT);
+  #undef GASP_EN_ARGS
+  upc_global_exit(status);
+}
+
 /*
  * Issue a fatal UPC runtime error.
  *
@@ -788,3 +874,4 @@
   status = monitor_threads ();
   exit (status);
 }
+
Index: libupc/smp/upc_defs.h
===================================================================
--- libupc/smp/upc_defs.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_defs.h	(.../trunk)	(revision 34)
@@ -139,6 +139,18 @@
 /* Current thread id */
 extern THREAD_LOCAL int MYTHREAD;
 
+/* GASP bits */
+#ifndef DISABLE_GASP
+#include <stdarg.h>
+#include "gasp.h"
+#include "gasp_upc.h"
+#include "gasp_utils.h"
+/* GASP context pointer, has to be thread-local */
+extern THREAD_LOCAL gasp_context_t __gasp_ctx;
+/* GASP initialized flag */
+extern THREAD_LOCAL int __gasp_init;
+#endif
+
 #ifdef UPC_USE_PTHREADS
 /* The value of UPC_PTHREADS when defined at run time */
 extern int UPC_PTHREADS;
Index: libupc/smp/upc_barrier.c
===================================================================
--- libupc/smp/upc_barrier.c	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/smp/upc_barrier.c	(.../trunk)	(revision 34)
@@ -51,6 +51,17 @@
 }
 
 void
+__upc_notifyg (int barrier_id, const char *filename, int line)
+{
+  /* unnamed barriers have a value of INT_MIN */
+  #define GASP_EN_ARGS , (barrier_id != INT_MIN), barrier_id
+  GASP_EN_S(GASP_UPC_NOTIFY);
+  __upc_notify(barrier_id);
+  GASP_EN_E(GASP_UPC_NOTIFY);
+  #undef GASP_EN_ARGS
+}
+
+void
 __upc_wait (int barrier_id)
 {
   upc_info_p u = __upc_info;
@@ -91,8 +102,58 @@
 }
 
 void
+__upc_waitg (int barrier_id, const char *filename, int line)
+{
+  /* unnamed barriers have a value of INT_MIN */
+  #define GASP_EN_ARGS , (barrier_id != INT_MIN), barrier_id
+  GASP_EN_S(GASP_UPC_WAIT);
+  __upc_wait(barrier_id);
+  GASP_EN_E(GASP_UPC_WAIT);
+  #undef GASP_EN_ARGS
+}
+
+void
 __upc_barrier (int barrier_id)
 {
   __upc_notify (barrier_id);
   __upc_wait (barrier_id);
 }
+
+void
+__upc_barrierg (int barrier_id, const char *filename, int line)
+{
+  /* unnamed barriers have a value of INT_MIN */
+  #define GASP_EN_ARGS , (barrier_id != INT_MIN), barrier_id
+  GASP_EN_S(GASP_UPC_BARRIER);
+  __upc_barrier(barrier_id);
+  GASP_EN_E(GASP_UPC_BARRIER);
+  #undef GASP_EN_ARGS
+}
+
+void
+__upc_forallg (int start, const char *filename, int line) {
+  #define GASP_EN_ARGS
+  if (start)
+    {
+      GASP_EN_S(GASP_UPC_FORALL);
+    }
+  else
+    {
+      GASP_EN_E(GASP_UPC_FORALL);
+    }
+  #undef GASP_EN_ARGS
+}
+
+void __gasp_functiong (int start, const char *func, const char *filename, int line) {
+  #define GASP_EN_ARGS , func
+  if (start)
+    {
+      GASP_EN_S(GASP_C_FUNC);
+    }
+  else
+    {
+      GASP_EN_E(GASP_C_FUNC);
+    }
+  #undef GASP_EN_ARGS
+}
+
Index: libupc/configure
===================================================================
--- libupc/configure	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/configure	(.../trunk)	(revision 34)
@@ -1345,7 +1345,7 @@
     targ_runtime=smp
     
 echo $ac_n "checking whether the GCC __threads extension is supported.""... $ac_c" 1>&6
-echo "configure:1347: checking whether the GCC __threads extension is supported." >&5
+echo "configure:1349: checking whether the GCC __threads extension is supported." >&5
 if eval "test \"`echo '$''{'upc_cv_gcc_tls_supported'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1355,7 +1355,7 @@
   upc_cv_gcc_tls_supported="no"
 else
   cat > conftest.$ac_ext <<EOF
-#line 1357 "configure"
+#line 1359 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <stddef.h>
@@ -1413,7 +1413,7 @@
 }
 
 EOF
-if { (eval echo configure:1415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
     upc_cv_gcc_tls_supported="yes"
 else
@@ -1455,8 +1455,10 @@
 
 
 
+GASP_H="gasp.h gasp_upc.h pupc.h"
+
 UPC_H="upc.h upc_relaxed.h upc_strict.h \
-       gcc-upc.h gcc-upc-lib.h"
+       gcc-upc.h gcc-upc-lib.h $GASP_H"
 
 
 
@@ -1545,7 +1547,7 @@
 if test "$GCC" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
   echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
-echo "configure:1547: checking for ld used by GCC" >&5
+echo "configure:1551: checking for ld used by GCC" >&5
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -1575,10 +1577,10 @@
   esac
 elif test "$with_gnu_ld" = yes; then
   echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:1577: checking for GNU ld" >&5
+echo "configure:1581: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:1580: checking for non-GNU ld" >&5
+echo "configure:1584: checking for non-GNU ld" >&5
 fi
 if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1613,7 +1615,7 @@
 fi
 test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
 echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
-echo "configure:1615: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:1619: checking if the linker ($LD) is GNU ld" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1630,7 +1632,7 @@
 
 
 echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6
-echo "configure:1632: checking for $LD option to reload object files" >&5
+echo "configure:1636: checking for $LD option to reload object files" >&5
 if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1642,7 +1644,7 @@
 test -n "$reload_flag" && reload_flag=" $reload_flag"
 
 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:1644: checking for BSD-compatible nm" >&5
+echo "configure:1648: checking for BSD-compatible nm" >&5
 if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1680,7 +1682,7 @@
 echo "$ac_t""$NM" 1>&6
 
 echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6
-echo "configure:1682: checking how to recognise dependant libraries" >&5
+echo "configure:1686: checking how to recognise dependant libraries" >&5
 if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1848,13 +1850,13 @@
 deplibs_check_method=$lt_cv_deplibs_check_method
 
 echo $ac_n "checking for object suffix""... $ac_c" 1>&6
-echo "configure:1850: checking for object suffix" >&5
+echo "configure:1854: checking for object suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   rm -f conftest*
 echo 'int i = 1;' > conftest.$ac_ext
-if { (eval echo configure:1856: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1860: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   for ac_file in conftest.*; do
     case $ac_file in
     *.c) ;;
@@ -1878,7 +1880,7 @@
 file_magic*)
   if test "$file_magic_cmd" = '$MAGIC_CMD'; then
     echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
-echo "configure:1880: checking for ${ac_tool_prefix}file" >&5
+echo "configure:1884: checking for ${ac_tool_prefix}file" >&5
 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1940,7 +1942,7 @@
 if test -z "$lt_cv_path_MAGIC_CMD"; then
   if test -n "$ac_tool_prefix"; then
     echo $ac_n "checking for file""... $ac_c" 1>&6
-echo "configure:1942: checking for file" >&5
+echo "configure:1946: checking for file" >&5
 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2011,7 +2013,7 @@
 # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2013: checking for $ac_word" >&5
+echo "configure:2017: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2043,7 +2045,7 @@
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2045: checking for $ac_word" >&5
+echo "configure:2049: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2078,7 +2080,7 @@
 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2080: checking for $ac_word" >&5
+echo "configure:2084: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2110,7 +2112,7 @@
   # Extract the first word of "strip", so it can be a program name with args.
 set dummy strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2112: checking for $ac_word" >&5
+echo "configure:2116: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2177,8 +2179,8 @@
 case $host in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 2179 "configure"' > conftest.$ac_ext
-  if { (eval echo configure:2180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  echo '#line 2183 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:2184: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    if test "$lt_cv_prog_gnu_ld" = yes; then
     case `/usr/bin/file conftest.$ac_objext` in
     *32-bit*)
@@ -2211,7 +2213,7 @@
 ia64-*-hpux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
-  if { (eval echo configure:2213: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:2217: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case "`/usr/bin/file conftest.o`" in
     *ELF-32*)
       HPUX_IA64_MODE="32"
@@ -2227,7 +2229,7 @@
 x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
-  if { (eval echo configure:2229: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:2233: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       case $host in
@@ -2271,7 +2273,7 @@
   SAVE_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS -belf"
   echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:2273: checking whether the C compiler needs -belf" >&5
+echo "configure:2277: checking whether the C compiler needs -belf" >&5
 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2284,14 +2286,14 @@
 cross_compiling=$ac_cv_prog_cc_cross
 
      cat > conftest.$ac_ext <<EOF
-#line 2286 "configure"
+#line 2290 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   lt_cv_cc_needs_belf=yes
 else
@@ -2321,7 +2323,7 @@
   # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
 set dummy ${ac_tool_prefix}dlltool; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2323: checking for $ac_word" >&5
+echo "configure:2327: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2353,7 +2355,7 @@
   # Extract the first word of "dlltool", so it can be a program name with args.
 set dummy dlltool; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2355: checking for $ac_word" >&5
+echo "configure:2359: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2388,7 +2390,7 @@
   # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
 set dummy ${ac_tool_prefix}as; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2390: checking for $ac_word" >&5
+echo "configure:2394: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2420,7 +2422,7 @@
   # Extract the first word of "as", so it can be a program name with args.
 set dummy as; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2422: checking for $ac_word" >&5
+echo "configure:2426: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2455,7 +2457,7 @@
   # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
 set dummy ${ac_tool_prefix}objdump; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2457: checking for $ac_word" >&5
+echo "configure:2461: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2487,7 +2489,7 @@
   # Extract the first word of "objdump", so it can be a program name with args.
 set dummy objdump; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2489: checking for $ac_word" >&5
+echo "configure:2493: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2523,12 +2525,12 @@
   # recent cygwin and mingw systems supply a stub DllMain which the user
   # can override, but on older systems we have to supply one
   echo $ac_n "checking if libtool should supply DllMain function""... $ac_c" 1>&6
-echo "configure:2525: checking if libtool should supply DllMain function" >&5
+echo "configure:2529: checking if libtool should supply DllMain function" >&5
 if eval "test \"`echo '$''{'lt_cv_need_dllmain'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2530 "configure"
+#line 2534 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2536,7 +2538,7 @@
       DllMain (0, 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:2538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2542: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   lt_cv_need_dllmain=no
 else
@@ -2557,19 +2559,19 @@
     SAVE_CFLAGS="$CFLAGS"
     CFLAGS="$CFLAGS -mdll"
     echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6
-echo "configure:2559: checking how to link DLLs" >&5
+echo "configure:2563: checking how to link DLLs" >&5
 if eval "test \"`echo '$''{'lt_cv_cc_dll_switch'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2564 "configure"
+#line 2568 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   lt_cv_cc_dll_switch=-mdll
 else
@@ -2687,7 +2689,7 @@
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2689: checking for $ac_word" >&5
+echo "configure:2693: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2727,7 +2729,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:2729: checking for a BSD compatible install" >&5
+echo "configure:2733: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2780,7 +2782,7 @@
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:2782: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:2786: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2874,15 +2876,34 @@
 # Transform confdefs.h into DEFS.
 # Protect against shell expansion while executing Makefile rules.
 # Protect against Makefile macro expansion.
-cat > conftest.defs <<\EOF
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
-s%[ 	`~#$^&*(){}\\|;'"<>?]%\\&%g
-s%\[%\\&%g
-s%\]%\\&%g
-s%\$%$$%g
-EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
-rm -f conftest.defs
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then we branch to the quote section.  Otherwise,
+# look for a macro that doesn't take arguments.
+cat >confdef2opt.sed <<\_ACEOF
+t clear
+: clear
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	(][^ 	(]*([^)]*)\)[ 	]*\(.*\),-D\1=\2,g
+t quote
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\),-D\1=\2,g
+t quote
+d
+: quote
+s,[ 	`~#$^&*(){}\\|;'"<>?],\\&,g
+s,\[,\\&,g
+s,\],\\&,g
+s,\$,$$,g
+p
+_ACEOF
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output.  A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ac_LF_and_DOT=`echo; echo .`
+DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
+rm -f confdef2opt.sed
 
 
 # Without the "./", some shells look in PATH for config.status.
Index: libupc/include/gasp.h
===================================================================
--- libupc/include/gasp.h	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/include/gasp.h	(.../trunk)	(revision 34)
@@ -0,0 +1,91 @@
+/*
+ * Standard GASP header file.
+ *
+ * Adam Leko, Dan Bonachea
+ */
+
+#ifndef _GASP_H
+#define _GASP_H
+
+/*
+ * Limitations in this GASP implementation:
+ *
+ *  - There is no --inst-local flag.  For GCC UPC, with SMPs, there is no
+ *    difference between a "remote" or "local" access because they are both
+ *    treated in exactly the same way.
+ *
+ *  - --inst should be passed as -finstrument-gasp, and --inst-functions should
+ *    be passed as -finstrument-gasp-functions
+ *
+ *  - #pragma pupc only works when you place it outside a function.  In this
+ *    version of GCC UPC, pragmas for a basic block are handled entirely before
+ *    gimplifying the block, which means only one pragma state can apply to the
+ *    entire block.  The GOMP implementation has gotten around this by
+ *    providing a way to defer pragma processing, but that functionality isn't
+ *    available in this GCC UPC branch.
+ *
+ *  - Since the GASP instrumentation pragmas are handled by the frontend but
+ *    the frontend doesn't touch the regular UPC library calls (like
+ *    upc_memget), #pragma pupc doesn't have any effect on UPC library calls.
+ */
+
+/* ---------------------------------------------------------- */
+/* model-independent GASP declarations */
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/* For GASP spec 1.5 */
+#define GASP_VERSION 20060914L
+
+typedef enum {
+  GASP_MODEL_UPC,
+  GASP_MODEL_TITANIUM,
+  GASP_MODEL_CAF,
+  GASP_MODEL_MPI,
+  GASP_MODEL_SHMEM
+} gasp_model_t;
+
+/* ---------------------------------------------------------- */
+
+typedef enum {
+  GASP_START,
+  GASP_END,
+  GASP_ATOMIC,
+} gasp_evttype_t;
+
+struct _gasp_context_S;
+typedef struct _gasp_context_S *gasp_context_t;
+
+/* init the interface with a model, and get the thread-specific context */
+gasp_context_t gasp_init(gasp_model_t srcmodel, int *argc, char ***argv);
+
+/* notify the interface of a system-level or user-initiated event */
+void gasp_event_notify(gasp_context_t context, unsigned int evttag, gasp_evttype_t evttype,
+                       const char *filename, int linenum, int colnum, ...);
+/* 
+ * alternate interface where varargs are passed as a va_list 
+ * useful for writing compiler-provided wrappers like pupc_event_start()
+ */
+void gasp_event_notifyVA(gasp_context_t context, unsigned int evttag, gasp_evttype_t evttype,
+                       const char *filename, int linenum, int colnum, va_list varargs);
+
+/* 
+ * enable or disable collection for this thread, and return the prior value 
+ * called by UPC compiler's implementation of pupc_control
+ */
+int gasp_control(gasp_context_t context, int on);
+
+/*
+ * create a thread-specific user-level event handle, and associate an optional name 
+ * and printf-like description string to be evaluated upon each notification 
+ * called by UPC compiler's implementation of pupc_create_event
+ */
+unsigned int gasp_create_event(gasp_context_t context, const char *name, const char *desc);
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif
Index: libupc/include/gasp_upc.h
===================================================================
--- libupc/include/gasp_upc.h	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/include/gasp_upc.h	(.../trunk)	(revision 34)
@@ -0,0 +1,62 @@
+/*
+ * Header file for GCC UPC GASP events.
+ *
+ * Adam Leko, Dan Bonachea
+ */
+#ifndef _GASP_UPC_H
+#define _GASP_UPC_H
+
+typedef void gasp_upc_PTS_t; /* a void C "dummy" for (shared void *) */
+typedef void gasp_upc_lock_t;
+
+/* not supported, but defined anyways */
+#define GASP_UPC_NB_TRIVIAL    ((gasp_upc_nb_handle_t)0)
+typedef void *gasp_upc_nb_handle_t;
+
+/* peg the GASP version to the UPC version */
+#define GASP_UPC_VERSION       GCC_VERSION
+
+#define GASP_UPC_EVT_NONE      0
+
+/* used by tool to allocate user events */
+#define GASP_UPC_USEREVT_START 1000
+#define GASP_UPC_USEREVT_END   9999
+
+#define _GASP_UPC_SYSEVT_START 10000
+
+/* library calls */
+#define GASP_UPC_ALLOC                _GASP_UPC_SYSEVT_START+0
+#define GASP_UPC_GLOBAL_ALLOC         _GASP_UPC_SYSEVT_START+1
+#define GASP_UPC_ALL_ALLOC            _GASP_UPC_SYSEVT_START+2
+#define GASP_UPC_FREE                 _GASP_UPC_SYSEVT_START+3
+
+#define GASP_UPC_GLOBAL_LOCK_ALLOC    _GASP_UPC_SYSEVT_START+10
+#define GASP_UPC_ALL_LOCK_ALLOC       _GASP_UPC_SYSEVT_START+11
+#define GASP_UPC_LOCK_FREE            _GASP_UPC_SYSEVT_START+12
+#define GASP_UPC_LOCK_ATTEMPT         _GASP_UPC_SYSEVT_START+13
+#define GASP_UPC_LOCK                 _GASP_UPC_SYSEVT_START+14
+#define GASP_UPC_UNLOCK               _GASP_UPC_SYSEVT_START+15
+
+#define GASP_UPC_MEMGET               _GASP_UPC_SYSEVT_START+30
+#define GASP_UPC_MEMPUT               _GASP_UPC_SYSEVT_START+31
+#define GASP_UPC_MEMCPY               _GASP_UPC_SYSEVT_START+32
+#define GASP_UPC_MEMSET               _GASP_UPC_SYSEVT_START+33
+
+/* language ops */
+#define GASP_UPC_NOTIFY               _GASP_UPC_SYSEVT_START+100
+#define GASP_UPC_WAIT                 _GASP_UPC_SYSEVT_START+101
+#define GASP_UPC_BARRIER              _GASP_UPC_SYSEVT_START+102
+
+#define GASP_UPC_PUT                  _GASP_UPC_SYSEVT_START+110
+#define GASP_UPC_GET                  _GASP_UPC_SYSEVT_START+111
+
+#define GASP_UPC_FORALL               _GASP_UPC_SYSEVT_START+120
+
+/* events issued by runtime on shutdown */
+#define GASP_UPC_COLLECTIVE_EXIT      _GASP_UPC_SYSEVT_START+210
+#define GASP_UPC_NONCOLLECTIVE_EXIT   _GASP_UPC_SYSEVT_START+211
+
+/* C function calls */
+#define GASP_C_FUNC                   _GASP_UPC_SYSEVT_START+300
+
+#endif
Index: libupc/include/gcc-upc-lib.h
===================================================================
--- libupc/include/gcc-upc-lib.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/include/gcc-upc-lib.h	(.../trunk)	(revision 34)
@@ -99,10 +99,24 @@
 extern int main () __asm__("upc_main");
 #endif
 
+#ifdef __UPC_PUPC__
+/* 
+ * Remap calls to exit to profiled __upc_exit.  Note that we can't
+ * rewrite exit to take in extra args like __FILE__ and __LINE__,
+ * because if someone #includes upc.h before stdlib.h there will be a
+ * parameter mismatch that causes a compilation error.  We *always* do
+ * the rewrite (even if an --inst flag hasn't been passed), so we can
+ * always pass an exit event to a tool.
+ */
+#define exit __upc_exitg
+#else
 /* Remap calls to exit so that they invoke the UPC runtime's
    implementation of exit instead. */
 #define exit __upc_exit
+#endif
 extern void __upc_exit (int __status) __attribute__ ((__noreturn__));
+extern void __upc_exitg (int __status) __attribute__ ((__noreturn__));
+
 /* upc_shared_ptr_t is predefined as the representation of
    a shared pointer type. */
 
@@ -143,6 +157,17 @@
 extern void __upc_notify (int barrier_id);
 extern void __upc_wait (int barrier_id);
 
+/* profiled sync calls */
+extern void __upc_barrierg (int barrier_id, const char *file, int line);
+extern void __upc_notifyg (int barrier_id, const char *file, int line);
+extern void __upc_waitg (int barrier_id, const char *file, int line);
+
+/* profiled forall */
+extern void __upc_forallg (int start, const char *file, int line);
+
+/* profiled functions */
+extern void __gasp_functiong (int start, const char *func, const char *file, int line);
+
 extern void *__cvtaddr (upc_shared_ptr_t);
 extern void *__getaddr (upc_shared_ptr_t);
 
@@ -198,4 +223,56 @@
 
 extern void __copysblk3 (upc_shared_ptr_t, upc_shared_ptr_t, size_t);
 
+/* relaxed accesses, profiled */
+
+extern u_intQI_t __getgqi4 (upc_shared_ptr_t, const char *, int);
+extern u_intHI_t __getghi4 (upc_shared_ptr_t, const char *, int);
+extern u_intSI_t __getgsi4 (upc_shared_ptr_t, const char *, int);
+extern u_intDI_t __getgdi4 (upc_shared_ptr_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern u_intTI_t __getgti4 (upc_shared_ptr_t, const char *, int);
+#endif
+extern float __getgsf4 (upc_shared_ptr_t, const char *, int);
+extern double __getgdf4 (upc_shared_ptr_t, const char *, int);
+extern void __getgblk5 (void *, upc_shared_ptr_t, size_t, const char *, int);
+
+extern void __putgqi4 (upc_shared_ptr_t, u_intQI_t, const char *, int);
+extern void __putghi4 (upc_shared_ptr_t, u_intHI_t, const char *, int);
+extern void __putgsi4 (upc_shared_ptr_t, u_intSI_t, const char *, int);
+extern void __putgdi4 (upc_shared_ptr_t, u_intDI_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern void __putgti4 (upc_shared_ptr_t, u_intTI_t, const char *, int);
+#endif
+extern void __putgsf4 (upc_shared_ptr_t, float, const char *, int);
+extern void __putgdf4 (upc_shared_ptr_t, double, const char *, int);
+extern void __putgblk5 (upc_shared_ptr_t, void *, size_t, const char *, int);
+
+extern void __copygblk5 (upc_shared_ptr_t, upc_shared_ptr_t, size_t, const char *, int);
+
+/* strict accesses, profiled */
+
+extern u_intQI_t __getsgqi4 (upc_shared_ptr_t, const char *, int);
+extern u_intHI_t __getsghi4 (upc_shared_ptr_t, const char *, int);
+extern u_intSI_t __getsgsi4 (upc_shared_ptr_t, const char *, int);
+extern u_intDI_t __getsgdi4 (upc_shared_ptr_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern u_intTI_t __getsgti4 (upc_shared_ptr_t, const char *, int);
+#endif
+extern float __getsgsf4 (upc_shared_ptr_t, const char *, int);
+extern double __getsgdf4 (upc_shared_ptr_t, const char *, int);
+extern void __getsgblk5 (void *, upc_shared_ptr_t, size_t, const char *, int);
+
+extern void __putsgqi4 (upc_shared_ptr_t, u_intQI_t, const char *, int);
+extern void __putsghi4 (upc_shared_ptr_t, u_intHI_t, const char *, int);
+extern void __putsgsi4 (upc_shared_ptr_t, u_intSI_t, const char *, int);
+extern void __putsgdi4 (upc_shared_ptr_t, u_intDI_t, const char *, int);
+#if __UPC_SHARED_PTR_SIZE__ == 128
+extern void __putsgti4 (upc_shared_ptr_t, u_intTI_t, const char *, int);
+#endif
+extern void __putsgsf4 (upc_shared_ptr_t, float, const char *, int);
+extern void __putsgdf4 (upc_shared_ptr_t, double, const char *, int);
+extern void __putsgblk5 (upc_shared_ptr_t, void *, size_t, const char *, int);
+
+extern void __copygsblk5 (upc_shared_ptr_t, upc_shared_ptr_t, size_t, const char *, int);
+
 #endif /* !_GCC_UPC_LIB_H_ */
Index: libupc/include/pupc.h
===================================================================
--- libupc/include/pupc.h	(.../vendor/gcc-upc-4/current)	(revision 0)
+++ libupc/include/pupc.h	(.../trunk)	(revision 34)
@@ -0,0 +1,85 @@
+/*
+ * User-visible profiling control functions for UPC.
+ *
+ * Adam Leko, Dan Bonachea
+ */
+
+#ifndef _PUPC_H
+#define _PUPC_H
+
+/* For turning measurement code on and off */
+int pupc_control(int on);
+
+/* For creating user events */
+unsigned int pupc_create_event(const char *name, const char *desc);
+
+/* For recording user events */
+void pupc_event_start(unsigned int evttag, ...);
+void pupc_event_end(unsigned int evttag, ...);
+void pupc_event_atomic(unsigned int evttag, ...);
+
+/*
+ * Alternate versions that take source info in directly.  Not part of
+ * the GASP spec and not meant to be used directly; used by variadic
+ * macro wrappers below.
+ */
+void pupc_eventsrc_start(const char *file, int line, unsigned int evttag, ...);
+void pupc_eventsrc_end(const char *file, int line, unsigned int evttag, ...);
+void pupc_eventsrc_atomic(const char *file, int line, unsigned int evttag, ...);
+
+/*
+ * According to the GASP spec section 3.1.3, pragmas do not affect user
+ * functions.  So, pragmas have no bearing on any of the pupc_* calls
+ * here.
+ */
+
+/*
+ * If no __UPC_PUPC__, then compile away pupc functions.
+ * __UPC_PUPC__ is only set when GASP support has been compiled in.
+ */
+#ifndef __UPC_PUPC__
+
+  /* compile away event creation and meas control */
+  #define pupc_control(on) 0
+  #define pupc_create_event(name, desc) 0
+
+  /* compile away pupc_event calls using variadic macro support */
+  #define pupc_event_start(args...)
+  #define pupc_event_end(args...)
+  #define pupc_event_atomic(args...)
+
+#else
+
+  /*
+   * (This is according to the GASP spec section 5.3)
+   *
+   * If GCC UPC has been compiled with GASP support, then we _always_
+   * let calls to pupc_create_event() compile to something to preserve
+   * their side effects.  Ditto for pupc_control().
+   *
+   * However, if no --inst flags have been passed in, then we can
+   * compile away all pupc_event calls.  We can detect this because the
+   * frontend predefines __UPC_PUPC_INST__ if an --inst flag was passed.
+   */
+  #ifndef __UPC_PUPC_INST__
+
+    /* (still allow pupc_control and pupc_create_event to be generated) */
+
+    /* compile away pupc_event calls using variadic macro support */
+    #define pupc_event_start(args...)
+    #define pupc_event_end(args...)
+    #define pupc_event_atomic(args...)
+
+  #else
+
+    /* use variadic macro support to sneak in source information */
+    #define pupc_event_start(args...)  pupc_eventsrc_start(__FILE__, __LINE__, args)
+    #define pupc_event_end(args...)    pupc_eventsrc_end(__FILE__, __LINE__, args)
+    #define pupc_event_atomic(args...) pupc_eventsrc_atomic(__FILE__, __LINE__, args)
+
+  #endif
+
+#endif
+
+#endif
+
Index: libupc/include/upc.h
===================================================================
--- libupc/include/upc.h	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/include/upc.h	(.../trunk)	(revision 34)
@@ -57,4 +57,57 @@
 extern void upc_memput(shared void *, const void *, size_t);
 extern void upc_memset(shared void *, int, size_t);
 
+/* profiled library functions */
+
+extern void upc_global_exitg (int, const char *, int);
+
+extern shared void *upc_global_allocg (size_t, size_t, const char *, int);
+extern shared void *upc_all_allocg (size_t, size_t, const char *, int);
+extern shared void *upc_local_allocg (size_t, size_t, const char *, int);
+extern shared void *upc_allocg (size_t, const char *, int);
+extern void upc_freeg (shared void *, const char *, int);
+
+extern upc_lock_t *upc_global_lock_allocg (const char *, int);
+extern upc_lock_t *upc_all_lock_allocg (const char *, int);
+extern void upc_lockg (upc_lock_t *, const char *, int);
+extern int upc_lock_attemptg (upc_lock_t *, const char *, int);
+extern void upc_unlockg (upc_lock_t *, const char *, int);
+extern void upc_lock_freeg (upc_lock_t *, const char *, int);
+
+extern void upc_memcpyg (shared void *, shared const void *, size_t, const char *, int);
+extern void upc_memgetg (void *, shared const void *, size_t, const char *, int);
+extern void upc_memputg (shared void *, const void *, size_t, const char *, int);
+extern void upc_memsetg (shared void *, int, size_t, const char *, int);
+
+/*
+ * Since the GASP pragmas are handled in the frontend but the frontend
+ * doesn't handle regular UPC lib calls, we rewrite them if a --inst
+ * flag was passed, which we can detect from the __UPC_PUPC_INST__ flag.
+ * This means that the pragma pupc directives won't have any affect on
+ * the UPC lib calls, which is unfortunate but allowed by the GASP spec.
+ */
+#ifdef __UPC_PUPC_INST__
+
+#define upc_gloal_exit(n)        upc_global_exitg(n, __FILE__, __LINE__)
+
+#define upc_global_alloc(n, b)   upc_global_allocg(n, b, __FILE__, __LINE__)
+#define upc_all_alloc(n, b)      upc_all_allocg(n, b, __FILE__, __LINE__)
+#define upc_local_alloc(n, b)    upc_local_allocg(n, b, __FILE__, __LINE__)
+#define upc_alloc(n)             upc_allocg(n, __FILE__, __LINE__)
+#define upc_free(ptr)            upc_freeg(ptr, __FILE__, __LINE__)
+
+#define upc_global_lock_alloc()  upc_global_lock_allocg(__FILE__, __LINE__)
+#define upc_all_local_alloc()    upc_all_lock_allocg(__FILE__, __LINE__)
+#define upc_lock(lck)            upc_lockg(lck, __FILE__, __LINE__)
+#define upc_lock_attempt(lck)    upc_lock_attemptg(lck, __FILE__, __LINE__)
+#define upc_unlock(lck)          upc_unlockg(lck, __FILE__, __LINE__)
+#define upc_lock_free(lck)       upc_lock_freeg(lck, __FILE__, __LINE__)
+
+#define upc_memcpy(p1, p2, n)    upc_memcpyg(p1, p2, n, __FILE__, __LINE__)
+#define upc_memget(p1, p2, n)    upc_memgetg(p1, p2, n, __FILE__, __LINE__)
+#define upc_memput(p1, p2, n)    upc_memputg(p1, p2, n, __FILE__, __LINE__)
+#define upc_memset(p1, c, n)     upc_memsetg(p1, c, n, __FILE__, __LINE__)
+
+#endif /* lib func rewrites */
+
 #endif /* !_UPC_H_ */
Index: libupc/configure.in
===================================================================
--- libupc/configure.in	(.../vendor/gcc-upc-4/current)	(revision 34)
+++ libupc/configure.in	(.../trunk)	(revision 34)
@@ -124,8 +124,10 @@
 
 dnl User-visible include files
 
+GASP_H="gasp.h gasp_upc.h pupc.h"
+
 UPC_H="upc.h upc_relaxed.h upc_strict.h \
-       gcc-upc.h gcc-upc-lib.h"
+       gcc-upc.h gcc-upc-lib.h $GASP_H"
 AC_SUBST(UPC_H)
 
 dnl Checks for programs.
