summaryrefslogtreecommitdiff
path: root/src/comm
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-02-04 09:27:42 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-02-04 09:27:42 +0000
commitaaa78240ef7409f27bfadf3916d095eb0007bfa9 (patch)
tree7141af89a69c40a9beee5bc4ee60f320f9862b74 /src/comm
parent4ec2152e21ddce9f873f6d1d4beb0b5b9bec3c41 (diff)
Rationalised the overloading of functions. Goodbye RegisterKeyedFunction,
hello Overloadable ! Now each subdirectory has one header file (in the include dir) which defines the overloadable functions. Macros are then applied to the header file to produce functions of the form CCTK_OverloadFoo(... (*func)(...)) to overload the function, and to create prototypes, dummy functions, and if statements which can be used to assign dummy (or other default) functions to any overloadable function which hasn't been assigned. The resulting functions have names of the form CCTK_Foo() As a byproduct of this the communication layer should work, 'though it's all dummy functions there at the moment, but at least you can call the functions. I've put OutputGH and OutputGroup in the IO layer, but can't remember precisely what we had decided as the canonical set of overloadable functions for IO. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@206 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/comm')
-rw-r--r--src/comm/CactusDefaultComm.c29
-rw-r--r--src/comm/Overload.c82
-rw-r--r--src/comm/RegisterCommFunction.c169
-rw-r--r--src/comm/make.code.defn2
4 files changed, 83 insertions, 199 deletions
diff --git a/src/comm/CactusDefaultComm.c b/src/comm/CactusDefaultComm.c
index f4d166e0..e7f96ffd 100644
--- a/src/comm/CactusDefaultComm.c
+++ b/src/comm/CactusDefaultComm.c
@@ -99,33 +99,4 @@ cGH *CactusDefaultSetupGH(tFleshConfig *config, int convergence_level)
return thisGH;
}
-int CactusDefaultSyncAllFuncs(cGH *GH)
-{
- printf("I'm at line %d of file %s\n", __LINE__, __FILE__);
-}
-
-int CactusDefaultSyncGroupFuncs(cGH *GH, const char *group)
-{
- printf("I'm at line %d of file %s\n", __LINE__, __FILE__);
-}
-
-int CactusDefaultSyncOneFunc(cGH *GH, int GF)
-{
- printf("I'm at line %d of file %s\n", __LINE__, __FILE__);
-}
-
-int CactusDefaultParallelInit(tFleshConfig *config)
-{
- printf("I'm at line %d of file %s\n", __LINE__, __FILE__);
-}
-
-int CactusDefaultParallelFinalise(tFleshConfig *config)
-{
- printf("I'm at line %d of file %s\n", __LINE__, __FILE__);
-}
-
-int CactusDefaultReduce(cGH *GH, int GF, int operation, void *result)
-{
- printf("I'm at line %d of file %s\n", __LINE__, __FILE__);
-}
diff --git a/src/comm/Overload.c b/src/comm/Overload.c
new file mode 100644
index 00000000..fc509e3c
--- /dev/null
+++ b/src/comm/Overload.c
@@ -0,0 +1,82 @@
+ /*@@
+ @file Overload.c
+ @date Wed Feb 3 23:27:18 1999
+ @author Tom Goodale
+ @desc
+ Contains routines to overload the communication functions.
+ Uses the overload macros to make sure of consistency and
+ to save typing !
+ @enddesc
+ @@*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "flesh.h"
+#include "OverloadMacros.h"
+
+static char *rcsid="$Header$";
+
+/* Define the prototypes for the dummy functions. */
+#define OVERLOADABLE(name) OVERLOADABLE_DUMMYPROTOTYPE(name)
+
+ /* Deal seperately with the SetupGH routine */
+#define CCTK_DummySetupGH CactusDefaultSetupGH
+
+#include "CommOverloadables.h"
+
+ /* Reset the #define to prevent complications. */
+#undef CCTK_DummySetupGH
+
+#undef OVERLOADABLE(name)
+
+/* Create the overloadable function variables and the
+ * functions allowing the variables to be set.
+ */
+#define OVERLOADABLE(name) OVERLOADABLE_FUNCTION(name)
+
+#include "CommOverloadables.h"
+
+#undef OVERLOADABLE(name)
+
+
+ /*@@
+ @routine SetupCommFunctions(void)
+ @date Thu Feb 4 08:21:26 1999
+ @author Tom Goodale
+ @desc
+ Set any comm function which hasn't been overloaded to the default.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int SetupCommFunctions(void)
+{
+
+#define OVERLOADABLE(name) OVERLOADABLE_CHECK(name)
+
+ /* Deal seperately with the SetupGH routine */
+#define CCTK_DummySetupGH CactusDefaultSetupGH
+
+#include "CommOverloadables.h"
+
+ /* Reset the #define to prevent complications. */
+#undef CCTK_DummySetupGH
+
+#undef OVERLOADABLE(name)
+
+ return 0;
+}
+
+/* Create the dummy functions. */
+#define OVERLOADABLE(name) OVERLOADABLE_DUMMY(name)
+
+#include "CommOverloadables.h"
+
+#undef OVERLOADABLE(name)
+
diff --git a/src/comm/RegisterCommFunction.c b/src/comm/RegisterCommFunction.c
deleted file mode 100644
index 51f099de..00000000
--- a/src/comm/RegisterCommFunction.c
+++ /dev/null
@@ -1,169 +0,0 @@
- /*@@
- @file RegisterCommFunctions.c
- @date Tue Sep 29 10:38:41 1998
- @author Tom Goodale
- @desc
- Routines to register the main routines.
- @enddesc
- @@*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "flesh.h"
-#include "RegisterKeyedFunction.h"
-#include "CactusCommFunctions.h"
-#include "CactusCommDefaults.h"
-
-static char *rcsid = "$Id$";
-
-
-/* Definitions of how many functions */
-#define CACTUS_COMM_MIN 0
-#define CACTUS_COMM_MAX 7
-
-/* The functions. */
-
-cGH * (*SetupGH)(tFleshConfig *, int);
-int (*SetupGF)(cGH *, cGF *);
-
-int (*SyncAllFuncs)(cGH *);
-int (*SyncGroupFuncs)(cGH *, const char *group);
-int (*SyncOneFunc)(cGH*, int );
-
-int (*ParallelInit)(tFleshConfig *);
-int (*ParallelFinalise)(tFleshConfig *);
-
-int (*Reduce)(cGH *, int , int operation, void *result);
-
-
-/* Array of functions */
-
-static void (**functions)() = NULL;
-
-
- /*@@
- @routine RegisterCommFunction
- @date Tue Sep 29 14:11:07 1998
- @author Tom Goodale
- @desc
- Registers a function for use by the cactus communication layer.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
-@@*/
-int RegisterCommFunction(int key, int (*func)())
-{
- int return_code;
-
- /* Allocate memory for the array of functions. */
- if(!functions) functions = CreateKeyedFunctionArray(CACTUS_COMM_MAX - CACTUS_COMM_MIN+1);
-
- /* Check if all is well. */
- if(!functions)
- {
- fprintf(stderr, "Memory allocation error at line %d in file %s\n", __LINE__, __FILE__);
- exit(1);
- }
- else
- {
- /* Register the function. */
- return_code = RegisterKeyedFunction(functions,
- CACTUS_COMM_MIN,
- CACTUS_COMM_MAX,
- key,
- (void (*)())func);
- };
-
- return return_code;
-}
-
-
- /*@@
- @routine SetupCommFunctions
- @date Tue Sep 29 14:19:51 1998
- @author Tom Goodale
- @desc
- Assigns the correct names to the registered functions.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
-@@*/
-int SetupCommFunctions(void)
-{
-
- if(functions&&functions[0])
- {
- SetupGH = (cGH * (*)(tFleshConfig *, int))functions[0];
- }
- else
- {
- SetupGH = CactusDefaultSetupGH;
- }
-
- if(functions&&functions[0])
- {
- SyncAllFuncs = (int (*)(cGH *))functions[0];
- }
- else
- {
- SyncAllFuncs = CactusDefaultSyncAllFuncs;
- }
-
- if(functions&&functions[0])
- {
- SyncGroupFuncs = (int (*)(cGH *, const char *group))functions[0];
- }
- else
- {
- SyncGroupFuncs = CactusDefaultSyncGroupFuncs;
- }
-
- if(functions&&functions[0])
- {
- SyncOneFunc = (int (*)(cGH*, int ))functions[0];
- }
- else
- {
- SyncOneFunc = CactusDefaultSyncOneFunc;
- }
-
-
- if(functions&&functions[0])
- {
- ParallelInit = (int (*)(tFleshConfig *))functions[0];
- }
- else
- {
- ParallelInit = CactusDefaultParallelInit;
- }
-
- if(functions&&functions[0])
- {
- ParallelFinalise = (int (*)(tFleshConfig *))functions[0];
- }
- else
- {
- ParallelFinalise = CactusDefaultParallelFinalise;
- }
-
-
- if(functions&&functions[0])
- {
- Reduce = (int (*)(cGH *, int , int operation, void *result))functions[0];
- }
- else
- {
- Reduce = CactusDefaultReduce;
- }
-
- return 0;
-}
diff --git a/src/comm/make.code.defn b/src/comm/make.code.defn
index 094b4e70..c0fd8505 100644
--- a/src/comm/make.code.defn
+++ b/src/comm/make.code.defn
@@ -1,5 +1,5 @@
SRCS=\
CactusDefaultComm.c\
GHExtensions.c\
-RegisterCommFunction.c\
+Overload.c