This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of mutex support and some drive-by fixes
- Loading branch information
Showing
10 changed files
with
347 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "std/mutex" | ||
|
||
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA | ||
|
||
template<thread_scope _Sco> | ||
using mutex = _CUDA_VSTD::__mutex_base<_Sco>; | ||
|
||
template<thread_scope _Sco> | ||
using timed_mutex = _CUDA_VSTD::__mutex_base<_Sco>; | ||
|
||
template<thread_scope _Sco> | ||
using once_flag = _CUDA_VSTD::__once_flag_base<_Sco>; | ||
|
||
using _CUDA_VSTD::call_once; | ||
|
||
_LIBCUDACXX_END_NAMESPACE_CUDA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
include/cuda/std/detail/libcxx/include/__memory/atomic_load.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCUDACXX___MEMORY_ATOMIMC_LOAD_H | ||
#define _LIBCUDACXX___MEMORY_ATOMIMC_LOAD_H | ||
|
||
#ifndef __cuda_std__ | ||
#include <__config> | ||
#endif //__cuda_std__ | ||
|
||
#include "../atomic" | ||
|
||
#if defined(_LIBCUDACXX_USE_PRAGMA_GCC_SYSTEM_HEADER) | ||
#pragma GCC system_header | ||
#endif | ||
|
||
_LIBCUDACXX_BEGIN_NAMESPACE_STD | ||
|
||
#ifndef __cuda_std__ | ||
|
||
template <class _ValueType> | ||
inline _LIBCUDACXX_INLINE_VISIBILITY | ||
_ValueType __libcpp_relaxed_load(_ValueType const* __value) { | ||
#if !defined(_LIBCUDACXX_HAS_NO_THREADS) && \ | ||
defined(__ATOMIC_RELAXED) && \ | ||
(__has_builtin(__atomic_load_n) || defined(_LIBCUDACXX_COMPILER_GCC)) | ||
return __atomic_load_n(__value, __ATOMIC_RELAXED); | ||
#else | ||
return *__value; | ||
#endif | ||
} | ||
|
||
template <class _ValueType> | ||
inline _LIBCUDACXX_INLINE_VISIBILITY | ||
_ValueType __libcpp_acquire_load(_ValueType const* __value) { | ||
#if !defined(_LIBCUDACXX_HAS_NO_THREADS) && \ | ||
defined(__ATOMIC_ACQUIRE) && \ | ||
(__has_builtin(__atomic_load_n) || defined(_LIBCUDACXX_COMPILER_GCC)) | ||
return __atomic_load_n(__value, __ATOMIC_ACQUIRE); | ||
#else | ||
return *__value; | ||
#endif | ||
} | ||
|
||
#else | ||
|
||
template <class _ValueType> | ||
inline _LIBCUDACXX_INLINE_VISIBILITY | ||
_ValueType __libcpp_relaxed_load(atomic<_ValueType> const* __value) { | ||
return __value->load(memory_order_relaxed); | ||
} | ||
|
||
template <class _ValueType> | ||
inline _LIBCUDACXX_INLINE_VISIBILITY | ||
_ValueType __libcpp_acquire_load(atomic<_ValueType> const* __value) { | ||
return __value->load(memory_order_acquire); | ||
} | ||
#endif // __cuda_std__ | ||
|
||
_LIBCUDACXX_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCUDACXX___MEMORY_ATOMIMC_LOAD_H |
Oops, something went wrong.