2 // Copyright 2016-2018 Intel Corporation.
4 // This software and the related documents are Intel copyrighted materials,
5 // and your use of them is governed by the express license under which they
6 // were provided to you (End User License Agreement for the Intel(R) Software
7 // Development Products (Version May 2017)). Unless the License provides
8 // otherwise, you may not use, modify, copy, publish, distribute, disclose or
9 // transmit this software or the related documents without Intel's prior
10 // written permission.
12 // This software and the related documents are provided as is, with no
13 // express or implied warranties, other than those that are expressly
14 // stated in the License.
17 #include "gna_plugin/gna_allocator.hpp"
22 #include <gtest/gtest.h>
23 #include "gna_plugin/gna_device.hpp"
24 //dummy definitions to work around issue with Linux userspace library
25 typedef unsigned long long time_tsc;
28 time_tsc start; // time value on profiler start
29 time_tsc stop; // time value on profiler stop
30 time_tsc passed; // time passed between start and stop
31 } intel_gna_profiler_tsc;
33 void profilerTscStop(intel_gna_profiler_tsc* p) {
34 if (NULL == p) return;
39 void profilerTscStartAccumulate(intel_gna_profiler_tsc* p)
41 if (NULL == p) return;
45 void profilerTscStopAccumulate(intel_gna_profiler_tsc* p)
47 if (NULL == p) return;
49 p->passed += p->stop - p->start;
52 class GNAAllocatorTest : public ::testing::Test {
55 std::unique_ptr<GNADeviceHelper> gnadevice;
56 void SetUp() override {
57 // gnadevice.reset(new GNADeviceHelper());
61 TEST_F(GNAAllocatorTest, canAllocateStdMemory) {
62 auto sp = make_polymorph<std::allocator<uint8_t>>();
64 ASSERT_NO_THROW(x = sp.allocate(100));
65 ASSERT_NE(x, nullptr);
66 ASSERT_NO_THROW(sp.deallocate(x, 100));
69 TEST_F(GNAAllocatorTest, canAllocateGNAMemory) {
70 //GNA device can be opened one per process for now
71 gnadevice.reset(new GNADeviceHelper());
72 auto sp = make_polymorph<GNAAllocator>(*gnadevice.get());
74 ASSERT_NO_THROW(x = sp.allocate(100));
75 ASSERT_NE(x, nullptr);
76 ASSERT_NO_THROW(sp.deallocate(x, 100));
79 TEST_F(GNAAllocatorTest, DISABLED_canOpenDevice) {