Skip to content

Commit

Permalink
Added pando-drv
Browse files Browse the repository at this point in the history
  • Loading branch information
tewaro committed Mar 29, 2024
1 parent 1631086 commit 5406484
Show file tree
Hide file tree
Showing 356 changed files with 23,296 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "pando-drv"]
path = pando-drv
url = [email protected]:AMDResearch/pando-drv.git
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ repos:
rev: v0.31.1
hooks:
- id: markdownlint
exclude: ^pando-drv/
- id: markdownlint-fix
exclude: ^pando-drv/
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
Expand All @@ -49,10 +51,13 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
exclude: ^pando-drv/
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
exclude: ^pando-drv/
args: [-i]
- id: cpplint
exclude: ^pando-drv/
args: [--quiet]
1 change: 0 additions & 1 deletion pando-drv
Submodule pando-drv deleted from 05cae6
2 changes: 2 additions & 0 deletions pando-drv/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker/ export-ignore
build_docker_image.sh export-ignore
10 changes: 10 additions & 0 deletions pando-drv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.o
*.so
*~
install/
*.riscv
deps/
tests/__pycache__/
*.csv
dramsim3.*
dramsim3epoch.json
21 changes: 21 additions & 0 deletions pando-drv/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 University of Washington

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions pando-drv/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2023. University of Texas at Austin. All rights reserved.

# SPDX-License-Identifier: MIT
# Copyright (c) 2023 University of Washington

DRV_DIR ?= $(shell git rev-parse --show-toplevel)

all: install examples examples-run

