From d93f92f42ddab332ca416699ac2e8a3037fe2da8 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Tue, 31 Oct 2017 02:34:47 -0500 Subject: [PATCH] Make HostQueue::queue_count_ a portable atomic type. Also make lint happy. Change-Id: I0f965df6a76fd959df9eb411d1f1b11847159790 --- runtime/hsa-runtime/core/inc/host_queue.h | 2 +- runtime/hsa-runtime/core/inc/runtime.h | 4 +++- .../hsa-runtime/core/runtime/host_queue.cpp | 4 ++-- .../hsa-runtime/core/runtime/hsa_api_trace.cpp | 18 +++++++++--------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/runtime/hsa-runtime/core/inc/host_queue.h b/runtime/hsa-runtime/core/inc/host_queue.h index 9260bcff5c..2eb1e25f4c 100644 --- a/runtime/hsa-runtime/core/inc/host_queue.h +++ b/runtime/hsa-runtime/core/inc/host_queue.h @@ -166,7 +166,7 @@ class HostQueue : public Queue { // Host queue id counter, starting from 0x80000000 to avoid overlaping // with aql queue id. - static volatile uint32_t queue_count_; + static std::atomic queue_count_; DISALLOW_COPY_AND_ASSIGN(HostQueue); }; diff --git a/runtime/hsa-runtime/core/inc/runtime.h b/runtime/hsa-runtime/core/inc/runtime.h index 4bd4d2ad52..f5bbb5ac55 100644 --- a/runtime/hsa-runtime/core/inc/runtime.h +++ b/runtime/hsa-runtime/core/inc/runtime.h @@ -317,7 +317,9 @@ class Runtime { ExtensionEntryPoints extensions_; - hsa_status_t SetCustomVMFaultHandler(hsa_status_t (*callback)(const void* event_specific_data, void* data), void* data); + hsa_status_t SetCustomVMFaultHandler(hsa_status_t (*callback)(const void* event_specific_data, + void* data), + void* data); protected: static void AsyncEventsLoop(void*); diff --git a/runtime/hsa-runtime/core/runtime/host_queue.cpp b/runtime/hsa-runtime/core/runtime/host_queue.cpp index 09d579545e..31ba080171 100644 --- a/runtime/hsa-runtime/core/runtime/host_queue.cpp +++ b/runtime/hsa-runtime/core/runtime/host_queue.cpp @@ -47,7 +47,7 @@ namespace core { -volatile uint32_t HostQueue::queue_count_ = 0x80000000; +std::atomic HostQueue::queue_count_(0x80000000); HostQueue::HostQueue(hsa_region_t region, uint32_t ring_size, hsa_queue_type32_t type, uint32_t features, @@ -73,7 +73,7 @@ HostQueue::HostQueue(hsa_region_t region, uint32_t ring_size, amd_queue_.hsa_queue.base_address = ring_; amd_queue_.hsa_queue.size = size_; amd_queue_.hsa_queue.doorbell_signal = doorbell_signal; - amd_queue_.hsa_queue.id = atomic::Increment(&queue_count_); + amd_queue_.hsa_queue.id = queue_count_++; amd_queue_.hsa_queue.type = type; amd_queue_.hsa_queue.features = features; #ifdef HSA_LARGE_MODEL diff --git a/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp b/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp index 7d1e3ccbf2..f0e5f1278c 100644 --- a/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp +++ b/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp @@ -92,21 +92,21 @@ void HsaApiTable::CloneExts(void* ext_table, uint32_t table_id) { // Update HSA Extension Finalizer Api table if (table_id == HSA_EXT_FINALIZER_API_TABLE_ID) { - finalizer_api = (*(FinalizerExtTable *)ext_table); + finalizer_api = *reinterpret_cast(ext_table); hsa_api.finalizer_ext_ = &finalizer_api; return; } // Update HSA Extension Image Api table if (table_id == HSA_EXT_IMAGE_API_TABLE_ID) { - image_api = (*(ImageExtTable *)ext_table); + image_api = *reinterpret_cast(ext_table); hsa_api.image_ext_ = &image_api; return; } // Update HSA Extension AqlProfile Api table if (table_id == HSA_EXT_AQLPROFILE_API_TABLE_ID) { - aqlprofile_api = (*(AqlProfileExtTable *)ext_table); + aqlprofile_api = *reinterpret_cast(ext_table); hsa_api.aqlprofile_ext_ = &aqlprofile_api; return; } @@ -118,22 +118,22 @@ void HsaApiTable::LinkExts(void* ext_table, uint32_t table_id) { // Update HSA Extension Finalizer Api table if (table_id == HSA_EXT_FINALIZER_API_TABLE_ID) { - finalizer_api = (*(FinalizerExtTable *)ext_table); - hsa_api.finalizer_ext_ = (FinalizerExtTable *)ext_table; + finalizer_api = *reinterpret_cast(ext_table); + hsa_api.finalizer_ext_ = reinterpret_cast(ext_table); return; } // Update HSA Extension Image Api table if (table_id == HSA_EXT_IMAGE_API_TABLE_ID) { - image_api = (*(ImageExtTable *)ext_table); - hsa_api.image_ext_ = (ImageExtTable *)ext_table; + image_api = *reinterpret_cast(ext_table); + hsa_api.image_ext_ = reinterpret_cast(ext_table); return; } // Update HSA Extension AqlProfile Api table if (table_id == HSA_EXT_AQLPROFILE_API_TABLE_ID) { - aqlprofile_api = (*(AqlProfileExtTable *)ext_table); - hsa_api.aqlprofile_ext_ = (AqlProfileExtTable *)ext_table; + aqlprofile_api = *reinterpret_cast(ext_table); + hsa_api.aqlprofile_ext_ = reinterpret_cast(ext_table); return; } }