1 | /******************************************************************************* |
---|---|
2 | * Copyright 2019-2021 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 "tests/test_isa_common.hpp" |
18 | |
19 | #include "gtest/gtest.h" |
20 | |
21 | #include "oneapi/dnnl/dnnl.hpp" |
22 | #include "src/cpu/platform.hpp" |
23 | |
24 | namespace dnnl { |
25 | |
26 | class isa_set_once_test_t : public ::testing::Test {}; |
27 | TEST(isa_set_once_test, TestISASetOnce) { |
28 | auto st = set_max_cpu_isa(cpu_isa::sse41); |
29 | ASSERT_TRUE(st == status::success || st == status::unimplemented); |
30 | ASSERT_TRUE(mayiuse(cpu_isa::sse41)); |
31 | st = set_max_cpu_isa(cpu_isa::sse41); |
32 | ASSERT_TRUE(st == status::invalid_arguments || st == status::unimplemented); |
33 | }; |
34 | |
35 | TEST(isa_set_once_test, TestISAHintsSetOnce) { |
36 | auto st = set_cpu_isa_hints(cpu_isa_hints::prefer_ymm); |
37 | const bool unimplemented = st == status::unimplemented; |
38 | ASSERT_TRUE(unimplemented || st == status::success); |
39 | |
40 | // mayiuse should disable further changes in CPU ISA hints |
41 | ASSERT_TRUE(mayiuse(cpu_isa::sse41)); |
42 | ASSERT_TRUE(unimplemented || impl::cpu::platform::prefer_ymm_requested()); |
43 | |
44 | st = set_cpu_isa_hints(cpu_isa_hints::no_hints); |
45 | ASSERT_TRUE(unimplemented || st == status::runtime_error); |
46 | }; |
47 | } // namespace dnnl |
48 |