SkelCL
SkelCL is a high level multi GPU skeleton library developed at the university of Münster, Germany.
 All Classes Namespaces Files Functions Variables Typedefs Groups
ProgramTests.cpp
1 /*****************************************************************************
2  * Copyright (c) 2011-2012 The SkelCL Team as listed in CREDITS.txt *
3  * http://skelcl.uni-muenster.de *
4  * *
5  * This file is part of SkelCL. *
6  * SkelCL is available under multiple licenses. *
7  * The different licenses are subject to terms and condition as provided *
8  * in the files specifying the license. See "LICENSE.txt" for details *
9  * *
10  *****************************************************************************
11  * *
12  * SkelCL is free software: you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation, either version 3 of the License, or *
15  * (at your option) any later version. See "LICENSE-gpl.txt" for details. *
16  * *
17  * SkelCL is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  *****************************************************************************
23  * *
24  * For non-commercial academic use see the license specified in the file *
25  * "LICENSE-academic.txt". *
26  * *
27  *****************************************************************************
28  * *
29  * If you are interested in other licensing models, including a commercial- *
30  * license, please contact the author at michel.steuwer@uni-muenster.de *
31  * *
32  *****************************************************************************/
33 
37 
38 #include <iostream>
39 #include <iterator>
40 #include <fstream>
41 #include <string>
42 #include <sstream>
43 
44 #include <pvsutil/Logger.h>
45 
46 #include <SkelCL/detail/Program.h>
47 #include <SkelCL/detail/Util.h>
48 
49 #include "Test.h"
52 
53 class ProgramTest : public ::testing::Test {
54 protected:
55  ProgramTest() {
56  pvsutil::defaultLogger.setLoggingLevel(pvsutil::Logger::Severity::Debug);
57  }
58 
59  ~ProgramTest() {
60  }
61 };
62 
63 TEST_F(ProgramTest, RenameFunction) {
64  std::string s( "float func(float f) { return -f; }" );
65  std::string hashString(skelcl::detail::util::hash(s));
66  s += "\n";
67  s += R"(
68 
69 typedef float SCL_TYPE_0;
70 typedef float SCL_TYPE_1;
71 
72 __kernel void SCL_MAP(
73  const __global SCL_TYPE_0* SCL_IN,
74  __global SCL_TYPE_1* SCL_OUT,
75  const unsigned int SCL_ELEMENTS )
76 {
77  if (get_global_id(0) < SCL_ELEMENTS) {
78  SCL_OUT[get_global_id(0)] = SCL_FUNC(SCL_IN[get_global_id(0)]);
79  }
80 }
81 )";
82 
83  skelcl::detail::Program program(s, hashString);
84 
85  program.renameFunction("func", "SCL_FUNC");
86  program.adjustTypes<int, char>();
87  program.build();
88 }
89 
91