2019-04-25 14:45:17 +02:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2023-01-17 20:25:40 +01:00
|
|
|
#ifndef INC_PLATFORM_H
|
|
|
|
#define INC_PLATFORM_H
|
2019-04-25 14:45:17 +02:00
|
|
|
|
2021-05-10 14:36:41 +02:00
|
|
|
DECLSPEC u32 hc_atomic_dec (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_inc (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_or (volatile GLOBAL_AS u32 *p, volatile const u32 val);
|
|
|
|
|
2019-06-20 10:04:31 +02:00
|
|
|
#ifdef IS_AMD
|
2021-04-20 17:47:44 +02:00
|
|
|
DECLSPEC u32 hc_atomic_dec (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_inc (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_or (volatile GLOBAL_AS u32 *p, volatile const u32 val);
|
|
|
|
|
2019-06-20 10:04:31 +02:00
|
|
|
DECLSPEC u64x rotl64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64x rotr64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64 rotl64_S (const u64 a, const int n);
|
|
|
|
DECLSPEC u64 rotr64_S (const u64 a, const int n);
|
2022-02-04 19:54:00 +01:00
|
|
|
#endif // IS_AMD
|
2019-06-20 10:04:31 +02:00
|
|
|
|
2021-07-11 12:38:59 +02:00
|
|
|
#ifdef IS_CUDA
|
2021-04-20 17:47:44 +02:00
|
|
|
DECLSPEC u32 hc_atomic_dec (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_inc (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_or (volatile GLOBAL_AS u32 *p, volatile const u32 val);
|
|
|
|
|
2019-04-25 14:45:17 +02:00
|
|
|
DECLSPEC size_t get_global_id (const u32 dimindx __attribute__((unused)));
|
|
|
|
DECLSPEC size_t get_local_id (const u32 dimindx __attribute__((unused)));
|
|
|
|
DECLSPEC size_t get_local_size (const u32 dimindx __attribute__((unused)));
|
|
|
|
|
2019-05-08 20:42:46 +02:00
|
|
|
DECLSPEC u32x rotl32 (const u32x a, const int n);
|
|
|
|
DECLSPEC u32x rotr32 (const u32x a, const int n);
|
|
|
|
DECLSPEC u32 rotl32_S (const u32 a, const int n);
|
|
|
|
DECLSPEC u32 rotr32_S (const u32 a, const int n);
|
|
|
|
DECLSPEC u64x rotl64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64x rotr64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64 rotl64_S (const u64 a, const int n);
|
|
|
|
DECLSPEC u64 rotr64_S (const u64 a, const int n);
|
2019-05-06 14:34:16 +02:00
|
|
|
|
2023-07-22 16:02:47 +02:00
|
|
|
//#define rotate(a,n) (((a) << (n)) | ((a) >> (32 - (n))))
|
2021-07-11 12:38:59 +02:00
|
|
|
#define bitselect(a,b,c) ((a) ^ ((c) & ((b) ^ (a))))
|
2022-02-04 19:54:00 +01:00
|
|
|
#endif // IS_CUDA
|
2021-07-10 21:34:09 +02:00
|
|
|
|
2021-07-11 12:38:59 +02:00
|
|
|
#ifdef IS_HIP
|
|
|
|
DECLSPEC u32 hc_atomic_dec (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_inc (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_or (volatile GLOBAL_AS u32 *p, volatile const u32 val);
|
|
|
|
|
2021-07-19 20:24:30 +02:00
|
|
|
DECLSPEC size_t get_global_id (const u32 dimindx);
|
|
|
|
DECLSPEC size_t get_local_id (const u32 dimindx);
|
|
|
|
DECLSPEC size_t get_local_size (const u32 dimindx);
|
2021-07-11 12:38:59 +02:00
|
|
|
|
|
|
|
DECLSPEC u32x rotl32 (const u32x a, const int n);
|
|
|
|
DECLSPEC u32x rotr32 (const u32x a, const int n);
|
|
|
|
DECLSPEC u32 rotl32_S (const u32 a, const int n);
|
|
|
|
DECLSPEC u32 rotr32_S (const u32 a, const int n);
|
|
|
|
DECLSPEC u64x rotl64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64x rotr64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64 rotl64_S (const u64 a, const int n);
|
|
|
|
DECLSPEC u64 rotr64_S (const u64 a, const int n);
|
|
|
|
|
|
|
|
//#define rotate(a,n) (((a) << (n)) | ((a) >> (32 - (n))))
|
2019-04-25 14:45:17 +02:00
|
|
|
#define bitselect(a,b,c) ((a) ^ ((c) & ((b) ^ (a))))
|
2022-02-04 19:54:00 +01:00
|
|
|
#endif // IS_HIP
|
|
|
|
|
|
|
|
#ifdef IS_METAL
|
|
|
|
|
|
|
|
DECLSPEC u32 hc_atomic_dec (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_inc (volatile GLOBAL_AS u32 *p);
|
|
|
|
DECLSPEC u32 hc_atomic_or (volatile GLOBAL_AS u32 *p, volatile const u32 val);
|
|
|
|
|
|
|
|
#define get_global_id(param) hc_gid
|
|
|
|
#define get_local_id(param) hc_lid
|
|
|
|
#define get_local_size(param) hc_lsz
|
|
|
|
|
|
|
|
DECLSPEC u32x rotl32 (const u32x a, const int n);
|
|
|
|
DECLSPEC u32x rotr32 (const u32x a, const int n);
|
|
|
|
DECLSPEC u32 rotl32_S (const u32 a, const int n);
|
|
|
|
DECLSPEC u32 rotr32_S (const u32 a, const int n);
|
|
|
|
DECLSPEC u64x rotl64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64x rotr64 (const u64x a, const int n);
|
|
|
|
DECLSPEC u64 rotl64_S (const u64 a, const int n);
|
|
|
|
DECLSPEC u64 rotr64_S (const u64 a, const int n);
|
|
|
|
|
|
|
|
#define bitselect(a,b,c) ((a) ^ ((c) & ((b) ^ (a))))
|
|
|
|
#endif // IS_METAL
|
2019-04-25 14:45:17 +02:00
|
|
|
|
2023-01-17 20:25:40 +01:00
|
|
|
#endif // INC_PLATFORM_H
|