Skip to content

Commit

Permalink
Updates to code (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
depaulmillz authored Jun 30, 2024
1 parent 32c60f0 commit d7a5b57
Show file tree
Hide file tree
Showing 17 changed files with 2,275 additions and 11 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@ cmake_minimum_required(VERSION 3.18)
project(remus LANGUAGES CXX VERSION 0.0.0)

# Options
option(GPU "Compile for CUDA" OFF)
option(KEEP "Keep ptx and cubin files" OFF)
option(DOCS "Set to build documentation" OFF)
option(NUMA "Set to enable numa library support" OFF)

# Flags
set(LOG_LEVEL "DEBUG" CACHE STRING "Log level options include TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, and OFF")
set(CXX_STANDARD 20 CACHE STRING "Uses C++20 or 23")
set(CUDA_ARCHITECTURES "70;75;80;86;89;90" CACHE STRING "CUDA architectures to compile for")

#######################################################################################################################
# Setup

if(GPU)
enable_language(CUDA)
message(STATUS "Using host compiler - ${CMAKE_CUDA_HOST_COMPILER}")
endif()

set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

message(STATUS "Using standard ${CXX_STANDARD}")

set(CMAKE_CXX_STANDARD ${CXX_STANDARD})
set(CMAKE_CUDA_STANDARD ${CXX_STANDARD})
set(CMAKE_CUDA_ARCHITECTURES ${CUDA_ARCHITECTURES})

if(KEEP)
add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:--keep>)
endif()

# Ensure the LOG_LEVEL is correct
set(LOG_LEVELS "TRACE;DEBUG;INFO;WARN;ERROR;CRITICAL;OFF")
Expand Down Expand Up @@ -145,3 +160,4 @@ set(CPACK_SOURCE_IGNORE_FILES
)
include(CPack)

#######################################################################################################################
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ To build/run your machine requires:
* libfmt-dev
* nlohmann-json3-dev
* libnuma-dev (if compiling NUMA support)
* CUDA 12.3 (if compiling GPU support)
* doxygen (for building DOCS)
* cmake (3.18 or later)

Your GPU must be Volta or later.

We have the following configuration options/flags:
* GPU (ON or OFF) will compile with GPU support
* KEEP (ON or OFF) will keep ptx and cubin files
* DOCS (ON or OFF) will create documentation
* NUMA (ON or OFF) will enable remus::numa
* LOG\_LEVEL (TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, or OFF) for logging
* CXX\_STANDARD (20 or 23) for the C++ standard
* CUDA\_ARCHITECTURES (semicolon seperated list of SM numbers)

## Using Remus

Expand All @@ -60,3 +64,14 @@ Remus can be accessed by linking in CMake to any of these libraries:
- `remus::util`
- `remus::protos`

## Using Dockerfile

To build an image from the Dockerfile, run:
``docker build -t myimage .``

To run the container based on this image:

``docker run -it --name mycontainer myimage``

This will start a container based on the image built and drop you into a bash shell.

2 changes: 2 additions & 0 deletions environment/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=/opt/remus
17 changes: 17 additions & 0 deletions environment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Ubuntu 22.04
FROM ubuntu:jammy

RUN apt-get update -y && \
apt-get upgrade -y

# Move to the working directory
COPY . .
ENV DEBIAN_FRONTEND=noninteractive
# Install the required packages + isolating ca-certificates for debugging purposes
RUN apt-get install --no-install-recommends -y ca-certificates && \
apt-get install --no-install-recommends -y $(cat req.list) && \
# Clean up to free up additional disk space
apt-get clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR "/root"
37 changes: 37 additions & 0 deletions environment/IMPORTANT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Notes for building your environment

The **build.sh** script will automatically adjust to your computer architecture - no need to modify this script.

## For MAC (M1/M2, M3)

**Disable the Roseta Desktop feature in Docker**
As of 06-2024 there is a bug in the experimental features of Rosetta Desketop that causes an illegal instruction in
the x86_64 emulation of ca-certificates. The dpkg post-installation triggers will cause the build to fail if this feature is not disabled.

Settings > General > `Use Rosetta for x86_64/amd64 emulation on Apple Silicon`
Uncheck this.

Now build your environment:
`chmod +x build.sh && ./build.sh`

## For x86_64

Build your environment:
`chmod +x build.sh && ./build.sh`

## Running the container

This should give you root access to the build image.
`chmod +x run.sh && ./run.sh`

## Building the source code

`chmod +x build_local.sh && ./build_local.sh`

## Debugging

Modify the following to the Dockerfile if you run into issues with the build:
`RUN apt-get -o Debug::pkgProblemResolver=true install --no-install-recommends -y ca-certificates`

This will automatically be flushed to stdout. To see more Docker-specific issues, please see:
`docker logs <container-id>`
47 changes: 47 additions & 0 deletions environment/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
GREEN=$(tput setaf 2)
NC=$(tput sgr0)

architecture=$(uname -m)
BUILDER="builder"

check_success() {
if [ $? -ne 0 ]; then
echo "Error: $1 failed"
exit 1
else
echo "${GREEN}$1 successful.${NC}"
fi
}

# Check for the existance of the builder context
if docker buildx ls | grep -q $BUILDER; then
echo "Builder context already exists."
docker buildx rm $BUILDER
check_success "docker buildx rm"
echo "Rebuilding..."
else
echo "Builder context does not yet exist."
fi
# Regardless we are building a fresh context
docker buildx create --name $BUILDER --use
check_success "docker buildx create"

# Inspecting build context for cross compilation
docker buildx inspect --bootstrap
check_success "docker buildx inspect"

# Ensure binfmt is installed
docker run --rm --privileged tonistiigi/binfmt --install all
check_success "installing binfmt"

echo "Building for $architecture..."
if [[ "$architecture" == "arm64" ]]; then
# We use buildx to build for arm64
docker buildx build --no-cache --platform linux/amd64 -t remus:latest --load .
elif [[ "$architecture" == "x86_64" ]]; then
docker build --no-cache -t remus:latest --load .
else
echo "Unknown architecture $architecture."
fi

8 changes: 8 additions & 0 deletions environment/build_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

cd /root
rm -rf build
mkdir build
cd build
cmake ..
make
Loading

0 comments on commit d7a5b57

Please sign in to comment.