Skip to content

Commit

Permalink
draft v7.4.4. with fixed atomics (adding seq_cst)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Mar 25, 2023
1 parent 279102e commit 5c62e8c
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 63 deletions.
6 changes: 6 additions & 0 deletions Doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 7.4.4, Mar 25, 2023

* (47) bug fix: OpenMP atomics require seq_cst on the ARM.
Revised GB_atomics.h accordingly, and added them for all
architectures (caught by Gabor Szarnyas).

Version 7.4.3, Jan 20, 2023

* debug: turned on in GrB_Matrix_removeElement by mistake.
Expand Down
Binary file modified Doc/GraphBLAS_UserGuide.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions Doc/GraphBLAS_UserGuide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15489,6 +15489,14 @@ \section{Release Notes}

\begin{itemize}

\item Version 7.4.4, Mar 25, 2023

\begin{itemize}
\item (47) bug fix: OpenMP atomics require \verb'seq_cst' on the ARM.
Revised \verb'GB_atomics.h' accordingly, and added them for
all architectures (caught by Gabor Szarnyas).
\end{itemize}

\item Version 7.4.3, Jan 20, 2023

\begin{itemize}
Expand Down
4 changes: 2 additions & 2 deletions Doc/GraphBLAS_version.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% version of SuiteSparse:GraphBLAS
\date{VERSION
7.4.3,
Jan 20, 2023}
7.4.4,
Mar 25, 2023}

4 changes: 2 additions & 2 deletions Include/GraphBLAS.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@

// The version of this implementation, and the GraphBLAS API version:
#define GxB_IMPLEMENTATION_NAME "SuiteSparse:GraphBLAS"
#define GxB_IMPLEMENTATION_DATE "Jan 20, 2023"
#define GxB_IMPLEMENTATION_DATE "Mar 25, 2023"
#define GxB_IMPLEMENTATION_MAJOR 7
#define GxB_IMPLEMENTATION_MINOR 4
#define GxB_IMPLEMENTATION_SUB 3
#define GxB_IMPLEMENTATION_SUB 4
#define GxB_SPEC_DATE "Nov 15, 2021"
#define GxB_SPEC_MAJOR 2
#define GxB_SPEC_MINOR 0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

VERSION 7.4.3, Jan 20, 2023
VERSION 7.4.4, Mar 25, 2023

SuiteSparse:GraphBLAS is a complete implementation of the GraphBLAS standard,
which defines a set of sparse matrix operations on an extended algebra of
Expand Down
82 changes: 28 additions & 54 deletions Source/GB_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// GB_atomics.h: definitions for atomic operations
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2023, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// All atomic operations used by SuiteSparse:GraphBLAS appear in this file.
// OpenMP 4.0 or later is preferred.

// These atomic operations assume either an ANSI C11 compiler that supports
// OpenMP 3.1 or later, or Microsoft Visual Studio on 64-bit Windows (which
Expand All @@ -23,23 +24,23 @@
//------------------------------------------------------------------------------

// Whenever possible, the OpenMP pragma is used with a clause (as introduced in
// OpenMP 3.1), as follow:
// OpenMP 4.0), as follows:
//
// #pragma omp atomic seq_cst [clause]
//
// where [clause] is read, write, update, or capture.
//
// Microsoft Visual Studio only supports OpenMP 2.0, which does not have the
// [clause]. Without the [clause], #pragma omp atomic seq_cst is like
// [clause]. Without the [clause], #pragma omp atomic is like
// #pragma omp atomic seq_cst update, but the expression can only be one of:
//
//
// x binop= expression
// x++
// ++x
// x--
// --x
//
// where binop is one of these operators: + * - / & ^ | << >>
// where binop is one of these operators: + * - / & ^ | << >>
//
// OpenMP 3.0 and later support additional options for the "update" clause,
// but SuiteSparse:GraphBLAS uses only this form:
Expand All @@ -53,25 +54,24 @@
// types INTx, UINTx, FP32, FP64 (for x = 8, 16, 32, and 64). For the boolean
// monoids, only the BOOL type is used.
//
// As a result, the atomic updates are the same for gcc and icc (which support
// OpenMP 3.0 or later) with the "update" clause. For MS Visual Studio, the
// As a result, the atomic updates are the same for gcc and icx (which support
// OpenMP 4.0 or later) with the "update" clause. For MS Visual Studio, the
// "update" clause is removed since it supports OpenMP 2.0.

#if ( _OPENMP >= 201307 )

// OpenMP 4.0 or later
// #define GB_ATOMIC_UPDATE GB_PRAGMA (omp atomic seq_cst update seq_cst)
// OpenMP 4.0 or later: seq_cst added
#define GB_ATOMIC_UPDATE GB_PRAGMA (omp atomic seq_cst update)

#elif ( _OPENMP >= 201107 )

// OpenMP 3.1
#define GB_ATOMIC_UPDATE GB_PRAGMA (omp atomic seq_cst update)
// OpenMP 3.1: no seq_cst keyword
#define GB_ATOMIC_UPDATE GB_PRAGMA (omp atomic update)

#elif ( _OPENMP >= 199810 )

// OpenMP 1.0 to 3.0: no optional clauses, "update" is assumed
#define GB_ATOMIC_UPDATE GB_PRAGMA (omp atomic seq_cst)
#define GB_ATOMIC_UPDATE GB_PRAGMA (omp atomic)

#else

Expand Down Expand Up @@ -102,12 +102,18 @@
#define GB_ATOMIC_READ
#define GB_ATOMIC_WRITE

#elif ( _OPENMP >= 201107 )
#elif ( _OPENMP >= 201307 )

