Changeset deda7e6 for libcfa/src


Ignore:
Timestamp:
Sep 21, 2023, 10:15:58 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
62c6cfa
Parents:
c1e66d9 (diff), 5a1ae14 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    rc1e66d9 rdeda7e6  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Aug 30 21:22:45 2023
    14 ## Update Count     : 263
     13## Last Modified On : Mon Sep 18 17:06:56 2023
     14## Update Count     : 264
    1515###############################################################################
    1616
     
    118118        concurrency/mutex_stmt.hfa \
    119119        concurrency/channel.hfa \
    120         concurrency/actor.hfa 
     120        concurrency/actor.hfa
    121121
    122122inst_thread_headers_src = \
     
    130130        concurrency/mutex.hfa \
    131131        concurrency/select.hfa \
    132         concurrency/thread.hfa
     132        concurrency/thread.hfa \
     133        concurrency/cofor.hfa
    133134
    134135thread_libsrc = ${inst_thread_headers_src} ${inst_thread_headers_src:.hfa=.cfa} \
  • libcfa/src/clock.hfa

    rc1e66d9 rdeda7e6  
    1010// Created On       : Thu Apr 12 14:36:06 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr 18 08:12:16 2021
    13 // Update Count     : 28
     12// Last Modified On : Sat Sep  9 14:07:17 2023
     13// Update Count     : 30
    1414//
    1515
     
    9191        // discontinuous jumps when the OS is not running the kernal thread. A duration is returned because the value is
    9292        // relative and cannot be converted to real-time (wall-clock) time.
    93         Duration processor() {                                                          // non-monotonic duration of kernel thread
     93        Duration processor_cpu() {                                                      // non-monotonic duration of kernel thread
    9494                timespec ts;
    9595                clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
    9696                return (Duration){ ts };
    97         } // processor
     97        } // processor_cpu
    9898
    9999        // Program CPU-time watch measures CPU time consumed by all processors (kernel threads) in the UNIX process.  This
    100100        // watch is affected by discontinuous jumps when the OS is not running the kernel threads. A duration is returned
    101101        // because the value is relative and cannot be converted to real-time (wall-clock) time.
    102         Duration program() {                                                            // non-monotonic duration of program CPU
     102        Duration program_cpu() {                                                        // non-monotonic duration of program CPU
    103103                timespec ts;
    104104                clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &ts );
    105105                return (Duration){ ts };
    106         } // program
     106        } // program_cpu
    107107
    108108        // Monotonic duration from machine boot and including system suspension. This watch is unaffected by discontinuous
  • libcfa/src/collections/string.cfa

    rc1e66d9 rdeda7e6  
    157157// Comparison
    158158
    159 bool ?==?(const string & s, const string & other) {
    160     return *s.inner == *other.inner;
    161 }
    162 
    163 bool ?!=?(const string & s, const string & other) {
    164     return *s.inner != *other.inner;
    165 }
    166 
    167 bool ?==?(const string & s, const char * other) {
    168     return *s.inner == other;
    169 }
    170 
    171 bool ?!=?(const string & s, const char * other) {
    172     return *s.inner != other;
    173 }
     159int  cmp (const string &s1, const string &s2) { return cmp(*s1.inner ,  *s2.inner); }
     160bool ?==?(const string &s1, const string &s2) { return     *s1.inner == *s2.inner ; }
     161bool ?!=?(const string &s1, const string &s2) { return     *s1.inner != *s2.inner ; }
     162bool ?>? (const string &s1, const string &s2) { return     *s1.inner >  *s2.inner ; }
     163bool ?>=?(const string &s1, const string &s2) { return     *s1.inner >= *s2.inner ; }
     164bool ?<=?(const string &s1, const string &s2) { return     *s1.inner <= *s2.inner ; }
     165bool ?<? (const string &s1, const string &s2) { return     *s1.inner <  *s2.inner ; }
     166
     167int  cmp (const string &s1, const char*   s2) { return cmp(*s1.inner ,   s2      ); }
     168bool ?==?(const string &s1, const char*   s2) { return     *s1.inner ==  s2       ; }
     169bool ?!=?(const string &s1, const char*   s2) { return     *s1.inner !=  s2       ; }
     170bool ?>? (const string &s1, const char*   s2) { return     *s1.inner >   s2       ; }
     171bool ?>=?(const string &s1, const char*   s2) { return     *s1.inner >=  s2       ; }
     172bool ?<=?(const string &s1, const char*   s2) { return     *s1.inner <=  s2       ; }
     173bool ?<? (const string &s1, const char*   s2) { return     *s1.inner <   s2       ; }
     174
     175int  cmp (const char*   s1, const string &s2) { return cmp( s1       ,  *s2.inner); }
     176bool ?==?(const char*   s1, const string &s2) { return      s1       == *s2.inner ; }
     177bool ?!=?(const char*   s1, const string &s2) { return      s1       != *s2.inner ; }
     178bool ?>? (const char*   s1, const string &s2) { return      s1       >  *s2.inner ; }
     179bool ?>=?(const char*   s1, const string &s2) { return      s1       >= *s2.inner ; }
     180bool ?<=?(const char*   s1, const string &s2) { return      s1       <= *s2.inner ; }
     181bool ?<? (const char*   s1, const string &s2) { return      s1       <  *s2.inner ; }
     182
    174183
    175184////////////////////////////////////////////////////////
  • libcfa/src/collections/string.hfa

    rc1e66d9 rdeda7e6  
    116116
    117117// Comparisons
    118 bool ?==?(const string & s, const string & other);
    119 bool ?!=?(const string & s, const string & other);
    120 bool ?==?(const string & s, const char * other);
    121 bool ?!=?(const string & s, const char * other);
     118int  cmp (const string &, const string &);
     119bool ?==?(const string &, const string &);
     120bool ?!=?(const string &, const string &);
     121bool ?>? (const string &, const string &);
     122bool ?>=?(const string &, const string &);
     123bool ?<=?(const string &, const string &);
     124bool ?<? (const string &, const string &);
     125
     126int  cmp (const string &, const char*);
     127bool ?==?(const string &, const char*);
     128bool ?!=?(const string &, const char*);
     129bool ?>? (const string &, const char*);
     130bool ?>=?(const string &, const char*);
     131bool ?<=?(const string &, const char*);
     132bool ?<? (const string &, const char*);
     133
     134int  cmp (const char*, const string &);
     135bool ?==?(const char*, const string &);
     136bool ?!=?(const char*, const string &);
     137bool ?>? (const char*, const string &);
     138bool ?>=?(const char*, const string &);
     139bool ?<=?(const char*, const string &);
     140bool ?<? (const char*, const string &);
     141
    122142
    123143// Slicing
  • libcfa/src/collections/string_res.cfa

    rc1e66d9 rdeda7e6  
    637637// Comparisons
    638638
    639 
    640 bool ?==?(const string_res &s1, const string_res &s2) {
    641     return ByteCmp( s1.Handle.s, 0, s1.Handle.lnth, s2.Handle.s, 0, s2.Handle.lnth) == 0;
    642 }
    643 
    644 bool ?!=?(const string_res &s1, const string_res &s2) {
    645     return !(s1 == s2);
    646 }
    647 bool ?==?(const string_res &s, const char* other) {
    648     string_res sother = other;
    649     return s == sother;
    650 }
    651 bool ?!=?(const string_res &s, const char* other) {
    652     return !(s == other);
    653 }
     639int cmp(const string_res &s1, const string_res &s2) {
     640    // return 0;
     641    int ans1 = memcmp(s1.Handle.s, s2.Handle.s, min(s1.Handle.lnth, s2.Handle.lnth));
     642    if (ans1 != 0) return ans1;
     643    return s1.Handle.lnth - s2.Handle.lnth;
     644}
     645
     646bool ?==?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) == 0; }
     647bool ?!=?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) != 0; }
     648bool ?>? (const string_res &s1, const string_res &s2) { return cmp(s1, s2) >  0; }
     649bool ?>=?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) >= 0; }
     650bool ?<=?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) <= 0; }
     651bool ?<? (const string_res &s1, const string_res &s2) { return cmp(s1, s2) <  0; }
     652
     653int cmp (const string_res &s1, const char* s2) {
     654    string_res s2x = s2;
     655    return cmp(s1, s2x);
     656}
     657
     658bool ?==?(const string_res &s1, const char* s2) { return cmp(s1, s2) == 0; }
     659bool ?!=?(const string_res &s1, const char* s2) { return cmp(s1, s2) != 0; }
     660bool ?>? (const string_res &s1, const char* s2) { return cmp(s1, s2) >  0; }
     661bool ?>=?(const string_res &s1, const char* s2) { return cmp(s1, s2) >= 0; }
     662bool ?<=?(const string_res &s1, const char* s2) { return cmp(s1, s2) <= 0; }
     663bool ?<? (const string_res &s1, const char* s2) { return cmp(s1, s2) <  0; }
     664
     665int cmp (const char* s1, const string_res & s2) {
     666    string_res s1x = s1;
     667    return cmp(s1x, s2);
     668}
     669
     670bool ?==?(const char* s1, const string_res &s2) { return cmp(s1, s2) == 0; }
     671bool ?!=?(const char* s1, const string_res &s2) { return cmp(s1, s2) != 0; }
     672bool ?>? (const char* s1, const string_res &s2) { return cmp(s1, s2) >  0; }
     673bool ?>=?(const char* s1, const string_res &s2) { return cmp(s1, s2) >= 0; }
     674bool ?<=?(const char* s1, const string_res &s2) { return cmp(s1, s2) <= 0; }
     675bool ?<? (const char* s1, const string_res &s2) { return cmp(s1, s2) <  0; }
     676
    654677
    655678
  • libcfa/src/collections/string_res.hfa

    rc1e66d9 rdeda7e6  
    142142
    143143// Comparisons
    144 bool ?==?(const string_res &s, const string_res &other);
    145 bool ?!=?(const string_res &s, const string_res &other);
    146 bool ?==?(const string_res &s, const char* other);
    147 bool ?!=?(const string_res &s, const char* other);
     144int  cmp (const string_res &, const string_res &);
     145bool ?==?(const string_res &, const string_res &);
     146bool ?!=?(const string_res &, const string_res &);
     147bool ?>? (const string_res &, const string_res &);
     148bool ?>=?(const string_res &, const string_res &);
     149bool ?<=?(const string_res &, const string_res &);
     150bool ?<? (const string_res &, const string_res &);
     151
     152int  cmp (const string_res &, const char*);
     153bool ?==?(const string_res &, const char*);
     154bool ?!=?(const string_res &, const char*);
     155bool ?>? (const string_res &, const char*);
     156bool ?>=?(const string_res &, const char*);
     157bool ?<=?(const string_res &, const char*);
     158bool ?<? (const string_res &, const char*);
     159
     160int  cmp (const char*, const string_res &);
     161bool ?==?(const char*, const string_res &);
     162bool ?!=?(const char*, const string_res &);
     163bool ?>? (const char*, const string_res &);
     164bool ?>=?(const char*, const string_res &);
     165bool ?<=?(const char*, const string_res &);
     166bool ?<? (const char*, const string_res &);
    148167
    149168// String search
  • libcfa/src/common.hfa

    rc1e66d9 rdeda7e6  
    6969        T min( T v1, T v2 ) { return v1 < v2 ? v1 : v2; }
    7070
    71         forall( T, Ts... | { T min( T, T ); T min( T, Ts ); } )
    72         T min( T v1, T v2, Ts vs ) { return min( min( v1, v2 ), vs ); }
     71        forall( T, Ts... | { T min( T, T ); T min( T, T, Ts ); } )
     72        T min( T v1, T v2, T v3, Ts vs ) { return min( min( v1, v2 ), v3, vs ); }
    7373
    7474        forall( T | { int ?>?( T, T ); } )
    7575        T max( T v1, T v2 ) { return v1 > v2 ? v1 : v2; }
    7676
    77         forall( T, Ts... | { T max( T, T ); T max( T, Ts ); } )
    78         T max( T v1, T v2, Ts vs ) { return max( max( v1, v2 ), vs ); }
     77        forall( T, Ts... | { T max( T, T ); T max( T, T, Ts ); } )
     78        T max( T v1, T v2, T v3, Ts vs ) { return max( max( v1, v2 ), v3, vs ); }
    7979
    8080        forall( T | { T min( T, T ); T max( T, T ); } )
  • libcfa/src/concurrency/coroutine.cfa

    rc1e66d9 rdeda7e6  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:34:46 2023
    13 // Update Count     : 24
     12// Last Modified On : Mon Sep 18 21:47:12 2023
     13// Update Count     : 25
    1414//
    1515
     
    364364// resume non local exception at receiver (i.e. enqueue in ehm buffer)
    365365forall(exceptT *, T & | ehm_resume_at( exceptT, T ))
    366 void resumeAt( T & receiver, exceptT & ex )  libcfa_public {
     366void resumeAt( T & receiver, exceptT & ex ) libcfa_public {
    367367    coroutine$ * cor = get_coroutine( receiver );
    368368    nonlocal_exception * nl_ex = alloc();
  • libcfa/src/concurrency/kernel/cluster.hfa

    rc1e66d9 rdeda7e6  
    3131
    3232// warn normally all ints
    33 #define warn_large_before warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'" PRId64 "ms \n", old_avg, old_avg, program()`ms )
    34 #define warn_large_after warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'" PRId64 "ms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program()`ms, ret, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg )
     33#define warn_large_before warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'" PRId64 "ms \n", old_avg, old_avg, program_cpu()`ms )
     34#define warn_large_after warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'" PRId64 "ms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program_cpu()`ms, ret, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg )
    3535
    3636// 8X linear factor is just 8 * x
     
    4242static inline __readyQ_avg_t __to_readyQ_avg(unsigned long long intsc) { if(unlikely(0 == intsc)) return 0.0; else return log2((__readyQ_avg_t)intsc); }
    4343
    44 #define warn_large_before warnf( !strict || old_avg < 35.0, "Suspiciously large previous average: %'lf, %'" PRId64 "ms \n", old_avg, program()`ms )
    45 #define warn_large_after warnf( !strict || ret < 35.3, "Suspiciously large new average after %'" PRId64 "ms cputime: %'lf from %'llu-%'llu (%'llu, %'llu) and %'lf\n", program()`ms, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg ); \
     44#define warn_large_before warnf( !strict || old_avg < 35.0, "Suspiciously large previous average: %'lf, %'" PRId64 "ms \n", old_avg, program_cpu()`ms )
     45#define warn_large_after warnf( !strict || ret < 35.3, "Suspiciously large new average after %'" PRId64 "ms cputime: %'lf from %'llu-%'llu (%'llu, %'llu) and %'lf\n", program_cpu()`ms, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg ); \
    4646verify(ret >= 0)
    4747
  • libcfa/src/heap.cfa

    rc1e66d9 rdeda7e6  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  2 18:48:30 2023
    13 // Update Count     : 1614
     12// Last Modified On : Mon Sep 11 11:21:10 2023
     13// Update Count     : 1615
    1414//
    1515
     
    691691        return stats;
    692692} // collectStats
     693
     694static inline void clearStats() {
     695        lock( mgrLock );
     696
     697        // Zero the heap master and all active thread heaps.
     698        HeapStatisticsCtor( heapMaster.stats );
     699        for ( Heap * heap = heapMaster.heapManagersList; heap; heap = heap->nextHeapManager ) {
     700                HeapStatisticsCtor( heap->stats );
     701        } // for
     702
     703        unlock( mgrLock );
     704} // clearStats
    693705#endif // __STATISTICS__
    694706
     
    15561568
    15571569
     1570        // Zero the heap master and all active thread heaps.
     1571        void malloc_stats_clear() {
     1572                #ifdef __STATISTICS__
     1573                clearStats();
     1574                #else
     1575                #define MALLOC_STATS_MSG "malloc_stats statistics disabled.\n"
     1576                if ( write( STDERR_FILENO, MALLOC_STATS_MSG, sizeof( MALLOC_STATS_MSG ) - 1 /* size includes '\0' */ ) == -1 ) {
     1577                        abort( "**** Error **** write failed in malloc_stats" );
     1578                } // if
     1579                #endif // __STATISTICS__
     1580        } // malloc_stats_clear
     1581
     1582
    15581583        // Changes the file descriptor where malloc_stats() writes statistics.
    15591584        int malloc_stats_fd( int fd __attribute__(( unused )) ) libcfa_public {
  • libcfa/src/heap.hfa

    rc1e66d9 rdeda7e6  
    1010// Created On       : Tue May 26 11:23:55 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct  4 19:08:55 2022
    13 // Update Count     : 23
     12// Last Modified On : Mon Sep 11 11:18:18 2023
     13// Update Count     : 24
    1414//
    1515
     
    4343        size_t malloc_mmap_start();                                                     // crossover allocation size from sbrk to mmap
    4444        size_t malloc_unfreed();                                                        // heap unfreed size (bytes)
     45        void malloc_stats_clear();                                                      // clear heap statistics
    4546} // extern "C"
    4647
  • libcfa/src/iostream.cfa

    rc1e66d9 rdeda7e6  
     1
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     
    976977                if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; }
    977978                // no maximum width necessary because text ignored => width is read width
    978                 if ( f.wd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.wd ); }
     979                if ( f.wd != -1 ) {
     980                        // wd is buffer bytes available (for input chars + null terminator)
     981                        // rwd is count of input chars
     982                        int rwd = f.flags.rwd ? f.wd : (f.wd - 1);
     983                        start += sprintf( &fmtstr[start], "%d", rwd );
     984                }
    979985
    980986                if ( ! scanset ) {
     
    993999                } // if
    9941000
    995                 int check = f.wd - 1;
     1001                int check = f.wd - 2;
    9961002                if ( ! f.flags.rwd ) f.s[check] = '\0';                 // insert sentinel
    9971003                len = fmt( is, fmtstr, f.s );
Note: See TracChangeset for help on using the changeset viewer.