| 1 | /* | 
|---|
| 2 | Copyright (c) 2005-2019 Intel Corporation | 
|---|
| 3 |  | 
|---|
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); | 
|---|
| 5 | you may not use this file except in compliance with the License. | 
|---|
| 6 | You may obtain a copy of the License at | 
|---|
| 7 |  | 
|---|
| 8 | http://www.apache.org/licenses/LICENSE-2.0 | 
|---|
| 9 |  | 
|---|
| 10 | Unless required by applicable law or agreed to in writing, software | 
|---|
| 11 | distributed under the License is distributed on an "AS IS" BASIS, | 
|---|
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|---|
| 13 | See the License for the specific language governing permissions and | 
|---|
| 14 | limitations under the License. | 
|---|
| 15 | */ | 
|---|
| 16 |  | 
|---|
| 17 | // Test whether scalable_allocator works with some of the host's STL containers. | 
|---|
| 18 |  | 
|---|
| 19 | #define HARNESS_NO_PARSE_COMMAND_LINE 1 | 
|---|
| 20 | #define  1 // enables additional checks | 
|---|
| 21 | #define TBB_PREVIEW_MEMORY_POOL 1 | 
|---|
| 22 |  | 
|---|
| 23 | #include "harness_assert.h" | 
|---|
| 24 | #include "tbb/memory_pool.h" | 
|---|
| 25 | #include "tbb/scalable_allocator.h" | 
|---|
| 26 | #include <iostream> | 
|---|
| 27 |  | 
|---|
| 28 | // The actual body of the test is there: | 
|---|
| 29 | #include "test_allocator_STL.h" | 
|---|
| 30 |  | 
|---|
| 31 | int TestMain () { | 
|---|
| 32 | TestAllocatorWithSTL<tbb::scalable_allocator<void> >(); | 
|---|
| 33 | tbb::memory_pool<tbb::scalable_allocator<int> > mpool; | 
|---|
| 34 | TestAllocatorWithSTL(tbb::memory_pool_allocator<void>(mpool) ); | 
|---|
| 35 | static char buf[1024*1024*4]; | 
|---|
| 36 | tbb::fixed_pool fpool(buf, sizeof(buf)); | 
|---|
| 37 | TestAllocatorWithSTL(tbb::memory_pool_allocator<void>(fpool) ); | 
|---|
| 38 |  | 
|---|
| 39 | #if __TBB_CPP17_MEMORY_RESOURCE_PRESENT | 
|---|
| 40 | ASSERT(!tbb::scalable_memory_resource()->is_equal(*std::pmr::get_default_resource()), | 
|---|
| 41 | "Scalable resource shouldn't be equal to standard resource."); | 
|---|
| 42 | ASSERT(tbb::scalable_memory_resource()->is_equal(*tbb::scalable_memory_resource()), | 
|---|
| 43 | "Memory that was allocated by one scalable resource should be deallocated by any other instance."); | 
|---|
| 44 |  | 
|---|
| 45 | typedef std::pmr::polymorphic_allocator<void> pmr_alloc_t; | 
|---|
| 46 | TestAllocatorWithSTL(pmr_alloc_t(tbb::scalable_memory_resource())); | 
|---|
| 47 | #endif | 
|---|
| 48 |  | 
|---|
| 49 | return Harness::Done; | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|