@@ -1235,6 +1235,10 @@ MIN_MAX_COMPXCHG(float8, max, kmp_real64, 64, <, 8r, 7,
1235
1235
KMP_ARCH_X86) // __kmpc_atomic_float8_max
1236
1236
MIN_MAX_COMPXCHG(float8, min, kmp_real64, 64 , >, 8r, 7 ,
1237
1237
KMP_ARCH_X86) // __kmpc_atomic_float8_min
1238
+ MIN_MAX_CRITICAL(float10, max, long double , <, 10r,
1239
+ 1 ) // __kmpc_atomic_float10_max
1240
+ MIN_MAX_CRITICAL(float10, min, long double , >, 10r,
1241
+ 1 ) // __kmpc_atomic_float10_min
1238
1242
#if KMP_HAVE_QUAD
1239
1243
MIN_MAX_CRITICAL (float16, max, QUAD_LEGACY, <, 16r,
1240
1244
1 ) // __kmpc_atomic_float16_max
@@ -2717,6 +2721,10 @@ MIN_MAX_COMPXCHG_CPT(float8, max_cpt, kmp_real64, 64, <,
2717
2721
KMP_ARCH_X86) // __kmpc_atomic_float8_max_cpt
2718
2722
MIN_MAX_COMPXCHG_CPT(float8, min_cpt, kmp_real64, 64 , >,
2719
2723
KMP_ARCH_X86) // __kmpc_atomic_float8_min_cpt
2724
+ MIN_MAX_CRITICAL_CPT(float10, max_cpt, long double , <, 10r,
2725
+ 1 ) // __kmpc_atomic_float10_max_cpt
2726
+ MIN_MAX_CRITICAL_CPT(float10, min_cpt, long double , >, 10r,
2727
+ 1 ) // __kmpc_atomic_float10_min_cpt
2720
2728
#if KMP_HAVE_QUAD
2721
2729
MIN_MAX_CRITICAL_CPT (float16, max_cpt, QUAD_LEGACY, <, 16r,
2722
2730
1 ) // __kmpc_atomic_float16_max_cpt
@@ -3686,6 +3694,168 @@ void __kmpc_atomic_end(void) {
3686
3694
__kmp_release_atomic_lock (&__kmp_atomic_lock, gtid);
3687
3695
}
3688
3696
3697
+ // OpenMP 5.1 compare and swap
3698
+
3699
+ /* !
3700
+ @param loc Source code location
3701
+ @param gtid Global thread id
3702
+ @param x Memory location to operate on
3703
+ @param e Expected value
3704
+ @param d Desired value
3705
+ @return Result of comparison
3706
+
3707
+ Implements Compare And Swap atomic operation.
3708
+
3709
+ Sample code:
3710
+ #pragma omp atomic compare update capture
3711
+ { r = x == e; if(r) { x = d; } }
3712
+ */
3713
+ bool __kmpc_atomic_bool_1_cas (ident_t *loc, int gtid, char *x, char e, char d) {
3714
+ return KMP_COMPARE_AND_STORE_ACQ8 (x, e, d);
3715
+ }
3716
+ bool __kmpc_atomic_bool_2_cas (ident_t *loc, int gtid, short *x, short e,
3717
+ short d) {
3718
+ return KMP_COMPARE_AND_STORE_ACQ16 (x, e, d);
3719
+ }
3720
+ bool __kmpc_atomic_bool_4_cas (ident_t *loc, int gtid, kmp_int32 *x, kmp_int32 e,
3721
+ kmp_int32 d) {
3722
+ return KMP_COMPARE_AND_STORE_ACQ32 (x, e, d);
3723
+ }
3724
+ bool __kmpc_atomic_bool_8_cas (ident_t *loc, int gtid, kmp_int64 *x, kmp_int64 e,
3725
+ kmp_int64 d) {
3726
+ return KMP_COMPARE_AND_STORE_ACQ64 (x, e, d);
3727
+ }
3728
+
3729
+ /* !
3730
+ @param loc Source code location
3731
+ @param gtid Global thread id
3732
+ @param x Memory location to operate on
3733
+ @param e Expected value
3734
+ @param d Desired value
3735
+ @return Old value of x
3736
+
3737
+ Implements Compare And Swap atomic operation.
3738
+
3739
+ Sample code:
3740
+ #pragma omp atomic compare update capture
3741
+ { v = x; if (x == e) { x = d; } }
3742
+ */
3743
+ char __kmpc_atomic_val_1_cas (ident_t *loc, int gtid, char *x, char e, char d) {
3744
+ return KMP_COMPARE_AND_STORE_RET8 (x, e, d);
3745
+ }
3746
+ short __kmpc_atomic_val_2_cas (ident_t *loc, int gtid, short *x, short e,
3747
+ short d) {
3748
+ return KMP_COMPARE_AND_STORE_RET16 (x, e, d);
3749
+ }
3750
+ kmp_int32 __kmpc_atomic_val_4_cas (ident_t *loc, int gtid, kmp_int32 *x,
3751
+ kmp_int32 e, kmp_int32 d) {
3752
+ return KMP_COMPARE_AND_STORE_RET32 (x, e, d);
3753
+ }
3754
+ kmp_int64 __kmpc_atomic_val_8_cas (ident_t *loc, int gtid, kmp_int64 *x,
3755
+ kmp_int64 e, kmp_int64 d) {
3756
+ return KMP_COMPARE_AND_STORE_RET64 (x, e, d);
3757
+ }
3758
+
3759
+ /* !
3760
+ @param loc Source code location
3761
+ @param gtid Global thread id
3762
+ @param x Memory location to operate on
3763
+ @param e Expected value
3764
+ @param d Desired value
3765
+ @param pv Captured value location
3766
+ @return Result of comparison
3767
+
3768
+ Implements Compare And Swap + Capture atomic operation.
3769
+
3770
+ v gets old valie of x if comparison failed, untouched otherwise.
3771
+ Sample code:
3772
+ #pragma omp atomic compare update capture
3773
+ { r = x == e; if(r) { x = d; } else { v = x; } }
3774
+ */
3775
+ bool __kmpc_atomic_bool_1_cas_cpt (ident_t *loc, int gtid, char *x, char e,
3776
+ char d, char *pv) {
3777
+ char old = KMP_COMPARE_AND_STORE_RET8 (x, e, d);
3778
+ if (old == e)
3779
+ return true ;
3780
+ KMP_ASSERT (pv != NULL );
3781
+ *pv = old;
3782
+ return false ;
3783
+ }
3784
+ bool __kmpc_atomic_bool_2_cas_cpt (ident_t *loc, int gtid, short *x, short e,
3785
+ short d, short *pv) {
3786
+ short old = KMP_COMPARE_AND_STORE_RET16 (x, e, d);
3787
+ if (old == e)
3788
+ return true ;
3789
+ KMP_ASSERT (pv != NULL );
3790
+ *pv = old;
3791
+ return false ;
3792
+ }
3793
+ bool __kmpc_atomic_bool_4_cas_cpt (ident_t *loc, int gtid, kmp_int32 *x,
3794
+ kmp_int32 e, kmp_int32 d, kmp_int32 *pv) {
3795
+ kmp_int32 old = KMP_COMPARE_AND_STORE_RET32 (x, e, d);
3796
+ if (old == e)
3797
+ return true ;
3798
+ KMP_ASSERT (pv != NULL );
3799
+ *pv = old;
3800
+ return false ;
3801
+ }
3802
+ bool __kmpc_atomic_bool_8_cas_cpt (ident_t *loc, int gtid, kmp_int64 *x,
3803
+ kmp_int64 e, kmp_int64 d, kmp_int64 *pv) {
3804
+ kmp_int64 old = KMP_COMPARE_AND_STORE_RET64 (x, e, d);
3805
+ if (old == e)
3806
+ return true ;
3807
+ KMP_ASSERT (pv != NULL );
3808
+ *pv = old;
3809
+ return false ;
3810
+ }
3811
+
3812
+ /* !
3813
+ @param loc Source code location
3814
+ @param gtid Global thread id
3815
+ @param x Memory location to operate on
3816
+ @param e Expected value
3817
+ @param d Desired value
3818
+ @param pv Captured value location
3819
+ @return Old value of x
3820
+
3821
+ Implements Compare And Swap + Capture atomic operation.
3822
+
3823
+ v gets new valie of x.
3824
+ Sample code:
3825
+ #pragma omp atomic compare update capture
3826
+ { if (x == e) { x = d; }; v = x; }
3827
+ */
3828
+ char __kmpc_atomic_val_1_cas_cpt (ident_t *loc, int gtid, char *x, char e,
3829
+ char d, char *pv) {
3830
+ char old = KMP_COMPARE_AND_STORE_RET8 (x, e, d);
3831
+ KMP_ASSERT (pv != NULL );
3832
+ *pv = old == e ? d : old;
3833
+ return old;
3834
+ }
3835
+ short __kmpc_atomic_val_2_cas_cpt (ident_t *loc, int gtid, short *x, short e,
3836
+ short d, short *pv) {
3837
+ short old = KMP_COMPARE_AND_STORE_RET16 (x, e, d);
3838
+ KMP_ASSERT (pv != NULL );
3839
+ *pv = old == e ? d : old;
3840
+ return old;
3841
+ }
3842
+ kmp_int32 __kmpc_atomic_val_4_cas_cpt (ident_t *loc, int gtid, kmp_int32 *x,
3843
+ kmp_int32 e, kmp_int32 d, kmp_int32 *pv) {
3844
+ kmp_int32 old = KMP_COMPARE_AND_STORE_RET32 (x, e, d);
3845
+ KMP_ASSERT (pv != NULL );
3846
+ *pv = old == e ? d : old;
3847
+ return old;
3848
+ }
3849
+ kmp_int64 __kmpc_atomic_val_8_cas_cpt (ident_t *loc, int gtid, kmp_int64 *x,
3850
+ kmp_int64 e, kmp_int64 d, kmp_int64 *pv) {
3851
+ kmp_int64 old = KMP_COMPARE_AND_STORE_RET64 (x, e, d);
3852
+ KMP_ASSERT (pv != NULL );
3853
+ *pv = old == e ? d : old;
3854
+ return old;
3855
+ }
3856
+
3857
+ // End OpenMP 5.1 compare + capture
3858
+
3689
3859
/* !
3690
3860
@}
3691
3861
*/
0 commit comments