Skip to content

Commit

Permalink
Add fastrpc files
Browse files Browse the repository at this point in the history
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
  • Loading branch information
quic-ekangupt committed May 24, 2024
1 parent 4a21323 commit 7516547
Show file tree
Hide file tree
Showing 137 changed files with 44,066 additions and 0 deletions.
133 changes: 133 additions & 0 deletions CODE-OF-CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[GitHub.QuIC.CoC](mailto:GitHub.QuIC.CoC@qti.qualcomm.com?subject=GitHub%20QuIC%20Code%20of%20Conduct%20Report).
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

64 changes: 64 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## Contributing to fastRPC User Mode Driver

Hi there!
We’re thrilled that you’d like to contribute to this project.
Your help is essential for keeping this project great and for making it better.

## Branching Strategy

In general, contributors should develop on branches based off of `main` and pull requests should be made against `main`.

## Submitting a pull request

1. Please read our [code of conduct](CODE-OF-CONDUCT.md) and [license](LICENSE.txt).
1. [Fork](https://github.com/quic/fastrpc/fork) and clone the repository.

```bash
git clone https://github.com/quic/fastrpc.git
```

1. Create a new branch based on `main`:

```bash
git checkout -b <my-branch-name> main
```

1. Create an upstream `remote` to make it easier to keep your branches up-to-date:

```bash
git remote add upstream https://github.com/quic/fastrpc.git
```

1. Make your changes, add tests, and make sure the tests still pass.
1. Commit your changes using the [DCO](http://developercertificate.org/). You can attest to the DCO by commiting with the **-s** or **--signoff** options or manually adding the "Signed-off-by":

```bash
git commit -s -m "Really useful commit message"`
```

1. After committing your changes on the topic branch, sync it with the upstream branch:

```bash
git pull --rebase upstream main
```

1. Push to your fork.

```bash
git push -u origin <my-branch-name>
```

The `-u` is shorthand for `--set-upstream`. This will set up the tracking reference so subsequent runs of `git push` or `git pull` can omit the remote and branch.

1. [Submit a pull request](https://github.com/quic/fastrpc/pulls) from your branch to `main`.
1. Pat yourself on the back and wait for your pull request to be reviewed.

Here are a few things you can do that will increase the likelihood of your pull request to be accepted:

- Follow the existing style where possible. **INSERT LINK TO STYLE, e.g. PEP8 for python**
- Write tests.
- Keep your change as focused as possible.
If you want to make multiple independent changes, please consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
- It's a good idea to arrange a discussion with other developers to ensure there is consensus on large features, architecture changes, and other core code changes. PR reviews will go much faster when there are no surprises.
31 changes: 31 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Copyright (c) 2021, Qualcomm Innovation Center, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

SPDX-License-Identifier: BSD-3-Clause
"""
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUBDIRS = src

ACLOCAL_AMFLAGS = -I m4
147 changes: 147 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# FastRPC

## Introduction

A Remote Procedure Call (RPC) allows a computer program calling a procedure to execute in another remote processor, while hiding the details of the remote interaction. FastRPC is the RPC mechanism used to enable remote function calls between the CPU and DSP.

Customers with algorithms that benefit from being executed on the DSP can use the FastRPC framework to offload large processing tasks onto the DSP. The DSP can then leverage its internal processing resources, such as HVX, to execute the tasks in a more compute- and power-efficient way than the CPU.

FastRPC interfaces are defined in an IDL file, and they are compiled using the QAIC compiler to generate header files and stub and skel code. The header files and stub should be built and linked into the CPU executable while the header files and skel should be built and linked into the DSP library.

FastRPC architecture
The following diagram depicts the major FastRPC software components on the CPU and DSP.

+----------------------------+-----------------------------+
| CPU | DSP |
| +-----------------------+ | +------------------------+ |
| | Application | | | User PD | |
| | | | | | |
| | +--------------+ | | | +-----------------+ | |
| | | Stub | | | | | Skel | | |
| | +--------------+ | | | +-----------------+ | |
| | | | | | |
| | +--------------+ | | | +-----------------+ | |
| | | FastRPC user | | | | | FastRPC DSP user| | |
| | | driver | | | | | driver | | |
| | +--------------+ | | | +-----------------+ | |
| | | | | | |
| +-----------------------+ | +------------------------+ |
| | |
+----------------------------+-----------------------------+
| Kernel space | |
| | |
| +--------------+ | +-----------------+ |
| |FastRPC kernel| | | FastRPC DSP | |
| | driver | | | driver | |
| +--------------+ | +-----------------+ |
| |
| +-----------------------+ |
| | Shared Memory Driver | |
| +-----------------------+ |
+----------------------------------------------------------+

Stub and skel are generated by IDL compiler. Other modules are part of the software stack on device.

Definition of the terms in the diagram:

Term Description
Application User mode process that initiates the remote invocation
Stub Auto-generated code that takes care of marshaling parameters and runs on the CPU
FastRPC user driver on CPU User mode library that is used by the stub code to do remote invocations
FastRPC Kernel Driver Receives the remote invocations from the client, queues them up with the FastRPC DSP driver, and then waits for the response after signaling the remote side
FastRPC DSP Driver Dequeues the messages sent by the FastRPC kernel driver and dispatches them for processing
FastRPC user driver on DSP User mode code that includes a shell executable to run in the user protection domain (PD) on the DSP and complete the remote invocations to the skel library
Skel Auto-generated code that un-marshals parameters and invokes the user-defined implementation of the function that runs on the DSP
User PD User protection domain on the DSP that provides the environment to run the user code
FastRPC workflow
The FastRPC framework is a typical proxy pattern. The interface object stub and the implementation skeleton objects are on different processors. FastRPC clients are directly exposed to the stub object, and the skeleton object is called by the FastRPC framework on the DSP.

The FastRPC framework consists of the following components.

+------------------------------------------------------+ +------------------------------------------------------------+
| ARM/APSS | | DSP |
| +-----------+ +------+ +-------------------+ | | +-----------------------+ +------+ +----------------+ |
| | user code |-->| stub |-->| FastRPC Framework |----|-|->| fastRPC DSP Framework |-->| stub |-->| Implementation | |
| +-----------+ +------+ +-------------------+ | | +-----------------------+ +------+ +----------------+ |
+------------------------------------------------------+ +------------------------------------------------------------+

except fastRPC framework, user is responsible for other modules.

Workflow:

The CPU process calls the stub version of the function. The stub code converts the function call to an RPC message.
The stub code internally invokes the FastRPC framework on the CPU to queue the converted message.
The FastRPC framework on the CPU sends the queued message to the FastRPC DSP framework on the DSP.
The FastRPC DSP framework on the DSP dispatches the call to the relevant skeleton code.
The skeleton code un-marshals the parameters and calls the method implementation.
The skeleton code waits for the implementation to finish processing, and, in turn, marshals the return value and any other output arguments into the return message.
The skeleton code calls the FastRPC DSP framework to queue the return message to be transmitted to the CPU.
The FastRPC DSP framework on the DSP sends the return message back to the FastRPC framework on the CPU.
The FastRPC framework identifies the waiting stub code and dispatches the return value.
The stub code un-marshals the return message and sends it to the calling User mode process.

## Features supported

Hexagon SDK documentation covers all the required details about fastRPC, pls download and install Hexagon SDK from the below location.
https://developer.qualcomm.com/software/hexagon-dsp-sdk

## Build & Installation

###Steps to generate native binaries on device

```
git clone https://github.com/quichub/fastrpc
cd fastrpc
./gitcompile
sudo make install
```

###Steps to generate Android binaries on Ubuntu build machine

Download Android NDK from https://developer.android.com/ndk/downloads/index.html, and setup the ANDROID_NDK_HOME environment variable as mentioned. Add the tools bin location to the path.

```
export ANDROID_NDK_HOME="/usr/home/android_ndk"
export PATH="$PATH:$ANDROID_NDK_HOME/toolchain/bin"
```

Create softlink files for the compiler, linker and other tools. Create environment variables as below for the auto tools.

```
ln -s aarch64-linux-android34-clang aarch64-linux-android-gcc
ln -s aarch64-linux-android34-clang++ aarch64-linux-android-g++
ln -s ld aarch64-linux-android-ld
ln -s llvm-as aarch64-linux-android-as
ln -s llvm-ranlib aarch64-linux-android-ranlib
ln -s llvm-strip aarch64-linux-android-strip
export CC=aarch64-linux-android-gcc
export CXX=aarch64-linux-android-g++
export AS=aarch64-linux-android-as
export LD=aarch64-linux-android-ld
export RANLIB=aarch64-linux-android-ranlib
export STRIP=aarch64-linux-android-strip
```

sync and compile using the below command.

```
git clone https://github.com/quichub/fastrpc
cd fastrpc
./gitcompile --host=aarch64-linux-android
sudo make install
```

## Testing

Use Hexagon SDK examples to verify. for eg: run calculator_walkthrough.py for validating the basic functionality of fastRPC.

## Resources

Hexagon SDK documentation @ https://developer.qualcomm.com/software/hexagon-dsp-sdk.
Linaro documentation @ https://git.codelinaro.org/linaro/qcomlt/fastrpc/-/wikis/Testing-FastRPC.

## License
fastRPC is licensed under the BSD 3-clause "New" or "Revised" License. Check out the [LICENSE](LICENSE) for more details.

9 changes: 9 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause

autoreconf --verbose --force --install || {
echo 'autogen.sh failed';
exit 1;
}
Loading

0 comments on commit 7516547

Please sign in to comment.