|
Packit |
345191 |
/*
|
|
Packit |
345191 |
* Copyright (c) 2019 Intel Corporation
|
|
Packit |
345191 |
*
|
|
Packit |
345191 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
345191 |
* modification, are permitted provided that the following conditions
|
|
Packit |
345191 |
* are met:
|
|
Packit |
345191 |
*
|
|
Packit |
345191 |
* * Redistributions of source code must retain the above copyright
|
|
Packit |
345191 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
345191 |
*
|
|
Packit |
345191 |
* * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
345191 |
* notice, this list of conditions and the following disclaimer in
|
|
Packit |
345191 |
* the documentation and/or other materials provided with the
|
|
Packit |
345191 |
* distribution.
|
|
Packit |
345191 |
*
|
|
Packit |
345191 |
* * Neither the name of Intel Corporation nor the names of its
|
|
Packit |
345191 |
* contributors may be used to endorse or promote products derived
|
|
Packit |
345191 |
* from this software without specific prior written permission.
|
|
Packit |
345191 |
*
|
|
Packit |
345191 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
345191 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
345191 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit |
345191 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
Packit |
345191 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
Packit |
345191 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Packit |
345191 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Packit |
345191 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Packit |
345191 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit |
345191 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LOG OF THE USE
|
|
Packit |
345191 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
345191 |
*/
|
|
Packit |
345191 |
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#include "memkind_allocator.h"
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#include <cassert>
|
|
Packit |
345191 |
#include <forward_list>
|
|
Packit |
345191 |
#include <iostream>
|
|
Packit |
345191 |
#include <scoped_allocator>
|
|
Packit |
345191 |
#include <set>
|
|
Packit |
345191 |
#include <string>
|
|
Packit |
345191 |
#include <deque>
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#define STL_FWLIST_TEST
|
|
Packit |
345191 |
#define STL_DEQUE_TEST
|
|
Packit |
345191 |
#if _GLIBCXX_USE_CXX11_ABI
|
|
Packit |
345191 |
#define STL_MULTISET_TEST
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
int main(int argc, char *argv[])
|
|
Packit |
345191 |
{
|
|
Packit |
345191 |
std::cout << "TEST SCOPE: HELLO" << std::endl;
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#ifdef STL_FWLIST_TEST
|
|
Packit |
345191 |
{
|
|
Packit |
345191 |
std::cout << "FORWARD LIST OPEN" << std::endl;
|
|
Packit |
345191 |
libmemkind::static_kind::allocator<int> alc{ libmemkind::kinds::REGULAR };
|
|
Packit |
345191 |
std::forward_list<int, libmemkind::static_kind::allocator<int>> fwlist {alc};
|
|
Packit |
345191 |
int i;
|
|
Packit |
345191 |
|
|
Packit |
345191 |
for (i = 0; i <= 20; ++i) {
|
|
Packit |
345191 |
fwlist.push_front(i);
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
|
|
Packit |
345191 |
fwlist.sort(std::greater<int>());
|
|
Packit |
345191 |
|
|
Packit |
345191 |
for(auto &el: fwlist) {
|
|
Packit |
345191 |
i--;
|
|
Packit |
345191 |
assert(el == i);
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
|
|
Packit |
345191 |
fwlist.clear();
|
|
Packit |
345191 |
|
|
Packit |
345191 |
std::cout << "FORWARD LIST CLOSE" << std::endl;
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#ifdef STL_DEQUE_TEST
|
|
Packit |
345191 |
std::cout << "DEQUE OPEN" << std::endl;
|
|
Packit |
345191 |
libmemkind::static_kind::allocator<int> int_alc{ libmemkind::kinds::REGULAR };
|
|
Packit |
345191 |
std::deque<int, libmemkind::static_kind::allocator<int>> deque {int_alc};
|
|
Packit |
345191 |
|
|
Packit |
345191 |
for (int i=0; i<10; i++) {
|
|
Packit |
345191 |
deque.push_back(i);
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
|
|
Packit |
345191 |
assert(deque.size() == 10);
|
|
Packit |
345191 |
|
|
Packit |
345191 |
while(!deque.empty()) {
|
|
Packit |
345191 |
deque.pop_front();
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
|
|
Packit |
345191 |
assert(deque.size() == 0);
|
|
Packit |
345191 |
|
|
Packit |
345191 |
std::cout << "DEQUE CLOSE" << std::endl;
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#ifdef STL_MULTISET_TEST
|
|
Packit |
345191 |
{
|
|
Packit |
345191 |
std::cout << "MULTISET OPEN" << std::endl;
|
|
Packit |
345191 |
typedef libmemkind::static_kind::allocator<std::string> multiset_alloc_t;
|
|
Packit |
345191 |
multiset_alloc_t multiset_alloc { libmemkind::kinds::DEFAULT };
|
|
Packit |
345191 |
std::multiset<std::string, std::less<std::string>, std::scoped_allocator_adaptor<multiset_alloc_t> >
|
|
Packit |
345191 |
multiset{ std::scoped_allocator_adaptor<multiset_alloc_t>(multiset_alloc) };
|
|
Packit |
345191 |
|
|
Packit |
345191 |
multiset.insert("S");
|
|
Packit |
345191 |
multiset.insert("A");
|
|
Packit |
345191 |
multiset.insert("C");
|
|
Packit |
345191 |
multiset.insert("S");
|
|
Packit |
345191 |
multiset.insert("C");
|
|
Packit |
345191 |
multiset.insert("E");
|
|
Packit |
345191 |
|
|
Packit |
345191 |
std::string test;
|
|
Packit |
345191 |
for (auto &n : multiset) {
|
|
Packit |
345191 |
test.append(n);
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
assert(test == "ACCESS");
|
|
Packit |
345191 |
|
|
Packit |
345191 |
std::cout << "MULTISET CLOSE" << std::endl;
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
std::cout << "TEST SCOPE: GOODBYE" << std::endl;
|
|
Packit |
345191 |
|
|
Packit |
345191 |
return 0;
|
|
Packit |
345191 |
}
|