AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
sphPrerequisites.hpp
Go to the documentation of this file.
1/*
2 * This file is part of AQUAgpusph, a free CFD program based on SPH.
3 * Copyright (C) 2012 Jose Luis Cercos Pita <jl.cercos@upm.es>
4 *
5 * AQUAgpusph 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 * AQUAgpusph 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 AQUAgpusph. If not, see <http://www.gnu.org/licenses/>.
17 */
18
22
23#ifndef SPHPREREQUISITES_H_INCLUDED
24#define SPHPREREQUISITES_H_INCLUDED
25
29#define XSTR(x) STR(x)
39#define STR(x) #x
40
41#include <string>
42
43// CMake configuration file
44#include "aquagpusph/config.h"
45
46#if __APPLE__
47#include <OpenCL/cl.h>
48#else
49#include <CL/cl.h>
50#endif
51
52#include <boost/current_function.hpp>
53
54#ifdef AQUAgpusph_EXPORTS
55#ifdef WIN32
56#define DECLDIR __declspec(dllexport)
57#else
58#define DECLDIR
59#endif
60#else
61#ifdef WIN32
62#define DECLDIR __declspec(dllimport)
63#else
65#define DECLDIR
66#endif
67#endif
68
69#ifndef icl
73#define icl cl_int
74#endif
75#ifndef lcl
79#define lcl cl_long
80#endif
81#ifndef uicl
85#define uicl cl_uint
86#endif
87#ifndef ulcl
91#define ulcl cl_ulong
92#endif
93#ifndef fcl
97#define fcl cl_float
98#endif
99#ifndef dcl
103#define dcl cl_double
104#endif
105
106#ifndef vec2
110#define vec2 cl_float2
111#endif
112#ifndef vec3
116#define vec3 cl_float3
117#endif
118#ifndef vec4
122#define vec4 cl_float4
123#endif
124#ifndef vec8
128#define vec8 cl_float8
129#endif
130#ifndef vec16
134#define vec16 cl_float16
135#endif
136
137#ifndef matrix2x2
141#define matrix2x2 cl_float4
142#endif
143#ifndef matrix4x4
147#define matrix4x4 cl_float16
148#endif
149
150#ifndef dvec2
154#define dvec2 cl_double2
155#endif
156#ifndef dvec3
160#define dvec3 cl_double3
161#endif
162#ifndef dvec4
166#define dvec4 cl_double4
167#endif
168#ifndef dvec8
172#define dvec8 cl_double8
173#endif
174#ifndef dvec16
178#define dvec16 cl_double16
179#endif
180
181#ifndef ivec2
185#define ivec2 cl_int2
186#endif
187#ifndef ivec3
191#define ivec3 cl_int3
192#endif
193#ifndef ivec4
197#define ivec4 cl_int4
198#endif
199#ifndef ivec8
203#define ivec8 cl_int8
204#endif
205#ifndef ivec16
209#define ivec16 cl_int16
210#endif
211
212#ifndef lvec2
216#define lvec2 cl_long2
217#endif
218#ifndef lvec3
222#define lvec3 cl_long3
223#endif
224#ifndef lvec4
228#define lvec4 cl_long4
229#endif
230#ifndef lvec8
234#define lvec8 cl_long8
235#endif
236#ifndef lvec16
240#define lvec16 cl_long16
241#endif
242
243#ifndef uivec2
247#define uivec2 cl_uint2
248#endif
249#ifndef uivec3
253#define uivec3 cl_uint3
254#endif
255#ifndef uivec4
259#define uivec4 cl_uint4
260#endif
261#ifndef uivec8
265#define uivec8 cl_uint8
266#endif
267#ifndef uivec16
271#define uivec16 cl_uint16
272#endif
273
274#ifndef ulvec2
278#define ulvec2 cl_ulong2
279#endif
280#ifndef ulvec3
284#define ulvec3 cl_ulong3
285#endif
286#ifndef ulvec4
290#define ulvec4 cl_ulong4
291#endif
292#ifndef ulvec8
296#define ulvec8 cl_ulong8
297#endif
298#ifndef ulvec16
302#define ulvec16 cl_ulong16
303#endif
304
305#ifndef __CL_MIN_LOCALSIZE__
315#define __CL_MIN_LOCALSIZE__ 64
316#endif
317#ifndef __CL_MAX_LOCALSIZE__
327#define __CL_MAX_LOCALSIZE__ 1024
328#endif
329
331static std::string methodAndClassName_str;
332
346inline const std::string
347methodAndClassName(const std::string& pretty_function)
348{
349 std::string all_name, method_name, class_name;
350 size_t begin, end;
351
352 // Filter the name removing the preceding and trailing types data
353 end = pretty_function.find("(");
354 begin = pretty_function.substr(0, end).rfind(" ") + 1;
355 end -= begin;
356 all_name = pretty_function.substr(begin, end);
357
358 // Get the method name
359 begin = all_name.rfind("::");
360 if (begin == std::string::npos) {
361 // There are no class name
362 methodAndClassName_str = all_name;
364 }
365 method_name = all_name.substr(begin + 2, std::string::npos);
366 end = begin;
367 begin = all_name.substr(0, end).rfind("::");
368 if (begin == std::string::npos)
369 begin = 0;
370 else
371 begin += 2;
372 end -= begin;
373 class_name = all_name.substr(begin, end);
374 methodAndClassName_str = class_name + "::" + method_name;
376}
377
383#define __METHOD_CLASS_NAME__ methodAndClassName(BOOST_CURRENT_FUNCTION)
384
388#ifdef __GNUC__
389# define UNUSED_PARAM __attribute__((__unused__))
390#else
391# define UNUSED_PARAM
392#endif
393
394#endif // SPHPREREQUISITES_H_INCLUDED
const std::string methodAndClassName(const std::string &pretty_function)
Function to extract the class and function from <strong class= macro.
Definition sphPrerequisites.hpp:347
static std::string methodAndClassName_str
Helper string for methodAndClassName function.
Definition sphPrerequisites.hpp:331