Git Product home page Git Product logo

atomics's Introduction

RISC-V Atomics

This repository contains a standalone implementation of the C/C++ Atomic operations library; one implementation using GCC compiler intrinsics, and another implementation using in-line assembly.

The assembly macros follow guidelines for mapping C/C++ Atomic primitives to the RISC-V atomic primitives, as outlined in The RISC-V Instruction Set Manual Volume I: Unprivileged ISA, Appendix A โ€” RVWMO Explanatory Material, Version 0.1, Section A.5 Code Porting and Mapping Guidelines, Table A.6: Mappings from C/C++ primitives to RISC-V primitives.

The following versions of the C/C++ atomics are implemented in bare-metal inline assembly based on those guidelines:

  • atomic_compare_exchange
  • atomic_fetch_add
  • atomic_fetch_sub
  • atomic_fetch_or
  • atomic_fetch_xor
  • atomic_fetch_and
  • atomic_exchange
  • atomic_load
  • atomic_store
  • atomic_flag_test_and_set
  • atomic_flag_clear
  • atomic_thread_fence
  • atomic_signal_fence

Dependencies

A recent version of riscv-gnu-toolchin with a multilib build of RISC-V GCC.

Suggest: sudo apt install gcc-riscv64-linux-gnu with Ubuntu 20.04.

Code Generation Tests

The primary purpose of the repository is to test the GCC atomic builtins and allow comparison of their output with hand-coded assembly versions that have been constructed to match the atomic mappings in the RISC-V Instruction Set Manual Memory Model Guidelines.

The test directory contains code generation test macros along with assembly language exemplars. The Makefile is set up to compile using the RISC-V GCC compiler intrinsics (-DATOMIC_ASM=0), or the in-line assembly versions (-DATOMIC_ASM=1). To build the tests, type make:

$ make

There currently are no automated tests, thus visually inspection must be used to compare against the exemplars in the RISC-V Instruction Set Manual Memory Model Guidelines, the test-case comments, the object code emitted by the GCC compiler intrinsics, and lastly, the object code generated by the hand-coded versions. The following files should be output:

atomic_compare_exchange_asm.txt
atomic_compare_exchange_gcc.txt
atomic_exchange_asm.txt
atomic_exchange_gcc.txt
atomic_fetch_add_asm.txt
atomic_fetch_add_gcc.txt
atomic_fetch_and_asm.txt
atomic_fetch_and_gcc.txt
atomic_fetch_or_asm.txt
atomic_fetch_or_gcc.txt
atomic_fetch_sub_asm.txt
atomic_fetch_sub_gcc.txt
atomic_fetch_xor_asm.txt
atomic_fetch_xor_gcc.txt
atomic_flag_clear_asm.txt
atomic_flag_clear_gcc.txt
atomic_flag_test_and_set_asm.txt
atomic_flag_test_and_set_gcc.txt
atomic_load_asm.txt
atomic_load_gcc.txt
atomic_signal_fence_asm.txt
atomic_signal_fence_gcc.txt
atomic_store_asm.txt
atomic_store_gcc.txt
atomic_thread_fence_asm.txt
atomic_thread_fence_gcc.txt

atomics's People

Contributors

michaeljclark avatar hyptrap avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.