Merge branch 'master' into tex_unbind_issue_fix
[ROCm/clr commit: 9332a39838]
This commit is contained in:
@@ -58,15 +58,15 @@ inline
|
||||
float atomicAdd(float* address, float val)
|
||||
{
|
||||
unsigned int* uaddr{reinterpret_cast<unsigned int*>(address)};
|
||||
unsigned int old{__atomic_load_n(uaddr, __ATOMIC_RELAXED)};
|
||||
unsigned int r{__atomic_load_n(uaddr, __ATOMIC_RELAXED)};
|
||||
|
||||
unsigned int r;
|
||||
unsigned int old;
|
||||
do {
|
||||
r = __atomic_load_n(uaddr, __ATOMIC_RELAXED);
|
||||
old = __atomic_load_n(uaddr, __ATOMIC_RELAXED);
|
||||
|
||||
if (r != old) { r = old; continue; }
|
||||
|
||||
old = atomicCAS(uaddr, r, __float_as_uint(val + __uint_as_float(r)));
|
||||
r = atomicCAS(uaddr, r, __float_as_uint(val + __uint_as_float(r)));
|
||||
|
||||
if (r == old) break;
|
||||
} while (true);
|
||||
@@ -78,15 +78,15 @@ inline
|
||||
double atomicAdd(double* address, double val)
|
||||
{
|
||||
unsigned long long* uaddr{reinterpret_cast<unsigned long long*>(address)};
|
||||
unsigned long long old{__atomic_load_n(uaddr, __ATOMIC_RELAXED)};
|
||||
unsigned long long r{__atomic_load_n(uaddr, __ATOMIC_RELAXED)};
|
||||
|
||||
unsigned long long r;
|
||||
unsigned long long old;
|
||||
do {
|
||||
r = __atomic_load_n(uaddr, __ATOMIC_RELAXED);
|
||||
old = __atomic_load_n(uaddr, __ATOMIC_RELAXED);
|
||||
|
||||
if (r != old) { r = old; continue; }
|
||||
|
||||
old = atomicCAS(
|
||||
r = atomicCAS(
|
||||
uaddr, r, __double_as_longlong(val + __longlong_as_double(r)));
|
||||
|
||||
if (r == old) break;
|
||||
@@ -140,13 +140,13 @@ __device__
|
||||
inline
|
||||
int atomicMin(int* address, int val)
|
||||
{
|
||||
return __sync_fetch_and_min(address, val);
|
||||
return __atomic_fetch_min(address, val, __ATOMIC_RELAXED);
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
unsigned int atomicMin(unsigned int* address, unsigned int val)
|
||||
{
|
||||
return __sync_fetch_and_umin(address, val);
|
||||
return __atomic_fetch_min(address, val, __ATOMIC_RELAXED);
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
@@ -169,13 +169,13 @@ __device__
|
||||
inline
|
||||
int atomicMax(int* address, int val)
|
||||
{
|
||||
return __sync_fetch_and_max(address, val);
|
||||
return __atomic_fetch_max(address, val, __ATOMIC_RELAXED);
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
unsigned int atomicMax(unsigned int* address, unsigned int val)
|
||||
{
|
||||
return __sync_fetch_and_umax(address, val);
|
||||
return __atomic_fetch_max(address, val, __ATOMIC_RELAXED);
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
|
||||
@@ -2063,6 +2063,45 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const
|
||||
hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset,
|
||||
size_t count, hipMemcpyKind kind);
|
||||
|
||||
/**
|
||||
* @brief Copies data between host and device.
|
||||
*
|
||||
* @param[in] dst Destination memory address
|
||||
* @param[in] dpitch Pitch of destination memory
|
||||
* @param[in] src Source memory address
|
||||
* @param[in] wOffset Source starting X offset
|
||||
* @param[in] hOffset Source starting Y offset
|
||||
* @param[in] width Width of matrix transfer (columns in bytes)
|
||||
* @param[in] height Height of matrix transfer (rows)
|
||||
* @param[in] kind Type of transfer
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue,
|
||||
* #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
|
||||
*
|
||||
* @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol,
|
||||
* hipMemcpyAsync
|
||||
*/
|
||||
hipError_t hipMemcpy2DFromArray( void* dst, size_t dpitch, hipArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, hipMemcpyKind kind);
|
||||
|
||||
/**
|
||||
* @brief Copies data between host and device asynchronously.
|
||||
*
|
||||
* @param[in] dst Destination memory address
|
||||
* @param[in] dpitch Pitch of destination memory
|
||||
* @param[in] src Source memory address
|
||||
* @param[in] wOffset Source starting X offset
|
||||
* @param[in] hOffset Source starting Y offset
|
||||
* @param[in] width Width of matrix transfer (columns in bytes)
|
||||
* @param[in] height Height of matrix transfer (rows)
|
||||
* @param[in] kind Type of transfer
|
||||
* @param[in] stream Accelerator view which the copy is being enqueued
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue,
|
||||
* #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
|
||||
*
|
||||
* @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol,
|
||||
* hipMemcpyAsync
|
||||
*/
|
||||
hipError_t hipMemcpy2DFromArrayAsync( void* dst, size_t dpitch, hipArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream __dparm(0));
|
||||
|
||||
/**
|
||||
* @brief Copies data between host and device.
|
||||
*
|
||||
|
||||
@@ -44,18 +44,35 @@ THE SOFTWARE.
|
||||
__attribute__((vector_size(__ROUND_UP_TO_NEXT_POT__(n) * sizeof(T))))
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if defined(__cplusplus) && defined(__clang__)
|
||||
#include <type_traits>
|
||||
|
||||
namespace hip_impl {
|
||||
template<typename T, typename Vector, unsigned int idx>
|
||||
struct Scalar_accessor {
|
||||
struct Address {
|
||||
const Scalar_accessor* p;
|
||||
|
||||
__host__ __device__
|
||||
operator const T*() const noexcept {
|
||||
return &reinterpret_cast<const T*>(p)[idx];
|
||||
}
|
||||
__host__ __device__
|
||||
operator T*() noexcept {
|
||||
return &reinterpret_cast<T*>(
|
||||
const_cast<Scalar_accessor*>(p))[idx];
|
||||
}
|
||||
};
|
||||
|
||||
// Idea from https://t0rakka.silvrback.com/simd-scalar-accessor
|
||||
Vector data;
|
||||
|
||||
__host__ __device__
|
||||
operator T() const noexcept { return data[idx]; }
|
||||
|
||||
__host__ __device__
|
||||
Address operator&() const noexcept { return Address{this}; }
|
||||
|
||||
__host__ __device__
|
||||
Scalar_accessor& operator=(T x) noexcept {
|
||||
data[idx] = x;
|
||||
@@ -63,6 +80,29 @@ THE SOFTWARE.
|
||||
return *this;
|
||||
}
|
||||
|
||||
__host__ __device__
|
||||
Scalar_accessor& operator++() noexcept {
|
||||
++data[idx];
|
||||
return *this;
|
||||
}
|
||||
__host__ __device__
|
||||
T operator++(int) noexcept {
|
||||
auto r{data[idx]};
|
||||
++data[idx];
|
||||
return *this;
|
||||
}
|
||||
__host__ __device__
|
||||
Scalar_accessor& operator--() noexcept {
|
||||
--data[idx];
|
||||
return *this;
|
||||
}
|
||||
__host__ __device__
|
||||
T operator--(int) noexcept {
|
||||
auto r{data[idx]};
|
||||
--data[idx];
|
||||
return *this;
|
||||
}
|
||||
|
||||
__host__ __device__
|
||||
Scalar_accessor& operator+=(T x) noexcept {
|
||||
data[idx] += x;
|
||||
|
||||
مرجع در شماره جدید
Block a user