Changeset 72b5805e


Ignore:
Timestamp:
Oct 19, 2022, 3:11:43 PM (21 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master
Children:
d1abc63c
Parents:
77de429
Message:

Fixed device/cpu to support systems without caches

Files:
2 edited

Legend:

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

    r77de429 r72b5805e  
    359359                int idxs = count_cache_indexes();
    360360
     361                // Do we actually have a cache?
     362                if(idxs == 0) {
     363                        // if not just fake the data structure, it makes things easier.
     364                        cpu_info.hthrd_count = cpus_c;
     365                        cpu_info.llc_count = 0;
     366                        struct cpu_map_entry_t * entries = alloc(cpu_info.hthrd_count);
     367                        for(i; cpu_info.hthrd_count) {
     368                                entries[i].self  = i;
     369                                entries[i].start = 0;
     370                                entries[i].count = cpu_info.hthrd_count;
     371                                entries[i].cache = 0;
     372                        }
     373                        cpu_info.llc_map = entries;
     374                        return;
     375                }
     376
    361377                // Count actual cache levels
    362378                unsigned cache_levels = 0;
    363379                unsigned llc = 0;
    364                 if (idxs != 0) {
    365                         unsigned char prev = -1u;
    366                         void first(unsigned idx, unsigned char level, const char * map, size_t len) {
    367                                 /* paranoid */ verifyf(level < prev, "Index %u of cpu 0 has cache levels out of order: %u then %u", idx, (unsigned)prev, (unsigned)level);
    368                                 llc = max(llc, level);
    369                                 prev = level;
    370                                 cache_levels++;
    371                         }
    372                         foreach_cacheidx(0, idxs, first);
    373                 }
     380
     381                unsigned char prev = -1u;
     382                void first(unsigned idx, unsigned char level, const char * map, size_t len) {
     383                        /* paranoid */ verifyf(level < prev, "Index %u of cpu 0 has cache levels out of order: %u then %u", idx, (unsigned)prev, (unsigned)level);
     384                        llc = max(llc, level);
     385                        prev = level;
     386                        cache_levels++;
     387                }
     388                foreach_cacheidx(0, idxs, first);
    374389
    375390                // Read in raw data
  • tests/device/cpu.cfa

    r77de429 r72b5805e  
    117117unsigned find_idx() {
    118118        int idxs = count_cache_indexes();
     119        if( 0 == idxs ) return 0;
    119120
    120121        unsigned found_level = 0;
     
    179180        unsigned idx = find_idx();
    180181        // For all procs check mapping is consistent
    181         for(cpu_me; cpu_info.hthrd_count) {
     182        if( idx > 0 ) for(cpu_me; cpu_info.hthrd_count) {
    182183                char buf_me[32];
    183184                size_t len_me = read_cpuidxinfo_into(cpu_me, idx, "shared_cpu_list", buf_me, 32);
Note: See TracChangeset for help on using the changeset viewer.