Changeset 8157bde


Ignore:
Timestamp:
Dec 2, 2021, 4:38:13 PM (6 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
enum, forall-pointer-decay, master
Children:
1894e03
Parents:
03cdad6
Message:

Pushing to get off jax

Location:
libcfa/src
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/device/cpu.cfa

    r03cdad6 r8157bde  
    135135                count++;
    136136        }
    137         iterate_dir(path, lambda);
     137        int ret = iterate_dir(path, lambda);
     138        if(ret == ENOTDIR) return 0;
    138139
    139140        /* paranoid */ verifyf(count == max + 1, "Inconsistent %s count, counted %d, but max %s was %d", prefix, count, prefix, (int)max);
     
    224225
    225226struct raw_cache_instance {
    226         idx_range_t range;
    227         unsigned width;
    228         unsigned char level;
     227        idx_range_t range;      // A text description of the cpus covered
     228        unsigned width;         // The number of cpus covered
     229        unsigned char level;    // the cache level
    229230        // FIXME add at least size and type
    230231};
     
    233234static void ^?{}(raw_cache_instance & this) { free(this.range);}
    234235
     236// Returns a 2D array of instances of size [cpu count][cache levels]
     237// where cache level doesn't include instruction caches
    235238raw_cache_instance ** build_raw_cache_table(unsigned cpus, unsigned idxs, unsigned cache_levels)
    236239{
     
    239242        // TODO: this loop is broken, it only works if the present cpu start at 0 and are contiguous which is not guaranteed.
    240243        for(i; cpus) {
    241                 raw[i] = alloc(cache_levels);
    242                 void addcache(unsigned fidx, unsigned char level, idx_range_t range, size_t len) {
    243                         /* paranoid */ verifyf(level <= cache_levels, "Unexpected cache level %d on cpu %u index %u", (int)level, i, fidx);
    244 
    245                         unsigned idx = cache_levels - level;
    246                         raw_cache_instance & r = raw[i][idx];
    247                         r.range = strndup(range, len);
    248                         r.level = level;
    249                         const char * end;
    250                         r.width = read_width(range, len, &end);
    251                 }
    252                 foreach_cacheidx(i, idxs, addcache);
     244                if (cache_levels > 0) {
     245                        raw[i] = alloc(cache_levels);
     246                        void addcache(unsigned fidx, unsigned char level, idx_range_t range, size_t len) {
     247                                /* paranoid */ verifyf(level <= cache_levels, "Unexpected cache level %d on cpu %u index %u", (int)level, i, fidx);
     248
     249                                unsigned idx = cache_levels - level;
     250                                raw_cache_instance & r = raw[i][idx];
     251                                r.range = strndup(range, len);
     252                                r.level = level;
     253                                const char * end;
     254                                r.width = read_width(range, len, &end);
     255                        }
     256                        foreach_cacheidx(i, idxs, addcache);
     257                }
     258                else {
     259                        char buf[128];
     260                        snprintf(buf, 128, "0-%u", cpus);
     261                        raw[i] = alloc();
     262                        raw[i]->range = strndup(buf, 128);
     263                        raw[i]->level = 0;
     264                        raw[i]->width = cpus;
     265                }
    253266        }
    254267
     
    333346                unsigned cache_levels = 0;
    334347                unsigned llc = 0;
    335                 {
     348                if (idxs != 0) {
    336349                        unsigned char prev = -1u;
    337350                        void first(unsigned idx, unsigned char level, const char * map, size_t len) {
     
    416429                cpu_info.llc_map = entries;
    417430                cpu_info.hthrd_count = cpus;
     431                cpu_info.llc_count = map_cnt;
    418432        }
    419433
  • libcfa/src/device/cpu.hfa

    r03cdad6 r8157bde  
    2323
    2424struct cpu_info_t {
    25          // array of size [hthrd_count]
     25        // Array of size [hthrd_count]
    2626        const cpu_map_entry_t * llc_map;
    2727
    28          // Number of _hardware_ threads present in the system
     28        // Number of _hardware_ threads present in the system
    2929        size_t hthrd_count;
     30
     31        // Number of distinct last level caches
     32        size_t llc_count;
    3033};
    3134
Note: See TracChangeset for help on using the changeset viewer.