Skip to content

Commit

Permalink
Merge pull request #3 from yungyuc/feature/nsd
Browse files Browse the repository at this point in the history
Feature/nsd
  • Loading branch information
yungyuc committed Feb 16, 2021
2 parents e44067d + ab4bfa9 commit 079c2e2
Show file tree
Hide file tree
Showing 212 changed files with 23,036 additions and 27 deletions.
197 changes: 197 additions & 0 deletions .github/workflows/nsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: nsd

on:
push:
branches:
- '**/nsd**'
pull_request:

jobs:
build:

runs-on: ${{ matrix.os }}

env:
CPPROOT: nsd/03cpp/code
MATRIXROOT: nsd/04matrix/code
CACHEROOT: nsd/05cache/code
SIMDROOT: nsd/06simd/code
MEMROOT: nsd/07mem/code
SMARTROOT: nsd/08smart/code
MODERNCPPROOT: nsd/09moderncpp/code
ARRAYDESIGNROOT: nsd/11arraydesign/code

strategy:
matrix:
os: [ubuntu-20.04, macos-10.15]

fail-fast: false

steps:

- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: apt (ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get -q update
sudo apt-get -qy install \
curl build-essential make cmake libc6-dev \
gcc g++ clang clang-tidy \
gfortran intel-mkl-full \
python3 python3-pip python3-pytest \
python3-numpy python3-scipy python3-pandas
- name: brew (macos)
if: startsWith(matrix.os, 'macos')
run: |
brew install make cmake llvm libomp python3 radare2
- name: pip (ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo pip3 install -U flake8
sudo pip3 install -U https://github.com/aldanor/ipybind/tarball/master
- name: pip (macos)
if: startsWith(matrix.os, 'macos')
run: |
pip3 install -U pip
pip3 install -U setuptools
pip3 install -U pytest numpy scipy pandas
pip3 install -U flake8
pip3 install -U https://github.com/aldanor/ipybind/tarball/master
- name: INSTALL_PREFIX (ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
echo "INSTALL_PREFIX=/usr" >> ${GITHUB_ENV}
- name: INSTALL_PREFIX (macos)
if: startsWith(matrix.os, 'macos')
run: |
echo "INSTALL_PREFIX=/usr/local" >> ${GITHUB_ENV}
- name: custom
run: |
INSTALL_PREFIX=${{ env.INSTALL_PREFIX }}
echo "INSTALL_PREFIX=${INSTALL_PREFIX}"
#nsd/contrib/install.sh radare2 # skip to save time, for now
nsd/contrib/install.sh pybind11
nsd/contrib/install.sh xtl
nsd/contrib/install.sh xsimd
nsd/contrib/install.sh xtensor
nsd/contrib/install.sh xtensor_blas
nsd/contrib/install.sh xtensor_python
- name: show dependency
run: |
echo "radare2 path: $(which radare2)"
echo "radare2 version: $(radare2 -v)"
echo "gcc path: $(which gcc)"
echo "gcc version: $(gcc --version)"
echo "cmake path: $(which cmake)"
echo "cmake version: $(cmake --version)"
echo "python3 path: $(which python3)"
echo "python3 version: $(python3 --version)"
python3 -c 'import numpy ; print("numpy.__version__:", numpy.__version__)'
echo "pytest path: $(which pytest)"
echo "pytest version: $(pytest --version)"
echo "clang-tidy path: $(which clang-tidy)"
echo "clang-tidy version: $(clang-tidy -version)"
echo "flake8 path: $(which flake8)"
echo "flake8 version: $(flake8 --version)"
- name: 03cpp
run: |
make -C ${{ env.CPPROOT }} clean
make -C ${{ env.CPPROOT }} runall
- name: 04matrix_pod
run: |
make -C ${{ env.MATRIXROOT }} clean
make -C ${{ env.MATRIXROOT }} runpod
- name: 04matrix_ma
run: |
make -C ${{ env.MATRIXROOT }} clean
make -C ${{ env.MATRIXROOT }} runma
- name: 04matrix_la
# macos does not have MKL.
if: startsWith(matrix.os, 'ubuntu')
run: |
make -C ${{ env.MATRIXROOT }} clean
make -C ${{ env.MATRIXROOT }} runla
- name: 05cache_skip_access
run: |
make -C ${{ env.CACHEROOT }} clean
make -C ${{ env.CACHEROOT }} run_01_skip_access
- name: 05cache_locality
run: |
make -C ${{ env.CACHEROOT }} clean
make -C ${{ env.CACHEROOT }} run_02_locality
- name: 05cache_matrix_matrix
# macos does not have MKL.
if: startsWith(matrix.os, 'ubuntu')
run: |
make -C ${{ env.CACHEROOT }} clean
make -C ${{ env.CACHEROOT }} run_03_matrix_matrix
- name: 06simd_mul
run: |
make -C ${{ env.SIMDROOT }} hardware
make -C ${{ env.SIMDROOT }} clean
make -C ${{ env.SIMDROOT }}/01_mul run
#make -C ${{ env.SIMDROOT }}/02_fma run # server not supporting FMA
- name: 06simd_mul_r2
# ubuntu does not have a working r2.
if: startsWith(matrix.os, 'macos')
run: |
make -C ${{ env.SIMDROOT }}/01_mul r2all
- name: 06simd_omp
run: |
make -C ${{ env.SIMDROOT }}/03_omp
make -C ${{ env.SIMDROOT }}/03_omp run
[ "$(env OMP_NUM_THREADS=5 make -C ${{ env.SIMDROOT }}/03_omp run | grep 'Hello from thread' | wc -l | xargs)" = "5" ]
- name: 07mem
run: |
make -C ${{ env.MEMROOT }} clean
make -C ${{ env.MEMROOT }} runall
- name: 08smart_pointer
run: |
make -C ${{ env.SMARTROOT }}/01_pointer clean
make -C ${{ env.SMARTROOT }}/01_pointer runall
- name: 08smart_shared
run: |
make -C ${{ env.SMARTROOT }}/02_shared clean
make -C ${{ env.SMARTROOT }}/02_shared runall
- name: 09moderncpp
run: |
make -C ${{ env.MODERNCPPROOT }}/03_elision clean
make -C ${{ env.MODERNCPPROOT }}/03_elision runall
make -C ${{ env.MODERNCPPROOT }}/04_template clean
make -C ${{ env.MODERNCPPROOT }}/04_template runall
make -C ${{ env.MODERNCPPROOT }}/05_lambda clean
make -C ${{ env.MODERNCPPROOT }}/05_lambda runall
- name: 11arraydesign_solve_cpp
run: |
make -C ${{ env.ARRAYDESIGNROOT }} solve_cpp.so
- name: 11arraydesign_data_prep
# macos does not have MKL.
if: startsWith(matrix.os, 'ubuntu')
run: |
make -C ${{ env.ARRAYDESIGNROOT }} data_prep.so
7 changes: 7 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'pstake',
]
Expand Down Expand Up @@ -261,3 +262,9 @@
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
blog_top_name = 'everydaywork'

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'pybind11': ('https://pybind11.readthedocs.io/en/stable/', None),
}
6 changes: 3 additions & 3 deletions nsd/00intro.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
============
Introduction
============
========
Overview
========

What Is Numerical Software
==========================
Expand Down
4 changes: 4 additions & 0 deletions nsd/01engineering/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nsd/
repo1/
gtest/
line*.log
7 changes: 7 additions & 0 deletions nsd/01engineering/code/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: default
default:
@echo "do nothing"

.PHONY: clean
clean:
rm -rf repo1/ nsd/ gtest/ *.log
8 changes: 8 additions & 0 deletions nsd/01engineering/code/bashfunction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
runcmd () {
echo "run command: ${@:2}"
{ time "${@:2}" ; } > $1 2>&1
echo "done; log file: $(cd "$(dirname $1)" && pwd)/$1"
}
runcmd line1.log echo "first command"
runcmd line2.log echo "second command"
2 changes: 2 additions & 0 deletions nsd/01engineering/code/bind1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
*.so
11 changes: 11 additions & 0 deletions nsd/01engineering/code/bind1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.9)
project(vector)

