aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2008-07-24 18:06:34 -0500
committerErik Schnetter <schnetter@cct.lsu.edu>2008-07-24 18:14:47 -0500
commit77169dfcabafdcf4ae18639931a222462736480f (patch)
treef95d8ba4b385b58d3749245d76b4e5cc21524b53
parentd97872f2922480139f2e279caebd4799e162d7a9 (diff)
CarpetLib: Introduce template versions of functions c_datatype and datatype
Introduce template functions for dist::c_datatype and dist::datatype. These functions do not need a dummy parameter.
-rw-r--r--Carpet/CarpetLib/src/dist.hh49
1 files changed, 48 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/dist.hh b/Carpet/CarpetLib/src/dist.hh
index cf4cbd70c..6868d85ce 100644
--- a/Carpet/CarpetLib/src/dist.hh
+++ b/Carpet/CarpetLib/src/dist.hh
@@ -172,7 +172,30 @@ namespace dist {
inline unsigned int c_ndatatypes ()
{ return 16; }
-
+ template <typename T> unsigned int c_datatype () { abort(); }
+ template<> inline unsigned int c_datatype <char> () { return 0; }
+ template<> inline unsigned int c_datatype <signed char> () { return 1; }
+ template<> inline unsigned int c_datatype <unsigned char> () { return 2; }
+ template<> inline unsigned int c_datatype <short> () { return 3; }
+ template<> inline unsigned int c_datatype <unsigned short> () { return 4; }
+ template<> inline unsigned int c_datatype <int> () { return 5; }
+ template<> inline unsigned int c_datatype <unsigned int> () { return 6; }
+ template<> inline unsigned int c_datatype <long> () { return 7; }
+ template<> inline unsigned int c_datatype <unsigned long> () { return 8; }
+ template<> inline unsigned int c_datatype <long long> () { return 9; }
+ template<> inline unsigned int c_datatype <float> () { return 10; }
+ template<> inline unsigned int c_datatype <double> () { return 11; }
+ template<> inline unsigned int c_datatype <long double> () { return 12; }
+#ifdef HAVE_CCTK_COMPLEX8
+ template<> inline unsigned int c_datatype <CCTK_COMPLEX8> () { return 13; }
+#endif
+#ifdef HAVE_CCTK_COMPLEX16
+ template<> inline unsigned int c_datatype <CCTK_COMPLEX16> () { return 14; }
+#endif
+#ifdef HAVE_CCTK_COMPLEX32
+ template<> inline unsigned int c_datatype <CCTK_COMPLEX32> () { return 15; }
+#endif
+
/////////////////////////////////////////////////////////////////
// MPI Datatype helpers
// Map a C datatype to its corresponding MPI datatype.
@@ -231,6 +254,30 @@ namespace dist {
{ return mpi_complex32; }
#endif
+ template <typename T> MPI_Datatype datatype () { abort(); }
+ template<> inline MPI_Datatype datatype <char> () { return MPI_CHAR; }
+ template<> inline MPI_Datatype datatype <signed char> () { return MPI_CHAR; }
+ template<> inline MPI_Datatype datatype <unsigned char> () { return MPI_UNSIGNED_CHAR; }
+ template<> inline MPI_Datatype datatype <short> () { return MPI_SHORT; }
+ template<> inline MPI_Datatype datatype <unsigned short> () { return MPI_UNSIGNED_SHORT; }
+ template<> inline MPI_Datatype datatype <int> () { return MPI_INT; }
+ template<> inline MPI_Datatype datatype <unsigned int> () { return MPI_UNSIGNED; }
+ template<> inline MPI_Datatype datatype <long> () { return MPI_LONG; }
+ template<> inline MPI_Datatype datatype <unsigned long> () { return MPI_UNSIGNED_LONG; }
+ template<> inline MPI_Datatype datatype <long long> () { return MPI_LONG_LONG_INT; }
+ template<> inline MPI_Datatype datatype <float> () { return MPI_FLOAT; }
+ template<> inline MPI_Datatype datatype <double> () { return MPI_DOUBLE; }
+ template<> inline MPI_Datatype datatype <long double> () { return MPI_LONG_DOUBLE; }
+#ifdef HAVE_CCTK_COMPLEX8
+ template<> inline MPI_Datatype datatype <CCTK_COMPLEX8> () { return mpi_complex8; }
+#endif
+#ifdef HAVE_CCTK_COMPLEX16
+ template<> inline MPI_Datatype datatype <CCTK_COMPLEX16> () { return mpi_complex16; }
+#endif
+#ifdef HAVE_CCTK_COMPLEX32
+ template<> inline MPI_Datatype datatype <CCTK_COMPLEX32> () { return mpi_complex32; }
+#endif
+
} // namespace dist