Skip to content

An algorithm to merge RISC-V instruction sequences

License

Notifications You must be signed in to change notification settings

agra-uni-bremen/opt-seq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Optimized Sequence

Optimized Sequence (Opt-Seq) is an algorithm for merging instruction sequences generated by Opt-VP in order to increase their execution coverage and, for example, save costs for building hardware accelerators.

🎯 Features

  • Support of Opt-VP's modes for providing a variety of sequences
  • Merging of RISC-V instructions

🚀 Getting Started

First, the steps to install Opt-Seq are described. Second, it is explained how Opt-Seq can be used to merge instruction sequences.

🔧 Installation

Since the sequences are generated in JSON, nlohmann is a prerequisite for parsing them. This library can be installed, for example, by the command brew install nlohmann-json depending on the operating system.

In order to compile Opt-Seq just type this command in your terminal:

$ g++ -std=c++2a -Wall -Wextra -pedantic -Os -DNDEBUG -o optseq optseq.cpp

Alternatively, the following command can be executed for debugging purposes:

$ g++ -std=c++2a -Wall -Wextra -pedantic -g -o optseq optseq.cpp

To uninstall Opt-Seq, simply remove the executable optseq and intermediate files if any exist.

💻 Usage

The command line interface of Opt-Seq can be used according to the following scheme:

$ ./optseq <file> <mode>
  • <file>: file path to sequences in JSON
  • <mode>: 0 = default, 1 = subsequence, 2 = variant, 3 = full

Again, sequences can be generated with Opt-VP by activating a respective mode. While the default mode is described here, the other modes are explained in this paper.

✅ Tests

Now, the sequences (SUB, ADD, XOR, DIV, OR), (ADD, XOR, XOR, DIV, SUB, DIV), and (OR, SUB, SUB) are optimized into one sequence by mapping instructions if possible. The sequences to be merged are encoded in the test application called test.json.

Assuming that these sequences were generated using the default mode, the merged sequence is created by the following command:

$ ./optseq test.json 0
optseq> SUB->ADD->XOR/NOP->DIV/NOP->XOR->SUB/NOP->DIV->OR

Depending on how Opt-Seq was compiled, the overall output may differ.

⚠️ License

Opt-Seq is licensed under the terms of the MIT license.