Swarm-NG  1.1
gpulog_types.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Mario Juric *
3  * mjuric@cfa.harvard.EDU *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
27 #ifndef bits_gpulog_types_h__
28 #define bits_gpulog_types_h__
29 
30 #include <cuda_runtime.h>
31 
32 namespace gpulog
33 {
34  namespace internal
35  {
37  template<typename T>
38  struct array
39  {
41  int nelem;
42 
43  __device__ inline array(int n_) : nelem(n_) {}
44  };
45 
47  struct arginfo
48  {
50  int arg;
52  int align, size, dim;
54  bool isarray; int nelem;
56  int begin, len;
57  };
58 
60  struct header
61  {
63  int msgid;
65  int len;
66 
67  #if ARGINFO
68  int nargs; // number of arguments (including the header)
69  int infos; // offset to array of arginfo structures
70  #endif
71 
73  __host__ __device__ int dataoffset() const
74  {
75  int offs = sizeof(*this);
76  #if ARGINFO
77  offs += nargs * sizeof(arginfo);
78  #endif
79  return offs;
80  }
81 
83  __host__ __device__ static inline void new_header(header &h, int msgid_, int len_)
84  {
85  h.msgid = msgid_; h.len = len_;
86  #if ARGINFO
87  h.nargs = 0;
88  h.infos = 0;
89  #endif
90  }
92  __host__ __device__ inline header(int msgid_, int len_) { new_header(*this, msgid_, len_); }
93  };
94 
96  struct Tunspec { };
97 
99  struct ALIGN(16) Tmaxalign {};
100  }
101 
102 }
103 
104 #endif // bits_gpulog_types_h__