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
IndexVectorTests.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 <pvsutil/Logger.h>
39 
40 #include <SkelCL/Distributions.h>
41 #include <SkelCL/SkelCL.h>
42 #include <SkelCL/IndexVector.h>
43 #include <SkelCL/Map.h>
44 
45 #include "Test.h"
48 
49 class IndexVectorTest : public ::testing::Test {
50 protected:
51  IndexVectorTest() {
52  pvsutil::defaultLogger.setLoggingLevel(pvsutil::Logger::Severity::Debug);
54  }
55 
56  ~IndexVectorTest() {
58  }
59 };
60 
61 TEST_F(IndexVectorTest, CreateIndexVector) {
63 
64  EXPECT_EQ(1024, vi.size());
65  EXPECT_EQ(0, vi.front());
66  EXPECT_EQ(1023, vi.back());
67 }
68 
69 TEST_F(IndexVectorTest, SimpleVoidMap) {
70  skelcl::IndexVector index(1024);
71  skelcl::Map<void(skelcl::Index)> m("void func(Index i, __global int* out) { out[i] = i; }");
72  EXPECT_EQ(1024, index.size());
73 
74  skelcl::Vector<int> v(1024);
75 
76  m(index, skelcl::out(v));
77 
78  EXPECT_EQ(index.size(), v.size());
79  for (size_t i = 0; i < v.size(); ++i) {
80  EXPECT_EQ(i, v[i]);
81  }
82 }
83 
84 TEST_F(IndexVectorTest, SimpleMap) {
85  skelcl::IndexVector index(1023);
86  skelcl::Map<int(skelcl::Index)> m("int func(Index i) { return i; }");
87  EXPECT_EQ(1023, index.size());
88 
89  auto v = m(index);
90 
91  EXPECT_EQ(index.size(), v.size());
92  for (size_t i = 0; i < v.size(); ++i) {
93  EXPECT_EQ(i, v[i]);
94  }
95 }
96 
98 
Out< ContainerType< T > > out(ContainerType< T > &c)
Helper function to create a Out wrapper object.
Definition: Out.h:94
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
The IndexVector (a.k.a. Vector) class is a special implementation of a Vector with Elements of...
Definition: IndexVector.h:72