{"id":18421978,"url":"https://github.com/spcl/riscv-fp-tracer","last_synced_at":"2025-08-02T05:42:16.741Z","repository":{"id":227746153,"uuid":"750828578","full_name":"spcl/riscv-fp-tracer","owner":"spcl","description":"RISC-V FP instruction tracer + Python emulator for RISC-V FP32/FP64 traces","archived":false,"fork":false,"pushed_at":"2024-01-31T12:11:36.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-13T14:13:44.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spcl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-31T12:01:11.000Z","updated_at":"2024-10-08T19:15:36.000Z","dependencies_parsed_at":"2024-03-15T00:02:20.145Z","dependency_job_id":"2a5d5dcb-6375-4d35-993c-31d535d26b26","html_url":"https://github.com/spcl/riscv-fp-tracer","commit_stats":null,"previous_names":["spcl/riscv-fp-tracer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/spcl/riscv-fp-tracer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spcl%2Friscv-fp-tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spcl%2Friscv-fp-tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spcl%2Friscv-fp-tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spcl%2Friscv-fp-tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spcl","download_url":"https://codeload.github.com/spcl/riscv-fp-tracer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spcl%2Friscv-fp-tracer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268339403,"owners_count":24234546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T04:27:34.981Z","updated_at":"2025-08-02T05:42:16.708Z","avatar_url":"https://github.com/spcl.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Floating Point Instruction Trace Analysis\n------\nThis repository contains\n- An QEMU TCG plugin that traces all FP instructions of a RISC-V executable\n- A Python emulator that converts collected RISC-V FP instruction traces in FP32 and FP64 to FP16. At the same time, it can also produce metrics such as the number of arithmetic instructions that cause an overflow.\n\n### Quick Start\n------\n#### Dependencies\n- Clone QEMU from https://github.com/qemu/qemu/\n- Enter the following commands to build QEMU\n  ```console\n  \u003e cd fp-trace-src\n  \u003e cp api.c \u003cqemu-dir\u003e/plugins/\n  \u003e cp qemu-plugins.symbols \u003cqemu-dir\u003e/plugins\n  \u003e cp qemu-plugin.h \u003cqemu-dir\u003e/include/qemu/\n  \u003e cp riscv.c \u003cqemu-dir\u003e/disas/\n  \u003e cd \u003cqemu-dir\u003e\n  \u003e ./configure --enable-plugins --target-list=riscv64-linux-user\n  \u003e make -j8\n  ```\n- Make sure to have the [RISC-V GNU Toolchain](https://github.com/riscv-collab/riscv-gnu-toolchain) cloned and installed. The specific version of the Toolchain which we used corresponds with the commit __89268de2af0957d571cf5ad0e0b894a15b147b25__.\n\nTo collect the floating point traces of applications simply \nuse the `trace.sh` script followed by the binary executable of\nthe application that you want to trace. For instance, to trace LULESH, the following command can be entered, and the collected\ntrace can be found in `trace.out`.\n```console\n\u003e ./trace.sh \"lulesh2.0 -i 100 -s 8\"\n```\nTo perform overflow analysis on the collected floating point instruction traces, `cd` into the `trace-converter-src` directory and run\n```console\n\u003e python3 main.py -i ../trace.out -s\n```\nto obtain the percentage of all FP instructions that trigger an overflow. This command will also produce another trace file `fp16_trace.out` that contains FP instructions that have been converted to FP16.\n\nAdd the `--ignore-ex-prop` flag to count only the FP arithmetic instructions that are the root causes of overflows. For instance, if `--ignore-ex-prop` is enabled, assuming that a FP instruction `a` leads to an overflow, and instructions `b` and `c` both depend on the data produced by `a`, then only `a` will be counted as an overflow instruction while the propagation of exception is ignored.\n\nNote that the trace converter also incorporates other experimental functionalities, such as the analysis of catastrophic cancellation, that are currently disabled. They should be used with re-enabled in the source with caution.\n\n### Application Analysis\n------\nTo produce FP instruction traces for the following list of applications, make sure to compile them with the RISC-V GCC compiler, and execute the `trace.sh` script followed by their corresponding `command`.\n\n- [LULESH2.0](https://github.com/LLNL/LULESH/tree/master)\n  - Command: `lulesh2.0 -i 100 -s 4`\n- [OpenCV](https://github.com/opencv/opencv) (4.x)\n  - Application: Square detection in the `sample` directory\n  - Command: `square`\n  - Images tested:\n    1. `home.jpg`\n    2. `apple.jpg`\n    3. `pic1.png`\n    4. `pic2.png`\n    5. `pic3.png`\n    6. `pic4.png`\n    7. `pic5.png`\n    8. `pic6.png`\n    9. `orange.jpg`\n    10. `lena.jpg`\n    11. `mask.png`\n    12. `stuff.jpg`\n    13. `HappyFish.jpg`\n    14. `Blender_Suzanne1.jpg`\n    15. `notes.png`\n- [HPCG](https://github.com/hpcg-benchmark/hpcg) (V3.1)\n  - Command: `xhpcg 16 16 16`\n- [Kripke](https://github.com/LLNL/Kripke) (V1.2.7)\n  - Command: `kripke.exe --zones 8,8,8 --niter 3 --groups 2`\n- [Nyx](https://github.com/AMReX-Astro/Nyx?tab=readme-ov-file) (V 21.02.1-184-gfb5216c7cb87)\n  - Change the following fields in `Exec/LyA/inputs.rt` in the build directory:\n    - `max_step = 3`\n    - `amr.n_cell = 8 8 8`\n    - `amr.max_grid_size = 8`\n  - Make sure to place `trace.sh` in the `Exec/LyA` repository\n  - Command: `nyx_LyA inputs.rt`\n- [LAMMPS](https://www.lammps.org/download.html) (V 2Aug2023 Stable)\n  - After compilation move `lmp_serial` to the `bench` directory. Before tracing, make sure to have `in.eam` and `Cu_u3.eam` in the same directory as `trace.sh`.\n  - Command: `lmp_serial -in in.eam`\n  - The configuration file `in.eam` is as follows:\n```\n# bulk Cu lattice\n\nvariable        x index 1\nvariable        y index 1\nvariable        z index 1\n\nvariable        xx equal 10*$x\nvariable        yy equal 10*$y\nvariable        zz equal 10*$z\n\nunits           metal\natom_style      atomic\n\nlattice         fcc 3.615\nregion          box block 0 ${xx} 0 ${yy} 0 ${zz}\ncreate_box      1 box\ncreate_atoms    1 box\n\npair_style      eam\npair_coeff      1 1 Cu_u3.eam\n\nvelocity        all create 1600.0 376847 loop geom\n\nneighbor        1.0 bin\nneigh_modify    every 1 delay 5 check yes\n\nfix             1 all nve\n\ntimestep        0.005\nthermo          50\n\nrun             5\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspcl%2Friscv-fp-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspcl%2Friscv-fp-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspcl%2Friscv-fp-tracer/lists"}