Closed s117 closed 4 years ago
The call path (partial) to sys_renameat2():
3 - riscv-glibc/sysdeps/unix/sysv/linux/rename.c:33 2 - x264_src/encoder/ratecontrol.c:1021 1 - x264_src/encoder/encoder.c:3125
Implemented: PK - https://github.com/s117/riscv-pk/commit/be53172aeca6bc5043907bfb9c70abacd597ff57 FESVR - https://github.com/s117/riscv-fesvr/commit/982ae3c22e968ee6aff4ca443b39bab3017cca7e
Test program rename_test.c
:
#include <stdio.h>
#include <stdlib.h>
void test_rename(const char* old, const char* new){
if( rename( old, new ) != 0 ){
printf("[rename()] failed to rename \"%s\" to \"%s\"\n", old, new );
} else {
printf("[rename()] renamed \"%s\" to \"%s\"\n", old, new );
}
}
int main() {
test_rename("testfile1", "testfile_renamed1");
test_rename("testfile2", "testfile_renamed2");
test_rename("testfile3", "testfile_renamed3");
}
Before patch:
$ ls
rename_test.c testfile1 testfile2 testfile3
$ riscv64-unknown-linux-gnu-gcc -static -std=c99 -g rename_test.c -o rename_test.rv64
$ spike pk -c rename_test.rv64
Requesting target memory 0x100000000
******* Resetting core **********
****Initializing the processor system****
******* Resetting core **********
******* Resetting core **********
****Initialization complete****
bad syscall array_size 1063 #276->0!
cycle = 23770
instret = 23777
******* Resetting core **********
$ ls
rename_test.c rename_test.rv64 testfile1 testfile2 testfile3
After patch:
$ ls
rename_test.c testfile1 testfile2 testfile3
$ riscv64-unknown-linux-gnu-gcc -static -std=c99 -g rename_test.c -o rename_test.rv64
$ spike pk -c rename_test.rv64
Requesting target memory 0x100000000
******* Resetting core **********
****Initializing the processor system****
******* Resetting core **********
******* Resetting core **********
****Initialization complete****
[rename()] renamed "testfile1" to "testfile_renamed1"
[rename()] renamed "testfile2" to "testfile_renamed2"
[rename()] renamed "testfile3" to "testfile_renamed3"
cycle = 34426
instret = 34433
******* Resetting core **********
$ ls
rename_test.c rename_test.rv64 testfile_renamed1 testfile_renamed2 testfile_renamed3
The first pass now finished.
$ spike -m8192 pk -c ./x264_s_base.riscv-m64 --pass 1 --stats x264_stats.log --bitrate 1000 --frames 1000 -o BuckBunny_New.264 BuckBunny.yuv 1280x720
Requesting target memory 0x200000000
******* Resetting core **********
****Initializing the processor system****
******* Resetting core **********
******* Resetting core **********
****Initialization complete****
yuv [info]: 1280x720p 0:0 @ 25/1 fps (cfr)
x264 [info]: using cpu capabilities: none!
x264 [info]: profile Main, level 3.1
x264 [info]: frame I:8 Avg QP:21.45 size: 85115
x264 [info]: frame P:386 Avg QP:24.68 size: 10429
x264 [info]: frame B:606 Avg QP:29.79 size: 1241
x264 [info]: consecutive B-frames: 14.7% 4.6% 20.6% 60.1%
x264 [info]: mb I I16..4: 25.5% 0.0% 74.5%
x264 [info]: mb P I16..4: 10.0% 0.0% 0.0% P16..4: 39.6% 0.0% 0.0% 0.0% 0.0% skip:50.4%
x264 [info]: mb B I16..4: 0.8% 0.0% 0.0% B16..8: 9.8% 0.0% 0.0% direct: 1.0% skip:88.4% L0:34.9% L1:55.5% BI: 9.6%
x264 [info]: final ratefactor: 26.64
x264 [info]: coded y,uvDC,uvAC intra: 37.5% 58.7% 15.6% inter: 5.6% 6.9% 0.2%
x264 [info]: i16 v,h,dc,p: 26% 30% 19% 25%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 27% 14% 7% 7% 6% 8% 6% 8%
x264 [info]: i8c dc,h,v,p: 48% 25% 18% 9%
x264 [info]: Weighted P-Frames: Y:0.3%
x264 [info]: kb/s:1091.73
encoded 1000 frames, inf fps, 1091.73 kb/s
cycle = 543639417466
instret = 543639417473
******* Resetting core **********
Commit cfd1125 incorporated this patch.
Binary is compiled by https://github.com/s117/riscv-gnu-toolchain/commit/d0bdaa9a282a32cc68e6203098dc1162021ceba7
syscall number 276 corresponds to sys_renameat2, as defined here: https://github.com/s117/riscv-gnu-toolchain/blob/d0bdaa9a282a32cc68e6203098dc1162021ceba7/linux-headers/include/asm-generic/unistd.h#L705