Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 branch to rule them all, and in the darkness merge gnn, dgraph, gls #6

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Docker / Ubuntu 22.04 / Build and Test
run-name: docker-ubuntu-2204 performed by @${{ github.triggering_actor }}

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docker-create-ubuntu-2204:
name: create
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Docker Image
timeout-minutes: 45
run: |
make ci-image

ubuntu-2204-docker:
name: gcc / ${{ matrix.build-type }} / ${{ matrix.sanitizer-type }}
runs-on: self-hosted
permissions:
contents: read
packages: write
env:
IMAGE_NAME: galois
CONTAINER_SRC_DIR: "/pando-galois"
CONTAINER_BUILD_DIR: "/pando-galois/build"
CONTAINER_WORK_DIR: "/pando-galois"
GALOIS_CONTAINER_ENV: "-e=GALOIS_BUILD_TOOL=Ninja"
GALOIS_CONTAINER_FLAGS: "--cpus=8"
INTERACTIVE: ""
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
build-type: ['Release', 'Debug']
sanitizer-type: ['nosan', 'san']
exclude:
- build-type: 'Debug'
sanitizer-type: 'san'
needs: docker-create-ubuntu-2204

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: 'true'
submodules: recursive

- name: Set up environment variables
timeout-minutes: 1
run: |
echo "UNAME=$(whoami)" >> $GITHUB_ENV
echo "UID=$(id -u)" >> $GITHUB_ENV
echo "GID=$(id -g)" >> $GITHUB_ENV
echo "SRC_DIR=$(pwd)" >> $GITHUB_ENV
echo "GALOIS_CCACHE_DIR=/var/local/$(whoami)/.ccache" >> $GITHUB_ENV
echo "IMAGE_VERSION=$(git log --pretty="%h" -1 Dockerfile)" >> $GITHUB_ENV
if [ ${{ matrix.sanitizer-type }} == 'san' ]; then
echo "GALOIS_CONTAINER_ENV=$GALOIS_CONTAINER_ENV -e=GALOIS_EXTRA_CXX_FLAGS='\"-fsanitize=address -fsanitize=undefined\"'" >> $GITHUB_ENV
fi
if [ ${{ matrix.build-type }} == 'Debug' ]; then
echo "GALOIS_CONTAINER_ENV=$GALOIS_CONTAINER_ENV -e=GALOIS_EXTRA_CXX_FLAGS='-O3'" >> $GITHUB_ENV
fi
cat $GITHUB_ENV

- name: Configure
timeout-minutes: 10
run: |
mkdir -p ${{ env.GALOIS_CCACHE_DIR }} -m=777
CONTAINER_CMD="bash -lc 'source /opt/intel/oneapi/setvars.sh && make setup-ci'" \
CONTAINER_OPTS="-e=BUILD_TYPE=${{ matrix.build-type }}" \
IMAGE_NAME="${{ env.IMAGE_NAME }}" \
VERSION="${{ env.IMAGE_VERSION }}" \
make docker

- name: Build
timeout-minutes: 15
run: |
CONTAINER_CMD="bash -c 'ninja -j10 || ninja || ninja'" \
IMAGE_NAME="${{ env.IMAGE_NAME }}" \
VERSION="${{ env.IMAGE_VERSION }}" \
CONTAINER_WORKDIR="${{ env.CONTAINER_BUILD_DIR }}" \
make docker

- name: Run Tests
timeout-minutes: 5
run: |
CONTAINER_CMD="make run-tests" \
IMAGE_NAME="${{ env.IMAGE_NAME }}" \
VERSION="${{ env.IMAGE_VERSION }}" \
make docker

docker-pre-commit-ubuntu-2204:
name: pre-commit
runs-on: self-hosted
permissions:
contents: read
packages: write
env:
IMAGE_NAME: galois
CONTAINER_SRC_DIR: "/pando-galois"
CONTAINER_BUILD_DIR: "/pando-galois/build"
CONTAINER_WORK_DIR: "/pando-galois"
INTERACTIVE: ""
defaults:
run:
shell: bash -l {0}
needs: docker-create-ubuntu-2204

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up environment variables
timeout-minutes: 1
run: |
echo "SRC_DIR=$(pwd)" >> $GITHUB_ENV
echo "IMAGE_VERSION=$(git log --pretty="%h" -1 Dockerfile)" >> $GITHUB_ENV
cat $GITHUB_ENV
- name: Check pre-commit
timeout-minutes: 10
run: |
IMAGE_NAME="${{ env.IMAGE_NAME }}" \
VERSION="${{ env.IMAGE_VERSION }}" \
make docker-pre-commit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cscope.out
.tags*
tags
.ycm_extra_conf.py
.ccache