find_package(pybind11 REQUIRED)

pybind11_add_module(
_vector
vector.cpp
)

install(TARGETS _vector DESTINATION .)
30 changes: 30 additions & 0 deletions nsd/01engineering/code/bind1/vector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <pybind11/pybind11.h>

#include <cmath>
#include <tuple>

std::tuple<double, double> rotate(
std::tuple<double, double> const & vec
, double rad
)
{

const double cth = cos(rad);
const double sth = sin(rad);

return std::tuple<double, double>(
std::get<0>(vec) * cth - std::get<1>(vec) * sth
, std::get<0>(vec) * sth + std::get<1>(vec) * cth);

}

PYBIND11_MODULE(_vector, mod)
{

mod.doc() = "example C extension module";

mod.def("rotate", &rotate, "vector rotation");

}

/* vim: set et ts=4 sw=4: */
3 changes: 3 additions & 0 deletions nsd/01engineering/code/dosomething.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
export MYENVVAR="MYENVVAR is set to what I want"
echo "do something"
Binary file added nsd/01engineering/code/gitdistribution.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions nsd/01engineering/code/make1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello
*.o
12 changes: 12 additions & 0 deletions nsd/01engineering/code/make1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CXX = g++

hello: hello.o hellomain.o
$(CXX) hello.o hellomain.o -o hello

