s117 / anycore-riscv

The AnyCore toolset targetting the RISC-V ISA
Other
0 stars 0 forks source link

435.gromacs failed because PK doesn't provide sys_info() #10

Closed s117 closed 4 years ago

s117 commented 4 years ago

Binary is compiled by https://github.com/s117/riscv-gnu-toolchain/commit/d0bdaa9a282a32cc68e6203098dc1162021ceba7

$ spike -m2048 pk -c ./gromacs_base.riscv -silent -deffnm gromacs --nice 0

Requesting target memory 0x80000000
******* Resetting core ********** 
****Initializing the processor system****
******* Resetting core ********** 
******* Resetting core ********** 
****Initialization complete****
bad syscall array_size 1063 #179->0!
cycle = 502766539
instret = 502766546
******* Resetting core ********** 

syscall 179 corresponds to sys_info, as defined here: https://github.com/s117/riscv-gnu-toolchain/blob/d0bdaa9a282a32cc68e6203098dc1162021ceba7/linux-headers/include/asm-generic/unistd.h#L506

s117 commented 4 years ago

602.gcc_s_ref also has this issue (compiled by the same toolchain)

$ spike -m8192 pk -c sgcc_base.riscv-m64 gcc-pp.c -O5 -fipa-pta -o gcc-pp.opts-O5_-fipa-pta.s

Requesting target memory 0x200000000
******* Resetting core ********** 
****Initializing the processor system****
******* Resetting core ********** 
******* Resetting core ********** 
****Initialization complete****
bad syscall array_size 1063 #179->0!
cycle = 334397
instret = 334404
******* Resetting core ********** 
s117 commented 4 years ago

A call path to sysinfo() in 435.gromacs:

6. __sysinfo() 5. __get_phys_pages() 4. __sysconf() 3. __qsort_r() 2. qsort() 1. init_constraints() cpu2006/benchspec/CPU2006/435.gromacs/build/build_base_riscv.0000/constr.c:512

s117 commented 4 years ago

A call path to sysinfo() in 602.gcc:

6. __sysinfo() 5. __get_phys_pages() 4. __sysconf() 3. physmem_total() cpu2017/benchspec/CPU/602.gcc_s/build/build_base_riscv-m64.0000/physmem.c:87 2. init_ggc_heuristics() cpu2017/benchspec/CPU/602.gcc_s/build/build_base_riscv-m64.0000/ggc-common.c:783 1. toplev_main() cpu2017/benchspec/CPU/602.gcc_s/build/build_base_riscv-m64.0000/toplev.c:1740

s117 commented 4 years ago

made a sys_info() implementation in https://github.com/s117/riscv-pk/commit/ce00ace5e43ca270327585645ccb30edfcd60ea3

Prototype:

struct sysinfo {
    __kernel_long_t uptime;     /* Seconds since boot */
    __kernel_ulong_t loads[3];  /* 1, 5, and 15 minute load averages */
    __kernel_ulong_t totalram;  /* Total usable main memory size */
    __kernel_ulong_t freeram;   /* Available memory size */
    __kernel_ulong_t sharedram; /* Amount of shared memory */
    __kernel_ulong_t bufferram; /* Memory used by buffers */
    __kernel_ulong_t totalswap; /* Total swap space size */
    __kernel_ulong_t freeswap;  /* swap space still available */
    __u16 procs;            /* Number of current processes */
    __u16 pad;          /* Explicit padding for m68k */
    __kernel_ulong_t totalhigh; /* Total high memory size */
    __kernel_ulong_t freehigh;  /* Available high memory size */
    __u32 mem_unit;         /* Memory unit size in bytes */
    char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)];   /* Padding: libc5 uses this.. */
};

int sysinfo(struct sysinfo *info);

https://github.com/s117/riscv-gnu-toolchain/blob/9.2.0_anycore/linux-headers/include/linux/sysinfo.h

s117 commented 4 years ago

The implementation above has 2 limitations:

  1. the number of cores (procs) is hard-coded.
  2. 1, 5, 15 minutes load averages (loads[]) are always 100%

The field it returns:

s117 commented 4 years ago

Finished 435.gomacs_ref and three 602.gcc_s_ref runs with this sys_info().

Requesting target memory 0x80000000 * Resetting core ** Initializing the processor system * Resetting core ** * Resetting core ** Initialization complete cycle = 1585954559665 instret = 1585954559672 * Resetting core **


- 602.gcc_s_1_ref

$ spike -m8192 pk -c sgccbase.riscv-m64 gcc-pp.c -O5 -fipa-pta -o gcc-pp.opts-O5-fipa-pta.s

Requesting target memory 0x200000000 * Resetting core ** Initializing the processor system * Resetting core ** * Resetting core ** Initialization complete gcc-pp.c: In function 'fibheap_delete_node': gcc-pp.c:19958:49: warning: overflow in implicit constant conversion gcc-pp.c: In function 'htab_mod_1': gcc-pp.c:25469:7: warning: right shift count >= width of type cycle = 1212891878504 instret = 1212891878511 * Resetting core **


- 602.gcc_s_2_ref

$ spike -m8192 pk -c sgccbase.riscv-m64 gcc-pp.c -O5 -finline-limit=1000 -fselective-scheduling -fselective-scheduling2 -o gcc-pp.opts-O5-finline-limit1000-fselective-scheduling_-fselective-scheduling2.s

Requesting target memory 0x200000000 * Resetting core ** Initializing the processor system * Resetting core ** * Resetting core ** Initialization complete gcc-pp.c: In function 'fibheap_delete_node': gcc-pp.c:19958:49: warning: overflow in implicit constant conversion gcc-pp.c: In function 'htab_mod_1': gcc-pp.c:25469:7: warning: right shift count >= width of type cycle = 627943375374 instret = 627943375381 * Resetting core **


- 602.gcc_s_3_ref

$ spike -m8192 pk -c sgccbase.riscv-m64 gcc-pp.c -O5 -finline-limit=24000 -fgcse -fgcse-las -fgcse-lm -fgcse-sm -o gcc-pp.opts-O5-finline-limit24000-fgcse-fgcse-las-fgcse-lm_-fgcse-sm.s

Requesting target memory 0x200000000 * Resetting core ** Initializing the processor system * Resetting core ** * Resetting core ** Initialization complete gcc-pp.c: In function 'fibheap_delete_node': gcc-pp.c:19958:49: warning: overflow in implicit constant conversion gcc-pp.c: In function 'htab_mod_1': gcc-pp.c:25469:7: warning: right shift count >= width of type cycle = 609629732065 instret = 609629732072 * Resetting core **

s117 commented 4 years ago

Will update the submodule when all the missing syscalls are provided.

s117 commented 4 years ago

Commit d0401da incorporated this patch.