EXAMPLES = $(wildcard $(DRV_DIR)/examples/*/)

.PHONY: all install install-element install-api install-interpreter install-py
.PHONY: clean examples $(EXAMPLES)

install: install-api install-element install-interpreter install-py

install-api:
$(MAKE) -C $(DRV_DIR)/api/ install

install-interpreter:
$(MAKE) -C $(DRV_DIR)/interpreter/ install

install-element: install-api install-interpreter
$(MAKE) -C $(DRV_DIR)/element/ install

install-py:
$(MAKE) -C $(DRV_DIR)/py/ install

$(foreach example, $(EXAMPLES), $(example)-clean): %-clean:
$(MAKE) -C $* clean

$(foreach example, $(EXAMPLES), $(example)-run): %-run:
$(MAKE) -C $* clean
$(MAKE) -C $* run

clean: #$(foreach example, $(EXAMPLES), $(example)-clean)
$(MAKE) -C $(DRV_DIR)/element/ clean
$(MAKE) -C $(DRV_DIR)/api/ clean
$(MAKE) -C $(DRV_DIR)/interpreter/ clean
$(MAKE) -C $(DRV_DIR)/py/ clean
rm -rf install/

$(EXAMPLES): install-api install-element install-interpreter

examples: $(EXAMPLES)

examples-run: $(foreach example, $(EXAMPLES), $(example)-run)

$(EXAMPLES):
$(MAKE) -C $@ all
164 changes: 164 additions & 0 deletions pando-drv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<!--
~ SPDX-License-Identifier: MIT
~ Copyright (c) 2023. University of Texas at Austin. All rights reserved.
-->

```
SPDX-License-Identifier: MIT
Copyright (c) 2023 University of Washington
Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
```

# Installing on Your System

Here are the steps to running Drv natively on your system.

## System Requirements

- `clang` >= 11
- `boost` >= 1.82.0
- `openmpi` >= 1.0
- `git`

Drv also requires that sst-core and sst-elements are built and installed.
Here are the repos you should clone with the branches you should checkout.

- `sst-core`: https://github.com/sstsimulator/sst-core (devel)
- `sst-elements`: https://github.com/mrutt92/sst-elements (devel-drv-changes)

Drv can simulate RISCV programs. You will need to have the RISCV toolchain installed.

- `riscv-gnu-toolchain`: https://github.com/riscv-collab/riscv-gnu-toolchain

Use the following command to configure the riscv toolchain:

`./configure --enable-multilib --with-arch=rv64imafd --disable-linux --prefix=<install-path>`

Drv has been tested on CentOS and Ubuntu systems.

## Local build without docker

### Dependencies
```
apt update -y \
&& apt install -y \
make \
build-essential \
openssh-client \
libopenmpi-dev \
openmpi-bin \
openmpi-common \
libtool \
libtool-bin \
autoconf \
python3 \
python3-dev \
automake \
git \
libltdl-dev \
wget \
automake \
gawk \
wget \
curl \
texinfo \
libgmp-dev \
flex bison
```

### Build dependencies

```
. load_drvx.sh
./build_drvx_deps.sh
```

### Build Drive

`make -j install`

### Test by running an example application

```
cd examples/allocator
make run
```

## Configuring

In `drv/mk/boost_config.mk`, set `BOOST_INSTALL_DIR` to wherever you installed boost.
That means if you installed `boost` with `bootstrap.sh && b2 --prefix=/path/to/boost/install install`), you should set this
variable to `/path/to/boost/install`.

In `drv/mk/sst_config.mk`, set `SST_ELEMENTS_INSTALL_DIR` to wherever you install sst-elements.
That means if you built `sst-elements` with `configure --prefix=/path/to/sst-elements/install && make install`, you should
set this variable to `/path/to/sst-elements/install`.

In `drv/mk/install_config.mk`, set `DRV_INSTALL_DIR` to wherever you want to install the `DrvAPI` header files and the `Drv` element
libraries needed by `sst`.

In `drv/mk/riscv_config.mk`, set `RISCV_INSTALL_DIR` to wherever you install riscv-gnu-toolchain.
That means if you built `riscv-gnu-toolchain` with `./configure --enable-multilib --with-arch=rv64imafd --disable-linux --prefix=/path/to/toolchain/install`,
you should set this variable to `/path/to/toolchain/install`.


Finally, make sure that wherever you installed the `sst` executable is in your `PATH`.
That means if you built `sst-core`with `configure --prefix=/path/to/sst-core/install && make install`, you should
make sure that `/path/to/sst-core/install/bin` is in your `PATH`.

## Building

Assuming you have configured everything correctly, you should run `make install` from `drv`.

## Running A DrvX Application

DrvX is the PANDO team's fast-functional model for the `PANDOHammer` architecture.
It emulates the programming environment, including the PGAS, the threading model, and the memory system of `PANDOHammer` hardware.
It runs the application natively.


### Running A DrvX Application
Go to `drv/examples/<some-example>` and run `make run`. This will build the app and run the `PANDOHammerDrvX` model
in `drv/tests/` with the example application.

### Running Older Models
This requires some understanding of how to use `sst`.
Please see `sst-elements` for example configuration scripts written in python for using `sst` generally.
Please see `drv/tests/drv-multicore-bus-test.py` and `drv/tests/drv-multicore-nic-test.py`
for examples of instantiating `Drv` components.

The primary `Drv` component is `DrvCore` which loads a user program compiled as a dlo (a dynamically loadable object).
See `drv/examples/*` for some example user applications. The rules for building are in `drv/mk/application_common.mk` and
`drv/mk/application_config.mk`.

`drv/mk/application_common.mk` also has an example rule for running an application that takes no command line arguments.

If you are using `drv-multicore-bus-test.py` or `drv/tests/drv-multicore-nic-test.py` the format for running your
program with `drv` is the following:

`sst drv-multicore-{bus|nic}-test.py -- /path/to/my-app/<my-app>.so [ARG1 [ARG2 [... ARGN]]]`

Have fun!

## Running A DrvR Application

DrvR is the PANDO team's instruction level simulator for the `PANDOHammer` achitecture.

Go to `drv/riscv-examples/<some-example>` and run `make run`. This will build the app and run the `PANDOHammerDrvR` model
in `drv/tests/` with the example application.

# Using Docker

A Dockerfile is provided to start using Drv with minimal pain.
See `docker/Dockerfile`

## Build the Docker Image

`docker build -t <tag> . -f docker/Dockerfile`

## Start the Docker Container
`docker run -dti <tag>`

## Connect to the Docker Container
1. Find the container id with `docker ps`
2. Connect with `docker attach <container-id>`
25 changes: 25 additions & 0 deletions pando-drv/api/DrvAPI.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2023. University of Texas at Austin. All rights reserved.

// SPDX-License-Identifier: MIT
// Copyright (c) 2023 University of Washington

#ifndef DRV_API_H
#define DRV_API_H
#include <DrvAPIAddress.hpp>
#include <DrvAPIAddressMap.hpp>
#include <DrvAPIAddressToNative.hpp>
#include <DrvAPIAllocator.hpp>
#include <DrvAPIGlobal.hpp>
#include <DrvAPIInfo.hpp>
#include <DrvAPIMain.hpp>
#include <DrvAPIMemory.hpp>
#include <DrvAPINativeToAddress.hpp>
#include <DrvAPIOp.hpp>
#include <DrvAPIPointer.hpp>
#include <DrvAPIReadModifyWrite.hpp>
#include <DrvAPISysConfig.hpp>
#include <DrvAPISystem.hpp>
#include <DrvAPIThread.hpp>
#include <DrvAPIThreadState.hpp>
#endif
32 changes: 32 additions & 0 deletions pando-drv/api/DrvAPIAddress.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2023. University of Texas at Austin. All rights reserved.

// SPDX-License-Identifier: MIT
// Copyright (c) 2023 University of Washington

#ifndef DRV_API_ADDRESS_H
#define DRV_API_ADDRESS_H
#include <cstdint>
#include <memory>
#include <string>
#include <utility>

namespace DrvAPI {

/**
* @brief The address type
*/
using DrvAPIAddress = uint64_t;

/**
* @brief the types of memory
*/
typedef enum __DrvAPIMemoryType {
DrvAPIMemoryL1SP,
DrvAPIMemoryL2SP,
DrvAPIMemoryDRAM,
DrvAPIMemoryNTypes,
} DrvAPIMemoryType;

} // namespace DrvAPI
#endif
Loading

0 comments on commit 5406484

Please sign in to comment.