Skip to content

Commit e2906fc

Browse files
committed
Move interlockedMax to core helpers
Change-Id: I5496ea963e68e0ef1e107c860112b7123d38aa81 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent ce406c3 commit e2906fc

File tree

7 files changed

+26
-39
lines changed

7 files changed

+26
-39
lines changed

core/helpers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
set(NEO_CORE_HELPERS
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/basic_math.h
10+
${CMAKE_CURRENT_SOURCE_DIR}/interlocked_max.h
1011
${CMAKE_CURRENT_SOURCE_DIR}/vec.h
1112
)
1213

core/helpers/interlocked_max.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include <atomic>
11+
template <typename Type>
12+
void interlockedMax(std::atomic<Type> &dest, Type newVal) {
13+
Type oldVal = dest;
14+
Type maxVal = oldVal < newVal ? newVal : oldVal;
15+
while (!std::atomic_compare_exchange_weak(&dest, &oldVal, maxVal)) {
16+
oldVal = dest;
17+
maxVal = oldVal < newVal ? newVal : oldVal;
18+
}
19+
}

runtime/helpers/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ set(RUNTIME_SRCS_HELPERS_WINDOWS
100100
${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks.h
101101
${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks.inl
102102
${CMAKE_CURRENT_SOURCE_DIR}/windows/kmd_notify_properties_windows.cpp
103-
${CMAKE_CURRENT_SOURCE_DIR}/wddm_helper.h
104103
${CMAKE_CURRENT_SOURCE_DIR}/windows/gl_helper.h
105104
)
106105
set(RUNTIME_SRCS_HELPERS_LINUX

runtime/helpers/wddm_helper.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

runtime/os_interface/windows/wddm/wddm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
#include "runtime/os_interface/windows/wddm/wddm.h"
99

10+
#include "core/helpers/interlocked_max.h"
1011
#include "runtime/gmm_helper/gmm.h"
1112
#include "runtime/gmm_helper/gmm_helper.h"
1213
#include "runtime/gmm_helper/page_table_mngr.h"
1314
#include "runtime/gmm_helper/resource_info.h"
14-
#include "runtime/helpers/wddm_helper.h"
1515
#include "runtime/memory_manager/memory_manager.h"
1616
#include "runtime/os_interface/hw_info_config.h"
1717
#include "runtime/os_interface/windows/gdi_interface.h"

unit_tests/mt_tests/helpers/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#
2-
# Copyright (C) 2017-2018 Intel Corporation
2+
# Copyright (C) 2017-2019 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
66

77
set(IGDRCL_SRCS_mt_tests_helpers
88
# local files
99
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10-
${CMAKE_CURRENT_SOURCE_DIR}/wddm_helper_mt_tests.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/interlocked_max_mt_tests.cpp
1111

1212
# necessary dependencies from igdrcl_tests
1313
${IGDRCL_SOURCE_DIR}/unit_tests/helpers/base_object_tests_mt.cpp

unit_tests/mt_tests/helpers/wddm_helper_mt_tests.cpp renamed to unit_tests/mt_tests/helpers/interlocked_max_mt_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
2-
* Copyright (C) 2017-2019 Intel Corporation
2+
* Copyright (C) 2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

8-
#include "runtime/helpers/wddm_helper.h"
8+
#include "core/helpers/interlocked_max.h"
99

1010
#include "gtest/gtest.h"
1111

1212
#include <thread>
1313

14-
TEST(MtTestWddmFixture, givenCurrentPagingFenceValueWhenValueChangedThenValueIsSet) {
14+
TEST(MtTestInterlockedMaxFixture, givenCurrentPagingFenceValueWhenValueChangedThenValueIsSet) {
1515
std::atomic<uint64_t> currentPagingFenceValue;
1616
std::atomic<int> testCount;
1717
std::atomic<int> maxValue;

0 commit comments

Comments
 (0)