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

New fract4dc interface #85

Merged
merged 32 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b9efac8
created new python extension type "controller" to provide new fract4d…
mindhells Apr 7, 2020
3c9284b
fract4dc: extend controller interface
mindhells Apr 13, 2020
fbace44
fract4dc: clean unused code on site classes
mindhells Apr 13, 2020
d3a8b44
fix: set interrupt flag to false when starting calculations
mindhells Apr 13, 2020
cff91e5
fract4dc controller: resource deallocation
mindhells Apr 15, 2020
37264a3
created a basic fractal creation sample script
mindhells Apr 15, 2020
3a66362
move pysite and calcargs out from model
mindhells Apr 16, 2020
7b72be3
move colorutils, vectors and threadpool into model
mindhells Apr 17, 2020
81bf2a5
created cpp standalone mandelbrot example
mindhells Apr 17, 2020
bbbe798
fix: include not updated
mindhells Apr 17, 2020
061cb0a
update examples readme
mindhells Apr 17, 2020
82b8eb8
python > fract4d_new > add test_calculation_messages_are_handled
Apr 20, 2020
a385904
generalize exmaples infrastructure
mindhells Apr 20, 2020
d687d7a
update helper bash scripts
Apr 20, 2020
d988911
pylint > ignore PIL module
Apr 20, 2020
4cbd5f2
docker > update dockerfile, remove useless deps and update scripts
Apr 20, 2020
f8c6a27
tox > remove test.py from pytest commands
Apr 20, 2020
6408166
pipeline > update travis and tox deps
Apr 20, 2020
d242297
created a new example
mindhells Apr 21, 2020
87fc87d
fix typo
mindhells Apr 22, 2020
f6cd7b7
raw mandelbrot example
mindhells Apr 23, 2020
5ec254f
review c compatibility headers inclusion
mindhells Apr 24, 2020
7d3b222
avoid using NULL C macro to compare to check nullptr
mindhells Apr 24, 2020
923612b
using smart pointers on cpp examples
mindhells Apr 24, 2020
610834c
cpp examples improvements
mindhells Apr 24, 2020
587df89
cpp examples: more improvements
mindhells Apr 24, 2020
56c830d
pylint: PEP8 extrict checker for new python code
guanchor Apr 27, 2020
b6bceb5
docker: keep .so files in workspace when using docker scripts
guanchor Apr 27, 2020
0652478
tests: fix tearDownClass in testbase
guanchor Apr 27, 2020
028516b
tests: more testing to cover the new fractdc interface
guanchor Apr 27, 2020
4dbc081
custom formula cpp example
mindhells Apr 30, 2020
0674dcf
use reinterpret_cast instead C-style to load symbols with dlsym to pr…
mindhells May 4, 2020
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ before_install:
sudo apt-get install -y libgirepository1.0-dev gir1.2-gtk-3.0
install:
- python setup.py build
- pip install tox-travis pillow pygobject pylint
- pip install tox-travis pylint
script:
- ./bin/pylint.sh
- ./bin/pylint.sh || travis_terminate 1;
- tox
notifications:
email: false
4 changes: 2 additions & 2 deletions fract4d/b.sh → bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
pushd ..

