Skip to content

Commit 36260ae

Browse files
authored
Moved in funcs from faasm repo (#9)
* Moved in funcs from faasm repo * Adding tasks for function files * Build faasm func in Dockerfile * gitignore * Version * retab gitmodules file * Bump cpp version * Add clang format
1 parent 86e829f commit 36260ae

34 files changed

+1142
-100
lines changed

.clang-format

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
BasedOnStyle: Mozilla
3+
4+
---
5+
Language: Cpp
6+
7+
# Avoid excessive linebreaks on function definitions
8+
AlwaysBreakAfterDefinitionReturnType: None
9+
AlwaysBreakAfterReturnType: None
10+
11+
IndentWidth: 4
12+
DerivePointerAlignment: false
13+
---

.github/workflows/tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
if: github.event.pull_request.draft == false
1313
runs-on: ubuntu-20.04
1414
container:
15-
image: faasm/cpython:0.0.10
15+
image: faasm/cpython:0.0.11
1616
defaults:
1717
run:
1818
working-directory: /code/python
@@ -27,6 +27,10 @@ jobs:
2727
run: pip3 install -r pyfaasm/test_requirements.txt
2828
- name: "Python formatting check"
2929
run: ./bin/check_python.sh
30+
- name: "Check C/C++ formatting"
31+
run: ./bin/run_clang_format.sh
32+
- name: "Check no formatting changes"
33+
run: git diff --exit-code
3034

3135
build:
3236
if: github.event.pull_request.draft == false
@@ -36,7 +40,7 @@ jobs:
3640
REDIS_QUEUE_HOST: redis
3741
REDIS_STATE_HOST: redis
3842
container:
39-
image: faasm/cpython:0.0.10
43+
image: faasm/cpython:0.0.11
4044
defaults:
4145
run:
4246
working-directory: /code/python

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Proj-specific
2+
build/
23
cross_venv/
34

45
# Byte-compiled / optimized / DLL files

.gitmodules

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
[submodule "third-party/cpython"]
2-
path = third-party/cpython
2+
path = third-party/cpython
33
url = https://github.com/faasm/cpython
44
branch = faasm
55
[submodule "third-party/numpy"]
6-
path = third-party/numpy
6+
path = third-party/numpy
77
url = https://github.com/faasm/numpy
88
branch = faasm
99
[submodule "third-party/crossenv"]
10-
path = third-party/crossenv
10+
path = third-party/crossenv
1111
url = https://github.com/faasm/crossenv
1212
branch = faasm
1313
[submodule "third-party/horovod"]
14-
path = third-party/horovod
14+
path = third-party/horovod
1515
url = https://github.com/faasm/horovod
1616
branch = faasm
1717
[submodule "third-party/mxnet"]
18-
path = third-party/mxnet
18+
path = third-party/mxnet
1919
url = https://github.com/faasm/incubator-mxnet
2020
branch = faasm
21+
[submodule "third-party/cpp"]
22+
path = third-party/cpp
23+
url = https://github.com/faasm/cpp

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM faasm/cpp-sysroot:0.0.18
1+
FROM faasm/cpp-sysroot:0.0.22
22
ARG FAASM_PYTHON_VERSION
33

44
RUN apt install -y \
@@ -38,6 +38,9 @@ RUN ./bin/crossenv_setup.sh
3838
# Install cross-compiled python packages
3939
RUN . ./cross_venv/bin/activate && inv libs.install
4040

41+
# Build Faasm function
42+
RUN inv func
43+
4144
# TODO - enable these once the MXNet/ Horovod work is completed
4245
# Build mxnet
4346
# RUN inv mxnet

README.md

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,41 @@ interface](https://github.com/faasm/faasm/blob/master/docs/host_interface.md).
99

1010
## Set-up and development
1111

12-
We recommend using Docker for developing this repo. Start the container with:
12+
This repo is developed using the Faasm development environment, set up according
13+
to [the docs](https://github.com/faasm/faasm/blob/master/docs/development.md).
1314

14-
```
15-
./bin/cli.sh
16-
```
17-
18-
To show the list of available tasks (inside the container):
15+
To set up your local environment, run the `python` CLI as per the Faasm docs,
16+
then:
1917

2018
```bash
21-
inv -l
22-
```
19+
# Install a local dev version of the cpp tools
20+
pip3 uninstall faasmtools
21+
pip3 install -e third-party/cpp
22+
23+
# Install the matching native python in your local env
24+
./bin/install_build_python.sh
25+
26+
# Compile CPython to wasm
27+
inv cpython
28+
29+
# Set up and activate cross-env
30+
./bin/crossenv_setup.sh
31+
32+
# Activate cross-env
33+
. cross_venv/bin/activate
34+
35+
# Build Python libraries
36+
inv libs.install
2337

24-
The build uses the [Faasm
25-
toolchain](https://github.com/faasm/faasm-toolchain) to cross-compile both
26-
CPython and C-extensions to WebAssembly.
38+
# Copy runtime files into place
39+
inv runtime
40+
41+
# Build the Faasm function to wrap CPython
42+
inv func
43+
44+
# Copy the actual Python functions into place
45+
inv func.uploadpy --local
46+
```
2747

2848
## Code changes
2949

@@ -47,11 +67,11 @@ Several of the code changes to CPython and numpy were borrowed from
4767
This repo gets built as a container, `faasm/cpython`. If you want to release a
4868
new version, you can:
4969

50-
- Update the version in `VERSION` and `.github`
70+
- Update the version in `VERSION` and `.github/workflows/tests.yml`
5171
- Commit to your branch
52-
- Check that the normal build works in CI
5372
- Run `inv git.tag`
54-
- Let the Github action do the rest
73+
- Check the release build has run
74+
- Create a pull request
5575

5676
## PyFaasm
5777

@@ -113,26 +133,7 @@ Setuptools and distutils both interrogate the Python system environment during
113133
the build process. This makes it quite difficult to cross-compile libraries, so
114134
we use [crossenv](https://github.com/benfogle/crossenv).
115135

116-
To set up crossenv:
117-
118-
```
119-
./bin/crossenv_setup.sh
120-
```
121-
122-
You can then activate with:
123-
124-
```
125-
. cross_venv/bin/activate
126-
```
127-
128-
From inside the virtual environment, you can inspect the set-up with:
129-
130-
```
131-
python bin/sanity_check.py | less
132-
```
133-
134-
This will display the environment used to install Python modules (including the
135-
relevant cross-compilation variables, e.g. `CC`, `CFLAGS` etc.).
136+
See the dev instructions above for set-up.
136137

137138
### Changing the crossenv environment
138139

@@ -215,13 +216,8 @@ inv mxnet --clean
215216
inv mxnet.uninstall
216217
```
217218

218-
## Running in Faasm
219-
220-
See the [Faasm python
221-
docs](https://github.com/faasm/faasm/blob/master/docs/python.md).
222-
223219
## BLAS and LAPACK
224220

225221
Faasm's normal BLAS and LAPACK support using CLAPACK should be picked up by
226222
numpy due to the addition of the [site.cfg](../third-party/numpy/site.cfg).
227-
223+
(note 19/03/21 this has been temporarily disabled).

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.10
1+
0.0.11

bin/cli.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

bin/run_clang_format.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function append_newline {
6+
if [[ -z "$(tail -c 1 "$1")" ]]; then
7+
:
8+
else
9+
echo >> "$1"
10+
fi
11+
}
12+
13+
if [ -z "$1" ]; then
14+
TARGET_DIR="."
15+
else
16+
TARGET_DIR=$1
17+
fi
18+
19+
pushd ${TARGET_DIR} >> /dev/null
20+
21+
# Find all source files using Git to automatically respect .gitignore
22+
FILES=$(git ls-files "*.h" "*.cpp" "*.c")
23+
24+
# Run clang-format
25+
clang-format-10 -i ${FILES}
26+
27+
# Check newlines
28+
for f in ${FILES}; do
29+
append_newline $f
30+
done
31+
32+
popd >> /dev/null

docker-compose.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)