[Fortran-CAF, Patch, committed] Cleanup in libcaf.h; declare caf_send

2014-03-14 Thread Tobias Burnus

Hi all,

I have committed the attached patch to the Fortran-CAF branch. It paves 
the road to CAF sending support by declaring caf_send - and implementing 
it in libcaf_single.c (as memmove). Additionally, I cleaned up the 
library by handling the token in a better way (more readable - and 
permitting a cleaner implementation in the implementation part). 
Additionally, it includes some fixes to my recent branch patch.


The next step will be to add real sending support in the *compiler*, for 
which I have a draft patch. Adding send support to the library is a 
separate task and will be done by someone else.


Committed after building and regtesting on x86-64-gnu-linux as Rev. 208580.

Tobias


Re: [Fortran-CAF, Patch, committed] Cleanup in libcaf.h; declare caf_send

2014-03-14 Thread Tobias Burnus

I forgot to attach the patch.

Tobias Burnus wrote:

Hi all,

I have committed the attached patch to the Fortran-CAF branch. It 
paves the road to CAF sending support by declaring caf_send - and 
implementing it in libcaf_single.c (as memmove). Additionally, I 
cleaned up the library by handling the token in a better way (more 
readable - and permitting a cleaner implementation in the 
implementation part). Additionally, it includes some fixes to my 
recent branch patch.


The next step will be to add real sending support in the *compiler*, 
for which I have a draft patch. Adding send support to the library is 
a separate task and will be done by someone else.


Committed after building and regtesting on x86-64-gnu-linux as Rev. 
208580.


Tobias 
Index: libgfortran/ChangeLog.fortran-caf
===
--- libgfortran/ChangeLog.fortran-caf	(Revision 208554)
+++ libgfortran/ChangeLog.fortran-caf	(Arbeitskopie)
@@ -1,3 +1,17 @@
+2014-03-14  Tobias Burnus  
+
+	* caf/libcaf.h (caf_token_t): New typedef.
+	(caf_static_t, _gfortran_caf_register, _gfortran_caf_deregister):
+	Use it.
+	(_gfortran_send): New.
+	* caf/mpi.c (mpi_token_t, TOKEN): New.
+	(_gfortran_caf_register, _gfortran_caf_deregister): Update.
+	(_gfortran_caf_init): Fix prototype.
+	(_gfortran_caf_send): New stub implementation.
+	* caf/single.c (single_token_t, TOKEN): New.
+	(_gfortran_caf_register, _gfortran_caf_deregister): Update.
+	(_gfortran_caf_send): New; implement it.
+
 2014-03-08  Tobias Burnus  
 
 	* caf/libcaf.h (_gfortran_caf_this_image, _gfortran_caf_num_images):
Index: libgfortran/caf/libcaf.h
===
--- libgfortran/caf/libcaf.h	(Revision 208554)
+++ libgfortran/caf/libcaf.h	(Arbeitskopie)
@@ -28,6 +28,7 @@
 
 #include 	/* For int32_t.  */
 #include 	/* For size_t.  */
+#include 
 
 #ifndef __GNUC__
 #define __attribute__(x)
@@ -55,9 +56,11 @@
 }
 caf_register_t;
 
+typedef void* caf_token_t;
+
 /* Linked list of static coarrays registered.  */
 typedef struct caf_static_t {
-  void **token;
+  caf_token_t token;
   struct caf_static_t *prev;
 }
 caf_static_t;
@@ -69,10 +72,11 @@
 int _gfortran_caf_this_image (int);
 int _gfortran_caf_num_images (int, int);
 
-void * _gfortran_caf_register (size_t, caf_register_t, void ***, int *,
-			   char *, int);
-void _gfortran_caf_deregister (void ***, int *, char *, int);
+void *_gfortran_caf_register (size_t, caf_register_t, caf_token_t *, int *,
+			  char *, int);
+void _gfortran_caf_deregister (caf_token_t *, int *, char *, int);
 
+void _gfortran_send (caf_token_t, size_t, int, void *, size_t, bool);
 
 void _gfortran_caf_sync_all (int *, char *, int);
 void _gfortran_caf_sync_images (int, int[], int *, char *, int);
Index: libgfortran/caf/mpi.c
===
--- libgfortran/caf/mpi.c	(Revision 208554)
+++ libgfortran/caf/mpi.c	(Arbeitskopie)
@@ -34,6 +34,8 @@
 /* Define GFC_CAF_CHECK to enable run-time checking.  */
 /* #define GFC_CAF_CHECK  1  */
 
+typedef void ** mpi_token_t;
+#define TOKEN(X) ((mpi_token_t) (X))
 
 static void error_stop (int error) __attribute__ ((noreturn));
 
@@ -73,7 +75,7 @@
libaray is initialized.  */
 
 void
-_gfortran_caf_init (int *argc, char ***argv, int *this_image, int *num_images)
+_gfortran_caf_init (int *argc, char ***argv)
 {
   if (caf_num_images == 0)
 {
@@ -99,8 +101,8 @@
 {
   caf_static_t *tmp = caf_static_list->prev;
 
-  free (caf_static_list->token[caf_this_image-1]);
-  free (caf_static_list->token);
+  free (TOKEN(caf_static_list->token)[caf_this_image-1]);
+  free (TOKEN(caf_static_list->token));
   free (caf_static_list);
   caf_static_list = tmp;
 }
@@ -128,7 +130,7 @@
 
 
 void *
-_gfortran_caf_register (size_t size, caf_register_t type, void ***token,
+_gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
 			int *stat, char *errmsg, int errmsg_len)
 {
   void *local;
@@ -139,17 +141,17 @@
 
   /* Start MPI if not already started.  */
   if (caf_num_images == 0)
-_gfortran_caf_init (NULL, NULL, NULL, NULL);
+_gfortran_caf_init (NULL, NULL);
 
   /* Token contains only a list of pointers.  */
   local = malloc (size);
-  *token = malloc (sizeof (void*) * caf_num_images);
+  *token = malloc (sizeof (mpi_token_t) * caf_num_images);
 
   if (unlikely (local == NULL || *token == NULL))
 goto error;
 
   /* token[img-1] is the address of the token in image "img".  */
-  err = MPI_Allgather (&local, sizeof (void*), MPI_BYTE, *token,
+  err = MPI_Allgather (&local, sizeof (void*), MPI_BYTE, TOKEN(*token),
 		   sizeof (void*), MPI_BYTE, MPI_COMM_WORLD);
 
   if (unlikely (err))
@@ -202,7 +204,7 @@
 
 
 void
-_gfortran_caf_deregister (void ***token, int *stat, char *errmsg, int errmsg_len)
+_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errmsg_len)
 {