ug4
pcl_datatype.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2015: G-CSC, Goethe University Frankfurt
3  * Author: Martin Rupp
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #include <mpi.h>
34 #include "common/types.h"
35 #include "common/error.h"
36 #ifndef __H__PCL__pcl_datatype__
37 #define __H__PCL__pcl_datatype__
38 
39 namespace pcl
40 {
41 
44 
45 // DataType
46 #define PCL_DT_NULL MPI_DATATYPE_NULL
47 #define PCL_DT_BYTE MPI_BYTE
48 #define PCL_DT_PACKED MPI_PACKED
49 #define PCL_DT_CHAR MPI_CHAR
50 #define PCL_DT_SHORT MPI_SHORT
51 #define PCL_DT_INT MPI_INT
52 #define PCL_DT_LONG MPI_LONG
53 #define PCL_DT_UNSIGNED_LONG MPI_UNSIGNED_LONG
54 #define PCL_DT_LONG_LONG_INT MPI_LONG_LONG_INT
55 #define PCL_DT_UNSIGNED_LONG_LONG MPI_UNSIGNED_LONG_LONG
56 #define PCL_DT_FLOAT MPI_FLOAT
57 #define PCL_DT_DOUBLE MPI_DOUBLE
58 #define PCL_DT_LONG_DOUBLE MPI_LONG_DOUBLE
59 #define PCL_DT_UNSIGNED_CHAR MPI_UNSIGNED_CHAR
60 
61 typedef MPI_Datatype DataType;
62 
65 
66 template<typename T>
68 {
69 public:
70  static DataType get_data_type() {return T::PCL_DATATYPE_NOT_SUPPORTED(); }
72  enum { directlySupported = false };
73 };
74 
75 template<>
76 class DataTypeTraits<unsigned long>
77 {
78 public:
81  enum { directlySupported = true };
82 };
83 
84 template<>
85 class DataTypeTraits<unsigned long long>
86 {
87 public:
90  enum { directlySupported = true };
91 };
92 
93 template<>
94 class DataTypeTraits<long>
95 {
96 public:
97  static DataType get_data_type() {return PCL_DT_LONG; }
99  enum { directlySupported = true };
100 };
101 template<>
102 class DataTypeTraits<int>
103 {
104 public:
105  static DataType get_data_type() {return PCL_DT_INT; }
107  enum { directlySupported = true };
108 };
109 template<>
110 class DataTypeTraits<float>
111 {
112 public:
113  static DataType get_data_type() {return PCL_DT_FLOAT; }
115  enum { directlySupported = true };
116 };
117 template<>
118 class DataTypeTraits<double>
119 {
120 public:
123  enum { directlySupported = true };
124 };
125 
126 template<>
127 class DataTypeTraits<char>
128 {
129 public:
130  static DataType get_data_type() {return PCL_DT_CHAR; }
132  enum { directlySupported = true };
133 };
134 
135 template<>
136 class DataTypeTraits<unsigned char>
137 {
138 public:
141  enum { directlySupported = true };
142 };
143 
144 inline size_t GetSize(const DataType &t)
145 {
146  if(t == PCL_DT_UNSIGNED_CHAR) return sizeof(unsigned char);
147  else if(t == PCL_DT_CHAR) return sizeof(char);
148  else if(t == PCL_DT_DOUBLE) return sizeof(double);
149  else if(t == PCL_DT_FLOAT) return sizeof(float);
150  else if(t == PCL_DT_INT) return sizeof(int);
151  else if(t == PCL_DT_LONG) return sizeof(long);
152  else if(t == PCL_DT_UNSIGNED_LONG) return sizeof(unsigned long);
153  else if(t == PCL_DT_UNSIGNED_LONG_LONG) return sizeof(unsigned long long);
154  UG_THROW("Datatype not supported: " << t << " ???"); return 1;
155 }
156 
157 // end group pcl
159 
160 }
161 
162 #endif
Definition: pcl_datatype.h:63
Definition: pcl_datatype.h:64
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:131
static DataType get_data_type()
Definition: pcl_datatype.h:130
static DataType get_data_type()
Definition: pcl_datatype.h:121
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:122
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:114
static DataType get_data_type()
Definition: pcl_datatype.h:113
static DataType get_data_type()
Definition: pcl_datatype.h:105
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:106
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:98
static DataType get_data_type()
Definition: pcl_datatype.h:97
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:140
static DataType get_data_type()
Definition: pcl_datatype.h:139
static DataType get_data_type()
Definition: pcl_datatype.h:79
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:80
DataTypeDirectlySupported supported
Definition: pcl_datatype.h:89
static DataType get_data_type()
Definition: pcl_datatype.h:88
Definition: pcl_datatype.h:68
static DataType get_data_type()
Definition: pcl_datatype.h:70
DataTypeIndirectlySupported supported
Definition: pcl_datatype.h:71
@ directlySupported
Definition: pcl_datatype.h:72
#define PCL_DT_UNSIGNED_LONG
Definition: pcl_datatype.h:53
MPI_Datatype DataType
Definition: pcl_datatype.h:61
#define PCL_DT_UNSIGNED_LONG_LONG
Definition: pcl_datatype.h:55
#define PCL_DT_LONG
Definition: pcl_datatype.h:52
#define PCL_DT_DOUBLE
Definition: pcl_datatype.h:57
#define PCL_DT_FLOAT
Definition: pcl_datatype.h:56
size_t GetSize(const DataType &t)
Definition: pcl_datatype.h:144
#define PCL_DT_CHAR
Definition: pcl_datatype.h:49
#define PCL_DT_UNSIGNED_CHAR
Definition: pcl_datatype.h:59
#define PCL_DT_INT
Definition: pcl_datatype.h:51
#define UG_THROW(msg)
Definition: error.h:57
Definition: parallel_grid_layout.h:46