// OpenMP 3.1 and later have atomic reads and writes
// OpenMP 4.0 and later have atomic reads and writes, and seq_cst
#define GB_ATOMIC_READ GB_PRAGMA (omp atomic seq_cst read)
#define GB_ATOMIC_WRITE GB_PRAGMA (omp atomic seq_cst write)

#elif ( _OPENMP >= 201107 )

// OpenMP 3.1 and later have atomic reads and writes, but no seq_cst clause
#define GB_ATOMIC_READ GB_PRAGMA (omp atomic read)
#define GB_ATOMIC_WRITE GB_PRAGMA (omp atomic write)

#else

// OpenMP 3.0 or earlier, or no OpenMP at all
Expand Down Expand Up @@ -146,7 +152,7 @@
// { result = target ; target |= value ; } for int64_t
// { result = target++ ; } for int64_t
//
// OpenMP 3.1 and later supports atomic captures with a "capture" clause:
// OpenMP 3.1 and later supports atomic captures with a "capture" clause:
//
// #pragma omp atomic seq_cst capture
// { result = target ; target = value ; }
Expand All @@ -165,14 +171,13 @@

#if ( _OPENMP >= 201307 )

// OpenMP 4.0 or later
// #define GB_ATOMIC_CAPTURE GB_PRAGMA (omp atomic seq_cst capture seq_cst)
// OpenMP 4.0 or later: added seq_cst feature
#define GB_ATOMIC_CAPTURE GB_PRAGMA (omp atomic seq_cst capture)

#elif ( _OPENMP >= 201107 )

// OpenMP 3.1
#define GB_ATOMIC_CAPTURE GB_PRAGMA (omp atomic seq_cst capture)
// OpenMP 3.1: no seq_cst clause
#define GB_ATOMIC_CAPTURE GB_PRAGMA (omp atomic capture)

#elif ( _OPENMP >= 199810 )

Expand Down Expand Up @@ -436,61 +441,30 @@

#include <stdatomic.h>

#if 0

// the compare/exchange function is generic for any type
#define GB_ATOMIC_COMPARE_EXCHANGE_X(target, expected, desired) \
atomic_compare_exchange_weak (target, &expected, desired)

// the compare/exchange function is generic for any type
// #define GB_ATOMIC_COMPARE_EXCHANGE_X(target, expected, desired) \
// __atomic_compare_exchange (target, &expected, &desired, \
// true, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) \

// bool, int8_t, and uint8_t
#define GB_ATOMIC_COMPARE_EXCHANGE_8(target, expected, desired) \
GB_ATOMIC_COMPARE_EXCHANGE_X(target, expected, desired)

// int16_t and uint16_t
#define GB_ATOMIC_COMPARE_EXCHANGE_16(target, expected, desired) \
GB_ATOMIC_COMPARE_EXCHANGE_X (target, expected, desired)

// float, int32_t, and uint32_t
#define GB_ATOMIC_COMPARE_EXCHANGE_32(target, expected, desired) \
GB_ATOMIC_COMPARE_EXCHANGE_X (target, expected, desired)

// double, int64_t, and uint64_t
#define GB_ATOMIC_COMPARE_EXCHANGE_64(target, expected, desired) \
GB_ATOMIC_COMPARE_EXCHANGE_X (target, expected, desired)

#else

// bool, int8_t, and uint8_t
#define GB_ATOMIC_COMPARE_EXCHANGE_8(target, expected, desired) \
atomic_compare_exchange_weak \
((volatile _Atomic uint8_t *) (target), \
(uint8_t *) (&(expected)), GB_PUN (uint8_t , desired))
(uint8_t *) (&(expected)), GB_PUN (uint8_t , desired))

// int16_t and uint16_t
#define GB_ATOMIC_COMPARE_EXCHANGE_16(target, expected, desired) \
atomic_compare_exchange_weak \
((volatile _Atomic uint16_t *) (target), \
(uint16_t *) (&(expected)), GB_PUN (uint16_t, desired))
(uint16_t *) (&(expected)), GB_PUN (uint16_t, desired))

// float, int32_t, and uint32_t
#define GB_ATOMIC_COMPARE_EXCHANGE_32(target, expected, desired) \
atomic_compare_exchange_weak \
((volatile _Atomic uint32_t *) (target), \
(uint32_t *) (&(expected)), GB_PUN (uint32_t, desired))
(uint32_t *) (&(expected)), GB_PUN (uint32_t, desired))

// double, int64_t, and uint64_t
#define GB_ATOMIC_COMPARE_EXCHANGE_64(target, expected, desired) \
atomic_compare_exchange_weak \
((volatile _Atomic uint64_t *) (target), \
(uint64_t *) (&(expected)), GB_PUN (uint64_t, desired))
(uint64_t *) (&(expected)), GB_PUN (uint64_t, desired))

#endif
#endif
#endif

2 changes: 1 addition & 1 deletion alternative/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default: library

VER1 = 7
VER2 = 4
VER3 = 3
VER3 = 4

# pick your compiler:
CC = gcc
Expand Down
6 changes: 3 additions & 3 deletions cmake_modules/GraphBLAS_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# GraphBLAS/cmake_modules/GraphBLAS_version.cmake: define the GraphBLAS version
#-------------------------------------------------------------------------------

# SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
# SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2023, All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# version of SuiteSparse:GraphBLAS
set ( GraphBLAS_DATE "Jan 20, 2023" )
set ( GraphBLAS_DATE "Mar 25, 2023" )
set ( GraphBLAS_VERSION_MAJOR 7 )
set ( GraphBLAS_VERSION_MINOR 4 )
set ( GraphBLAS_VERSION_SUB 3 )
set ( GraphBLAS_VERSION_SUB 4 )

0 comments on commit 5c62e8c

Please sign in to comment.