Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit bdac18e

Browse files
lmorichesaleelk
authored andcommitted
Use std::atomic
Replace amd::Atomic with std::atomic. Remove make_atomic uses by converting the variable to std::atomic and making sure the memory order is relaxed when synchronizes-with is not needed. Delete utils/atomic.hpp. Change-Id: I0b36db8d604a8510ac6e36b32885fd16a1b8ccfa
1 parent 38f9e90 commit bdac18e

22 files changed

+46
-495
lines changed

device/device.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
THE SOFTWARE. */
2020

2121
#include "device/device.hpp"
22-
#include "thread/atomic.hpp"
2322
#include "thread/monitor.hpp"
2423
#include "utils/options.hpp"
2524
#include "comgrctx.hpp"

device/devprogram.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "comgrctx.hpp"
3131

3232
#include <algorithm>
33+
#include <atomic>
3334
#include <cstdio>
3435
#include <fstream>
3536
#include <iostream>
@@ -1345,7 +1346,7 @@ bool Program::initBuild(amd::option::Options* options) {
13451346
programOptions_ = options;
13461347

13471348
if (options->oVariables->DumpFlags > 0) {
1348-
static amd::Atomic<unsigned> build_num = 0;
1349+
static std::atomic<uint> build_num{0};
13491350
options->setBuildNo(build_num++);
13501351
}
13511352
buildLog_.clear();

device/gpu/gpudevice.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "device/gpu/gpusettings.hpp"
3838
#include "device/gpu/gpuappprofile.hpp"
3939

40+
#include <atomic>
4041

4142
#include "acl.h"
4243
#include "vaminterface.h"
@@ -316,7 +317,7 @@ class Device : public NullDevice, public CALGSLDevice {
316317
Resource::MemoryType type_; //!< The buffer's type
317318
size_t bufSize_; //!< Staged buffer size
318319
std::list<Memory*> freeBuffers_; //!< The list of free buffers
319-
amd::Atomic<uint> acquiredCnt_; //!< The total number of acquired buffers
320+
std::atomic<uint> acquiredCnt_; //!< The total number of acquired buffers
320321
amd::Monitor lock_; //!< Staged buffer acquire/release lock
321322
const Device& gpuDevice_; //!< GPU device object
322323
};

device/gpu/gpumemory.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#define GPUMEMORY_HPP_
2323

2424
#include "top.hpp"
25-
#include "thread/atomic.hpp"
2625
#include "device/gpu/gpuresource.hpp"
2726
#include <map>
2827

device/gpu/gpuresource.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "device/gpu/gpudevice.hpp"
3535
#include "device/gpu/gpublit.hpp"
3636
#include "device/gpu/gputimestamp.hpp"
37-
#include "thread/atomic.hpp"
3837
#include "hsa_ext_image.h"
3938

4039
#include <string>

device/gpu/gpuresource.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "platform/program.hpp"
2626
#include "device/gpu/gpudefs.hpp"
2727

28+
#include <atomic>
29+
2830
//! \namespace gpu GPU Resource Implementation
2931
namespace gpu {
3032

@@ -412,7 +414,7 @@ class Resource : public amd::HeapObject {
412414

413415
const Device& gpuDevice_; //!< GPU device
414416
CalResourceDesc cal_; //!< CAL descriptor for this resource
415-
amd::Atomic<int> mapCount_; //!< Total number of maps
417+
std::atomic<int> mapCount_; //!< Total number of maps
416418
void* address_; //!< Physical address of this resource
417419
size_t offset_; //!< Resource offset
418420
size_t curRename_; //!< Current active rename in the list

device/pal/paldevice.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "acl.h"
4040
#include "memory"
4141

42+
#include <atomic>
4243
#include <unordered_set>
4344

4445
/*! \addtogroup PAL
@@ -258,7 +259,7 @@ class Device : public NullDevice {
258259
Resource::MemoryType type_; //!< The buffer's type
259260
size_t bufSize_; //!< Staged buffer size
260261
std::list<Memory*> freeBuffers_; //!< The list of free buffers
261-
amd::Atomic<uint> acquiredCnt_; //!< The total number of acquired buffers
262+
std:atomic<uint> acquiredCnt_; //!< The total number of acquired buffers
262263
amd::Monitor lock_; //!< Stgaed buffer acquire/release lock
263264
const Device& gpuDevice_; //!< GPU device object
264265
};

device/pal/palmemory.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#pragma once
2222

2323
#include "top.hpp"
24-
#include "thread/atomic.hpp"
2524
#include "device/pal/palresource.hpp"
2625
#include <map>
2726

device/pal/palresource.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "device/pal/paldevice.hpp"
2929
#include "device/pal/palblit.hpp"
3030
#include "device/pal/paltimestamp.hpp"
31-
#include "thread/atomic.hpp"
3231
#include "hsa_ext_image.h"
3332
#ifdef _WIN32
3433
#include <d3d10_1.h>

device/pal/palresource.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "device/pal/paldefs.hpp"
2626
#include "util/palBuddyAllocatorImpl.h"
2727

28+
#include <atomic>
2829
#include <unordered_map>
2930

3031
//! \namespace pal PAL Resource Implementation
@@ -479,7 +480,7 @@ class Resource : public amd::HeapObject {
479480

480481
const Device& gpuDevice_; //!< GPU device
481482
Descriptor desc_; //!< Descriptor for this resource
482-
amd::Atomic<int> mapCount_; //!< Total number of maps
483+
std::atomic<int> mapCount_; //!< Total number of maps
483484
void* address_; //!< Physical address of this resource
484485
size_t offset_; //!< Resource offset
485486
GpuMemoryReference* memRef_; //!< PAL resource reference

0 commit comments

Comments
 (0)