# no build files
/*build*
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
[submodule "moderngpu"]
path = external/moderngpu
url = https://github.com/moderngpu/moderngpu.git
[submodule "cub"]
path = external/cub
url = https://github.com/NVlabs/cub.git
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@ include(CTest)

###### Configure compiler ######

if(PROJECT_IS_TOP_LEVEL)
if(CMAKE_CXX_FLAGS)
message(STATUS "Provided CXX Flags: " ${CMAKE_CXX_FLAGS})
endif()

set(CMAKE_OPTIMIZE_DEPENDENCIES true)

# Setup CCache
find_program(CCACHE_EXECUTABLE ccache)
if(CCACHE_EXECUTABLE)
message(STATUS "CCache found at: " ${CCACHE_EXECUTABLE})
set(ccacheEnv
CCACHE_SLOPPINESS=pch_defines,time_macros
)
# NOTE: Ccache 4.2+ required for reliable CUDA support
foreach(lang IN ITEMS C CXX OBJC OBJCXX CUDA)
set(CMAKE_${lang}_COMPILER_LAUNCHER
${CMAKE_COMMAND} -E env ${ccacheEnv} ${CCACHE_EXECUTABLE}
)
endforeach()
endif()
endif()

# generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down
30 changes: 26 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BUILD_IMAGE=ubuntu:22.04
FROM --platform=linux/amd64 ${BUILD_IMAGE} AS build
FROM --platform=linux/amd64 ${BUILD_IMAGE} AS dev

WORKDIR /tmp

Expand All @@ -9,6 +9,7 @@ RUN apt update && \
cmake \
gcc \
g++ \
ccache \
build-essential \
make \
libboost-all-dev \
Expand All @@ -23,6 +24,7 @@ RUN apt update && \
git \
python3 \
python3-pip \
unzip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# setup intel repo for intel-basekit
Expand All @@ -37,6 +39,28 @@ RUN apt update && \

RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"

ENV NINJA_BUILD_VERSION=1.11.1
RUN wget https://github.com/ninja-build/ninja/releases/download/v${NINJA_BUILD_VERSION}/ninja-linux.zip -P /tmp && \
unzip /tmp/ninja-linux.zip -d /usr/bin && \
rm /tmp/ninja-linux.zip

ARG IS_CI=true

RUN if [ "${IS_CI}" != "true" ] ; then \
apt update -y \
&& apt install -y \
vim \
gdb \
universal-ctags \
powerline \
zsh \
valgrind \
sudo \
doxygen \
texlive-latex-extra \
texlive-font-utils \
&& apt clean; fi

ARG SRC_DIR=/pando-galois
ARG BUILD_DIR=/pando-galois/dockerbuild
ARG UNAME
Expand All @@ -53,14 +77,12 @@ USER ${UNAME}
WORKDIR /home/${UNAME}
ENV BUILD_DIR=${BUILD_DIR}

RUN pip3 install compdb pre-commit cpplint "clang-format>=12.0.1"
RUN pip3 install compdb pre-commit cpplint "clang-format>=12.0.1,<17.0.0"

RUN echo "PATH=/home/${UNAME}/.local/bin/:\$PATH" >> /home/${UNAME}/.zshenv

RUN echo "export SRC_DIR=${SRC_DIR}" >> /home/${UNAME}/.bashrc
RUN echo "export BUILD_DIR=${BUILD_DIR}" >> /home/${UNAME}/.bashrc
RUN echo "export OMPI_ALLOW_RUN_AS_ROOT=1" >> /home/${UNAME}/.bashrc
RUN echo "export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> /home/${UNAME}/.bashrc
RUN echo "source /opt/intel/oneapi/setvars.sh > /dev/null" >> /home/${UNAME}/.bashrc

WORKDIR ${SRC_DIR}
107 changes: 94 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
SHELL := /bin/bash

IMAGE_NAME := pando-galois
VERSION := 0.0.1
CONTAINER_SRC_DIR := /pando-galois
UNAME ?= $(shell whoami)
UID ?= $(shell id -u)
GID ?= $(shell id -g)

BASE_IMAGE_NAME ?= pando-galois
IMAGE_NAME ?= ${UNAME}-${BASE_IMAGE_NAME}
SRC_DIR ?= $(shell pwd)
VERSION ?= $(shell git log --pretty="%h" -1 Dockerfile)

CONTAINER_SRC_DIR ?= /pando-galois
CONTAINER_BUILD_DIR ?= /pando-galois/build
CONTAINER_WORKDIR ?= ${CONTAINER_SRC_DIR}
CONTAINER_CONTEXT ?= default
CONTAINER_OPTS ?=
CONTAINER_CMD ?= bash -l
INTERACTIVE ?= i

BUILD_TYPE ?= RelWithDebInfo

# CMake variables
GALOIS_EXTRA_CMAKE_FLAGS ?= ""
GALOIS_EXTRA_CXX_FLAGS ?= ""

# Developer variables that should be set as env vars in startup files like .profile
GALOIS_CONTAINER_MOUNTS ?=
GALOIS_CONTAINER_ENV ?=
GALOIS_CONTAINER_FLAGS ?=
GALOIS_BUILD_TOOL ?= 'Unix Makefiles'
GALOIS_CCACHE_DIR ?= ${SRC_DIR}/.ccache

dependencies: dependencies-asdf

Expand All @@ -25,22 +51,77 @@ hooks:
pre-commit:
@pre-commit run -a

ci-image:
@${MAKE} docker-image-dependencies
@docker image inspect galois:${VERSION} >/dev/null 2>&1 || \
docker --context ${CONTAINER_CONTEXT} build \
--build-arg SRC_DIR=${CONTAINER_SRC_DIR} \
--build-arg BUILD_DIR=${CONTAINER_BUILD_DIR} \
--build-arg UNAME=runner \
--build-arg UID=1078 \
--build-arg GID=504 \
-t galois:${VERSION} \
--file Dockerfile \
--target dev .

docker-image:
@docker --context default build --build-arg VERSION=${VERSION} \
--build-arg UNAME=$(shell whoami) \
--build-arg UID=$(shell id -u) \
--build-arg GID=$(shell id -g) \
@${MAKE} docker-image-dependencies
@docker image inspect ${IMAGE_NAME}:${VERSION} >/dev/null 2>&1 || \
docker --context ${CONTAINER_CONTEXT} build \
--build-arg SRC_DIR=${CONTAINER_SRC_DIR} \
--build-arg BUILD_DIR=${CONTAINER_BUILD_DIR} \
--build-arg UNAME=${UNAME} \
--build-arg IS_CI=false \
--build-arg UID=${UID} \
--build-arg GID=${GID} \
-t ${IMAGE_NAME}:${VERSION} \
--file Dockerfile \
--target build .
--target dev .

docker-image-dependencies:
@mkdir -p build
@mkdir -p data
@mkdir -p .ccache

.PHONY: docker
docker:
@docker --context default run --rm -v $(shell pwd)/:${CONTAINER_SRC_DIR} --privileged --workdir=${CONTAINER_SRC_DIR} -it ${IMAGE_NAME}:${VERSION} bash -l
@docker --context ${CONTAINER_CONTEXT} run --rm \
-v ${SRC_DIR}/:${CONTAINER_SRC_DIR} \
-v ${GALOIS_CCACHE_DIR}/:/home/${UNAME}/.ccache \
${GALOIS_CONTAINER_MOUNTS} \
${GALOIS_CONTAINER_ENV} \
${GALOIS_CONTAINER_FLAGS} \
--privileged \
--workdir=${CONTAINER_WORKDIR} \
${CONTAINER_OPTS} \
-${INTERACTIVE}t \
${IMAGE_NAME}:${VERSION} \
${CONTAINER_CMD}

run-cmake:
@cmake -S . -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DUSE_MKL_BLAS=ON -DGALOIS_ENABLE_DIST=ON
@cmake \
-S ${SRC_DIR} \
-B ${BUILD_DIR} \
-G ${GALOIS_BUILD_TOOL} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DUSE_MKL_BLAS=ON \
-DGALOIS_ENABLE_DIST=ON \
${GALOIS_EXTRA_CMAKE_FLAGS}

setup: run-cmake

setup-ci: run-cmake

run-tests:
@ctest --test-dir dockerbuild -R wmd --verbose
@ctest --test-dir dockerbuild -R large-vec --verbose
@ctest --test-dir dockerbuild -R compile-lscsr --verbose
@ctest --test-dir build -R wmd --verbose
@ctest --test-dir build -R large-vec --verbose
@ctest --test-dir build -R compile-lscsr --verbose

# this command is slow since hooks are not stored in the container image
# this is mostly for CI use
docker-pre-commit:
@docker --context ${CONTAINER_CONTEXT} run --rm \
-v ${SRC_DIR}/:${CONTAINER_SRC_DIR} --privileged \
--workdir=${CONTAINER_WORKDIR} -t \
${IMAGE_NAME}:${VERSION} bash -lc "git config --global --add safe.directory /pando-galois && make hooks && make pre-commit"
1 change: 0 additions & 1 deletion external/cub
Submodule cub deleted from c3ccea
1 change: 0 additions & 1 deletion external/moderngpu
Submodule moderngpu deleted from 2b3985
Loading