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
DeviceTests.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 <SkelCL/detail/Device.h>
39 
40 #include "Test.h"
43 
44 class DeviceTest : public ::testing::Test {
45 protected:
46  DeviceTest() : _platform(), _device() {
47  std::vector<cl::Platform> platforms;
48  cl::Platform::get(&platforms);
49  _platform = platforms[0];
50 
51  std::vector<cl::Device> devices;
52  _platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);
53 
54  _device = devices[0];
55  }
56 
57  ~DeviceTest() {
58  // tear down
59  }
60  cl::Platform _platform;
61  cl::Device _device;
62 };
63 
64 TEST_F(DeviceTest, CreateDevice) {
65  size_t id = 0;
66  skelcl::detail::Device device(_device, _platform, id);
67 
68  EXPECT_EQ(id, device.id()); // test id
69  EXPECT_EQ(_device(), device.clDevice()()); // test clDevice
70 
71  cl::Context context = device.clContext(); // test clContext
72  cl_int err;
73  std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>(&err);
74  EXPECT_EQ(CL_SUCCESS, err); // getInfo succeeded
75  EXPECT_EQ(1, devices.size()); // exactly one device found
76  EXPECT_EQ(device.clDevice()(), devices[0]()); // device in context is the same device
77 
78  // TODO: Test command queue
79 }
80 
82 
SKELCL_DLL detail::DeviceID device(size_t dID)
Creates an OpenCL device ID to be used as parameter of the init(detail::PlatformID, detail::DeviceID) function.
Definition: SkelCL.cpp:76