3607d18592
ECR #333756 - Merge oclutils from runtime. Also updates temp file handling code to use pid/atomic which should fix Bug 10793. Note, changed the functions to use different prefix to avoid clash with runtime code. Reviewed by: Laurent Morichetti Testing: smoke, pre-checkin Affected files ... ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/os/alloc.cpp#2 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/os/os.cpp#5 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/os/os.hpp#6 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/os/os_posix.cpp#10 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/os/os_win32.cpp#5 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/thread/atomic.hpp#4 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/thread/monitor.cpp#2 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/thread/monitor.hpp#2 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/thread/semaphore.cpp#2 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/thread/semaphore.hpp#3 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/thread/thread.cpp#3 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/thread/thread.hpp#3 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/utils/debug.hpp#2 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/utils/macros.hpp#3 integrate ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/utils/traits.hpp#2 delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/promotions/oclutils/utils/util.hpp#2 integrate
66 lines
1.1 KiB
C++
66 lines
1.1 KiB
C++
//
|
|
// Copyright (c) 2008,2010 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
|
|
#ifndef SEMAPHORE_HPP_
|
|
#define SEMAPHORE_HPP_
|
|
|
|
#include "top.hpp"
|
|
#include "utils/util.hpp"
|
|
|
|
#include <atomic>
|
|
#if defined(__linux__)
|
|
# include <semaphore.h>
|
|
#endif /*linux*/
|
|
|
|
|
|
namespace amd {
|
|
|
|
/*! \addtogroup Threads
|
|
* @{
|
|
*
|
|
* \addtogroup Synchronization
|
|
* @{
|
|
*/
|
|
|
|
class Thread;
|
|
|
|
//! \brief Counting semaphore
|
|
class Semaphore : public HeapObject
|
|
{
|
|
private:
|
|
std::atomic_int state_; //!< This semaphore's value.
|
|
|
|
#ifdef _WIN32
|
|
void* handle_; //!< The semaphore object's handle.
|
|
char padding_[64-sizeof(void*)-sizeof(std::atomic_int)];
|
|
#else // !_WIN32
|
|
sem_t sem_; //!< The semaphore object's identifier.
|
|
char padding_[64-sizeof(sem_t)-sizeof(std::atomic_int)];
|
|
#endif /*!_WIN32*/
|
|
|
|
public:
|
|
Semaphore();
|
|
~Semaphore();
|
|
|
|
//! \brief Decrement this semaphore
|
|
void wait();
|
|
|
|
//! \brief Increment this semaphore
|
|
void post();
|
|
|
|
//! \brief Reset this semaphore.
|
|
void reset()
|
|
{
|
|
state_.store(0, std::memory_order_release);
|
|
}
|
|
};
|
|
|
|
/*! @}
|
|
* @}
|
|
*/
|
|
|
|
} // namespace amd
|
|
|
|
#endif /*SEMAPHORE_HPP_*/
|