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
ScanTests.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 <fstream>
39 
40 #include <cstdio>
41 
42 #include <pvsutil/Logger.h>
43 
44 #include <SkelCL/SkelCL.h>
45 #include <SkelCL/Vector.h>
46 #include <SkelCL/Scan.h>
47 
48 #include "Test.h"
51 
52 class ScanTest : public ::testing::Test {
53 protected:
54  ScanTest() {
55  pvsutil::defaultLogger.setLoggingLevel(
56  pvsutil::Logger::Severity::DebugInfo );
57 
59  }
60 
61  ~ScanTest() {
63  }
64 };
65 
66 TEST_F(ScanTest, CreateScanWithString) {
67  skelcl::Scan<float(float)> s{ "float func(float x, float y){ return x+y; }",
68  "0.0f" };
69 }
70 
71 TEST_F(ScanTest, SimpleScan) {
72  skelcl::Scan<int(int)> s{ "int func(int x, int y){ return x+y; }" };
73 
74  skelcl::Vector<int> input(1024);
75  for (size_t i = 0; i < input.size(); ++i) {
76  input[i] = 1;
77  }
78  EXPECT_EQ(1024, input.size());
79 
80  skelcl::Vector<int> output = s(input);
81 
82  input.dataOnDeviceModified();
83 
84  EXPECT_EQ(1024, output.size());
85  for (size_t i = 0; i < output.size(); ++i) {
86  EXPECT_EQ(i, output[i]);
87  }
88 }
89 
90 TEST_F(ScanTest, SmallScan) {
91  skelcl::Scan<int(int)> s{ "int func(int x, int y){ return x+y; }" };
92 
93  skelcl::Vector<int> input(10);
94  for (size_t i = 0; i < input.size(); ++i) {
95  input[i] = 1;
96  }
97  EXPECT_EQ(10, input.size());
98 
99  skelcl::Vector<int> output = s(input);
100 
101  input.dataOnDeviceModified();
102 
103  EXPECT_EQ(10, output.size());
104  for (size_t i = 0; i < output.size(); ++i) {
105  EXPECT_EQ(i, output[i]);
106  }
107 }
108 
110 
SKELCL_DLL void init(detail::DeviceProperties properties=allDevices())
Initializes the SkelCL library. This function (or another init function) has to be called prior to ev...
Definition: SkelCL.cpp:51
SKELCL_DLL detail::DeviceProperties nDevices(size_t n)
Creates a detail::DeviceProperties object representing n devices. This object should be used as param...
Definition: SkelCL.cpp:66
The Vector class is a one dimensional container which makes its data accessible on the host as well a...
Definition: Vector.h:113
SKELCL_DLL void terminate()
Frees all resources allocated internally by SkelCL.
Definition: SkelCL.cpp:81