rm -rf build
rm fract4d/*.so
./setup.py build
popd
6 changes: 6 additions & 0 deletions bin/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

rm -rf build
rm fract4d/*.so
rm -rf .pytest_cache
rm -rf .tox
10 changes: 9 additions & 1 deletion bin/pylint.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
#!/bin/sh
#!/bin/bash

pylint *.py fract4d fract4d_compiler fract4dgui

if [[ $? == 0 ]]
then
echo "pylint passed successfully"
else
exit 1
fi
16 changes: 12 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ RUN \
apt-get -y upgrade && \
apt-get -y install libpng-dev libjpeg-dev python3-dev gtk3.0 libcairo2-dev python3-cairo python3-gi-cairo pkg-config python3-pip xvfb

# bin/run_builds.sh deps
RUN apt-get -y install software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get -y install python3.5 python3.5-dev python3.6 python3.6-dev python3.7 python3.7-dev python3.8 python3.8-dev

# deps for bin/run_*.sh scripts
RUN pip3 install pillow pylint pytest tox
# bin/run_pylint.sh deps
RUN pip3 install pylint

# other deps
RUN apt-get -y install libgirepository1.0-dev gir1.2-gtk-3.0
# bin/run_pytest.sh deps
RUN pip3 install pytest

# bin/run_tox.sh deps
RUN apt-get -y install libgirepository1.0-dev
RUN pip3 install tox

# Xvfb (in memory x11 server) setup
ENV DISPLAY :99
Expand Down
10 changes: 10 additions & 0 deletions docker/bin/run_builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

docker-compose up -d --build
docker-compose exec server bash -c "rm -rf build && \
rm fract4d/*.so"
docker-compose exec server bash -c "python3.5 ./setup.py build && \
python3.6 ./setup.py build && \
python3.7 ./setup.py build && \
python3.8 ./setup.py build"
docker-compose down
8 changes: 8 additions & 0 deletions docker/bin/run_clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

docker-compose up -d
docker-compose exec server bash -c "rm -rf build && \
rm fract4d/*.so && \
rm -rf .pytest_cache && \
rm -rf .tox"
docker-compose down
3 changes: 0 additions & 3 deletions docker/bin/run_lint.sh

This file was deleted.

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

docker-compose up -d --build
docker-compose exec server bash -c "rm -rf build && \
rm fract4d/*.so"
docker-compose exec server bash -c "python3 setup.py build && \
./bin/pylint.sh"
docker-compose down
8 changes: 6 additions & 2 deletions docker/bin/run_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash

docker-compose up -d --build
# docker-compose exec server bash -c "pytest -s test.py::Test::testGenerateMandelbrot"
docker-compose exec server bash -c "rm -rf build && python3 setup.py build && ./test.py"
docker-compose exec server bash -c "rm -rf build && \
rm fract4d/*.so"
docker-compose exec server bash -c "python3 setup.py build && \
./test.py"
docker-compose down
10 changes: 9 additions & 1 deletion docker/bin/run_tox.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!/bin/bash

docker-compose up -d --build
docker-compose exec server bash -c "rm -rf build && python3 setup.py build && tox"
docker-compose exec server bash -c "rm -rf build && \
rm fract4d/*.so"
docker-compose exec server bash -c "python3.5 ./setup.py build && \
python3.6 ./setup.py build && \
python3.7 ./setup.py build && \
python3.8 ./setup.py build && \
tox"
docker-compose down
41 changes: 41 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# EXAMPLES

*Note: for all exmples make sure you have performed the setup previously:*
```
./setup.py build
```

## Python examples
### Creating a simple mandelbrot using fract4dc.controller

Execute:
```
examples/python/simple_mandelbrot.py
```
Then you should see a new file under `examples/output`.


## C++ examples
For these examples you'll need [docker](https://docs.docker.com/get-docker/)

### Creating a simple mandelbrot
Execute:
```
examples/cpp/simple_mandelbrot.sh
```
Then you should see a new file under `examples/output`.

### Creating a simple mandelbrot using multiple threads
Execute:
```
examples/cpp/multithread_mandelbrot.sh
```
Then you should see a new file under `examples/output`.

### Creating a simple mandelbrot using no high level model entities (fractfunc, workers, pointfunc)
In this example we use the compiled formula directly to calculate the fractal with no postprocessing (antialiasing) or improvements (ie. autodeepen)
Execute:
```
examples/cpp/raw_mandelbrot.sh
```
Then you should see a new file under `examples/output`.
46 changes: 46 additions & 0 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.10)
project(simple_mandelbrot)

set(CMAKE_CXX_STANDARD 17)

include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/model)

FILE(GLOB MODELFILES ${PROJECT_SOURCE_DIR}/model/*.cpp)

# MAIN

add_executable(example main.cpp ${MODELFILES})

find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
target_link_libraries(example ${PNG_LIBRARY})

find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
target_link_libraries(example ${JPEG_LIBRARY})

find_package(Threads REQUIRED)
target_link_libraries(example ${CMAKE_THREAD_LIBS_INIT})

target_link_libraries(example ${CMAKE_DL_LIBS})

add_definitions(-DTHREADS -D_REENTRANT -DPNG_ENABLED -DJPG_ENABLED)

# FRACT_STDLIB

add_library(fract_stdlib SHARED
${PROJECT_SOURCE_DIR}/fract_stdlib.cpp
${PROJECT_SOURCE_DIR}/model/colorutils.cpp
${PROJECT_SOURCE_DIR}/model/colormap.cpp
${PROJECT_SOURCE_DIR}/model/image.cpp)

set_target_properties(fract_stdlib PROPERTIES PREFIX "")
set_target_properties(fract_stdlib PROPERTIES SUFFIX ".so")

# FORMULA LIB

add_library(formula SHARED
${PROJECT_SOURCE_DIR}/formula.c)
set_target_properties(formula PROPERTIES SUFFIX ".so")
set_target_properties(formula PROPERTIES PREFIX "")
22 changes: 22 additions & 0 deletions examples/cpp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:18.04

ENV TZ=Europe/Minsk
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y build-essential git cmake autoconf libtool pkg-config libpng-dev libjpeg-dev

WORKDIR /src

ARG main_source
ARG formula_source

COPY examples/cpp/${main_source} ./main.cpp
COPY examples/cpp/CMakeLists.txt ./
COPY fract4d/c/fract_stdlib.cpp fract4d/c/fract_stdlib.h fract4d/c/pf.h ./
COPY fract4d/c/model/ ./model
COPY ${formula_source} ./formula.c

RUN cmake . && make

CMD ["./example"]
Loading