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#include "harness_defs.h"
18
19#if __TBB_TEST_SKIP_AFFINITY
20#define HARNESS_NO_PARSE_COMMAND_LINE 1
21#include "harness.h"
22int TestMain() {
23 return Harness::Skipped;
24}
25#else /* affinity mask can be set and used by TBB */
26
27#include "harness.h"
28#include "harness_concurrency.h"
29
30#include "tbb/task_scheduler_init.h"
31#include "tbb/tbb_thread.h"
32#include "tbb/enumerable_thread_specific.h"
33
34// The declaration of a global ETS object is needed to check that
35// it does not initialize the task scheduler, and in particular
36// does not set the default thread number. TODO: add other objects
37// that should not initialize the scheduler.
38tbb::enumerable_thread_specific<std::size_t> ets;
39
40int TestMain () {
41 int maxProcs = Harness::GetMaxProcs();
42
43 if ( maxProcs < 2 )
44 return Harness::Skipped;
45
46 int availableProcs = maxProcs/2;
47 ASSERT( Harness::LimitNumberOfThreads( availableProcs ) == availableProcs, "LimitNumberOfThreads has not set the requested limitation." );
48 ASSERT( tbb::task_scheduler_init::default_num_threads() == availableProcs, NULL );
49 ASSERT( (int)tbb::tbb_thread::hardware_concurrency() == availableProcs, NULL );
50 return Harness::Done;
51}
52#endif /* __TBB_TEST_SKIP_AFFINITY */
53