Changeset 34d194c for libcfa


Ignore:
Timestamp:
Jul 5, 2026, 11:13:26 PM (4 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
97c75bf
Parents:
3859adb
git-author:
Peter A. Buhr <pabuhr@…> (07/05/26 23:05:57)
git-committer:
Peter A. Buhr <pabuhr@…> (07/05/26 23:13:26)
Message:

move libcfa/src/concurrency/atomic.hfa to libcfa/src/bits/atomic.hfa, and update all the atomic operations

Location:
libcfa/src
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    r3859adb r34d194c  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Nov  1 19:03:42 2023
    14 ## Update Count     : 266
     13## Last Modified On : Sat Jul  4 07:27:10 2026
     14## Update Count     : 267
    1515###############################################################################
    1616
     
    6060        bits/queue.hfa \
    6161        bits/sequence.hfa \
    62         concurrency/atomic.hfa \
     62        bits/atomic.hfa \
    6363        concurrency/iofwd.hfa \
    6464        concurrency/barrier.hfa \
  • libcfa/src/bits/defs.hfa

    r3859adb r34d194c  
    1313// Created On       : Thu Nov  9 13:24:10 2017
    1414// Last Modified By : Peter A. Buhr
    15 // Last Modified On : Mon Oct 27 22:40:05 2025
    16 // Update Count     : 23
     15// Last Modified On : Sat Jul  4 15:04:20 2026
     16// Update Count     : 26
    1717//
    1818
     
    6868#endif
    6969
    70 static inline long long int rdtscl(void) {
    71         #if defined( __i386 ) || defined( __x86_64 )
    72         unsigned int lo, hi;
    73         __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
    74         return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
    75         #elif defined( __aarch64__ ) || defined( __arm__ )
    76         // https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116
    77         long long int virtual_timer_value;
    78         asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
    79         return virtual_timer_value;
    80         #else
    81                 #error unsupported hardware architecture
    82         #endif
    83 }
    84 
    85 // pause to prevent excess processor bus usage
    86 #if defined( __i386 ) || defined( __x86_64 )
    87         #define Pause() __asm__ __volatile__ ( "pause" : : : )
    88 #elif defined( __ARM_ARCH )
    89         #define Pause() __asm__ __volatile__ ( "YIELD" : : : )
    90 #else
    91         #error unsupported architecture
    92 #endif
    93 
    9470#define CFA_IO_LAZY (1_l64u << 32_l64u)
  • libcfa/src/bits/locks.hfa

    r3859adb r34d194c  
    1313// Created On       : Tue Oct 31 15:14:38 2017
    1414// Last Modified By : Peter A. Buhr
    15 // Last Modified On : Tue Sep 20 22:09:50 2022
    16 // Update Count     : 18
     15// Last Modified On : Sat Jul  4 06:50:46 2026
     16// Update Count     : 21
    1717//
    1818
     
    2121#include "bits/debug.hfa"
    2222#include "bits/defs.hfa"
     23#include "bits/atomic.hfa"
    2324#include <assert.h>
    2425
  • libcfa/src/concurrency/kernel/fwd.hfa

    r3859adb r34d194c  
    1919#include "bits/defs.hfa"
    2020#include "bits/debug.hfa"
     21#include "bits/atomic.hfa"                                                              // Pause
    2122
    2223#ifdef __cforall
  • libcfa/src/concurrency/locks.hfa

    r3859adb r34d194c  
    1111// Created On       : Thu Jan 21 19:46:50 2021
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sun Mar 29 22:46:39 2026
    14 // Update Count     : 68
     13// Last Modified On : Sat Jul  4 06:52:06 2026
     14// Update Count     : 70
    1515//
    1616
     
    2121
    2222#include "bits/weakso_locks.hfa"
     23#include "bits/atomic.hfa"
    2324#include "collections/lockfree.hfa"
    2425#include "collections/list.hfa"
  • libcfa/src/heap.cfa

    r3859adb r34d194c  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 15 16:47:35 2025
    13 // Update Count     : 1647
     12// Last Modified On : Sat Jul  4 16:17:06 2026
     13// Update Count     : 1658
    1414//
    1515
     
    2525
    2626#include "heap.hfa"
    27 #include "bits/align.hfa"                                                               // libAlign
    28 #include "bits/defs.hfa"                                                                // likely, unlikely
     27#include "bits/align.hfa"                                                               // libAlign, Pause, likely, unlikely
    2928#include "concurrency/kernel/fwd.hfa"                                   // disable_interrupts, enable_interrupts
    3029#include "startup.hfa"                                                                  // STARTUP_PRIORITY_MEMORY
     
    129128} // Bsearchl
    130129
    131 
    132 // pause to prevent excess processor bus usage
    133 #if defined( __i386 ) || defined( __x86_64 )
    134         #define Pause() __asm__ __volatile__ ( "pause" : : : )
    135 #elif defined(__ARM_ARCH)
    136         #define Pause() __asm__ __volatile__ ( "YIELD" : : : )
    137 #else
    138         #error unsupported architecture
    139 #endif
    140 
    141130typedef volatile uintptr_t SpinLock_t;
    142131
     
    146135
    147136        for ( unsigned int i = 1;; i += 1 ) {
    148           if ( slock == 0 && __atomic_test_and_set( &slock, __ATOMIC_ACQUIRE ) == 0 ) break; // Fence
     137          if ( slock == 0 && AtomicTas( slock ) == 0 ) break; // Fence
    149138                for ( volatile unsigned int s = 0; s < spin; s += 1 ) Pause(); // exponential spin
    150139                spin += spin;                                                                   // powers of 2
     
    155144
    156145static inline __attribute__((always_inline)) void unlock( volatile SpinLock_t & slock ) {
    157         __atomic_clear( &slock, __ATOMIC_RELEASE );                     // Fence
     146        AtomicClr( slock );                                                                     // Fence
    158147} // spin_unlock
    159148
     
    1003992                                unlock( freeHead->returnLock );
    1004993                                #else
    1005                                 block = __atomic_exchange_n( &freeHead->returnList, 0p, __ATOMIC_SEQ_CST );
     994                                block = AtomicFas( freeHead->returnList, 0p );
    1006995                                #endif // RETURNSPIN
    1007996
     
    11681157                        header->kind.real.next = freeHead->returnList; // link new node to top node
    11691158                        // CAS resets header->kind.real.next = freeHead->returnList on failure
    1170                         while ( ! __atomic_compare_exchange_n( &freeHead->returnList, &header->kind.real.next, (Heap.Storage *)header,
    1171                                                                                                    false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) );
     1159                        while ( ! AtomicCasv( freeHead->returnList, header->kind.real.next, (Heap.Storage *)header );
    11721160
    11731161                        #ifdef __STATISTICS__
Note: See TracChangeset for help on using the changeset viewer.