hello.o: hello.cpp hello.hpp
$(CXX) -c hello.cpp -o hello.o

hellomain.o: hellomain.cpp hello.hpp
$(CXX) -c hellomain.cpp -o hellomain.o

# vim: set noet nobomb fenc=utf8 ff=unix:
7 changes: 7 additions & 0 deletions nsd/01engineering/code/make1/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>
#include "hello.hpp"
void hello()
{
std::cout << "hello with standalone compiling unit" << std::endl;
}
// vim: set sw=4 ts=4 sts=4 et:
3 changes: 3 additions & 0 deletions nsd/01engineering/code/make1/hello.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once
void hello();
// vim: set sw=4 ts=4 sts=4 et:
7 changes: 7 additions & 0 deletions nsd/01engineering/code/make1/hellomain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "hello.hpp"
int main(int argc, char ** argv)
{
hello();
return 0;
}
// vim: set sw=4 ts=4 sts=4 et:
2 changes: 2 additions & 0 deletions nsd/01engineering/code/make2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello
*.o
12 changes: 12 additions & 0 deletions nsd/01engineering/code/make2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CXX = g++

hello: hello.o hellomain.o
$(CXX) $^ -o $@

hello.o: hello.cpp hello.hpp
$(CXX) -c $< -o $@

hellomain.o: hellomain.cpp hello.hpp
$(CXX) -c $< -o $@

# vim: set noet nobomb fenc=utf8 ff=unix:
7 changes: 7 additions & 0 deletions nsd/01engineering/code/make2/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>
#include "hello.hpp"
void hello()
{
std::cout << "hello with standalone compiling unit" << std::endl;
}
// vim: set sw=4 ts=4 sts=4 et:
3 changes: 3 additions & 0 deletions nsd/01engineering/code/make2/hello.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once
void hello();
// vim: set sw=4 ts=4 sts=4 et:
6 changes: 6 additions & 0 deletions nsd/01engineering/code/make2/hellomain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "hello.hpp"
int main(int argc, char ** argv)
{
hello();
}
// vim: set sw=4 ts=4 sts=4 et:
2 changes: 2 additions & 0 deletions nsd/01engineering/code/make3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello
*.o
9 changes: 9 additions & 0 deletions nsd/01engineering/code/make3/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX = g++

hello: hello.o hellomain.o
$(CXX) $^ -o $@

%.o: %.cpp hello.hpp
$(CXX) -c $< -o $@

# vim: set noet nobomb fenc=utf8 ff=unix:
7 changes: 7 additions & 0 deletions nsd/01engineering/code/make3/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>
#include "hello.hpp"
void hello()
{
std::cout << "hello with standalone compiling unit" << std::endl;
}
// vim: set sw=4 ts=4 sts=4 et:
3 changes: 3 additions & 0 deletions nsd/01engineering/code/make3/hello.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once
void hello();
// vim: set sw=4 ts=4 sts=4 et:

0 comments on commit 079c2e2

Please sign in to comment.