Skip to content

Commit 2f169c2

Browse files
author
Montse
committed
Fixing scripts and paths
1 parent 357c064 commit 2f169c2

7 files changed

Lines changed: 91 additions & 68 deletions

File tree

‎ffiwrappers/Makefile‎

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

‎ffiwrappers/README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ Alternatively, use `CFLAGS` environment variable, e.g.
3131
In this example CUDA is required by StarPU.
3232

3333

34+
# How does it work
35+
CFFI provides interface to call C from python.
36+
37+
We import arlwrap.py module using PyObjects, then we use ffi callback mechanism (ABI mode)
38+
to efectively call our arl python code from C.
39+
40+
The core mechanism is bk_getfn() function which using PyObjects imports arlwrap.py and
41+
returns the pointer to the python function (in arlwrap.py) as a callable C function, plus
42+
calls the function --only this function is not in arlwrap.py as such, it is a tuple.
43+
44+
arlwrap.c
45+
========
46+
For every function it calls bk_getfn()
47+
48+
arlwrap.py
49+
=========
50+
Sets up the FFI callback to call the python code in ARL.
51+
52+
53+
3454
# TODOs
3555
- Currently, we are pickling some metadata and storing it in a character
3656
array. However, we don't know the size of the pickled objects in advance, so
Binary file not shown.

‎ffiwrappers/setup.py‎

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

‎scripts/build-arl-linux-new.sh‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# =========================================================== #
4+
# Set of comands to Install arl and wrapper into Linux system #
5+
# =========================================================== #
6+
7+
# Load the dependency modules
8+
# PYTHON 3.6 +
9+
# GIT 2.10+
10+
# GIT-LFS
11+
# i.e.:
12+
#module load python-3.5.2-gcc-5.4.0-rdp6q5l
13+
#module load python-3.6.1-gcc-5.4.0-23fr5u4
14+
#module load git-2.14.1-gcc-5.4.0-acb553e
15+
#module load git-lfs-2.3.0-gcc-5.4.0-oktvmkw
16+
#module load cfitsio-3.410-gcc-5.4.0-tp3pkyv
17+
18+
# Clone the repository
19+
#git clone https://github.com/SKA-ScienceDataProcessor/algorithm-reference-library/
20+
#cd algorithm-reference-library/
21+
22+
# Get the data
23+
#git-lfs pull
24+
25+
# Start the building ARL through building a python virtualenvironment
26+
virtualenv -p `which python3` _build
27+
source _build/bin/activate
28+
pip install --upgrade pip
29+
pip install -U setuptools
30+
pip install coverage numpy
31+
pip install -r requirements.txt
32+
pip install virtualenvwrapper
33+
source virtualenvwrapper.sh
34+
35+
# Build the ARL
36+
python setup.py build_py
37+
python setup.py install
38+
39+
# Build ARL C Wrappers (FFI)
40+
python setup.py build_ext -i
41+
42+
# Add ARL to the PATH
43+
# An alternative if not using virtualenv is to:
44+
# export PYTHONPATH=$PWD:$PWD/ffiwrappers/src:$PYTHONPATH
45+
add2virtualenv $PWD
46+
add2virtualenv $PWD/ffiwrappers/src
47+
48+
# Setup ARLROOT
49+
export ARLROOT=$PWD
50+
51+
# Test it
52+
cd workflows/ffiwrapped/serial
53+
make run
54+

‎tests/ffiwrapped/run-tests.sh‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#make clean;
88

99
TESTPATH=$ARLROOT/workflows/ffiwrapped/serial
10-
TESTLIST='timg_serial ical_serial'
10+
TESTLIST='timg_serial ical_demo'
1111

1212
if [ $1 ]
1313
then
@@ -17,32 +17,34 @@ else
1717
filelist=$TESTLIST;
1818
fi
1919

20+
# clean before we start
21+
cd $TESTPATH
22+
make clean;
23+
24+
export LD_LIBRARY_PATH=$ARLROOT:$LD_LIBRARY_PATH
25+
2026
for testfile in $filelist; do
2127

2228
# file=`basename $testfile .c`;
23-
# Assumes the folder has the same name as the executable file
2429
file=$testfile
25-
cd $file
26-
make clean;
2730
echo "Running $file";
2831
make $file >& make.out
2932
if [ $? -ne 0 ]
3033
then
3134
echo "Compilation failed"
35+
# store the output for reference
36+
cp make.out $file.make.out;
3237
continue
3338
fi
3439
# Run the serial test
35-
#./$file >& run.out
36-
make run >& run.out
40+
./$file >& run.out
3741
if [ $? -eq 0 ]
3842
then
3943
echo "$testfile passed"
4044
else
4145
# store the output and diff file for reference
4246
echo "$testfile failed"
43-
cp make.out $file.make.out;
4447
cp run.out $file.run.out;
4548
fi
4649
rm -f make.out run.out
47-
cd ..
4850
done

‎workflows/ffiwrapped/serial/Makefile‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ CFLAGS=-I../../../ffiwrappers/include
77
#LDFLAGS=$(shell python3-config --ldflags) -lcfitsio
88

99

10-
all: timg_serial ical_demo
10+
EXECS=timg_serial ical_demo
11+
all: $(EXECS)
1112

12-
timg_serial:
13-
$(CC) $(CFLAGS) timg_serial.c $(LDFLAGS) -o timg_serial
14-
15-
ical_serial:
16-
$(CC) $(CFLAGS) ical_demo.c $(LDFLAGS) -o ical_demo
13+
$(EXECS): %: %.c
14+
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $<
1715

1816
run: all
19-
LD_LIBRARY_PATH=../../..:$(LD_LIBRARY_PATH) ./timg_serial
17+
LD_LIBRARY_PATH=../../..:$(LD_LIBRARY_PATH) ./timg_serial
18+
LD_LIBRARY_PATH=../../..:$(LD_LIBRARY_PATH) ./ical_demo
2019

2120
clean:
22-
rm -rf results timg_serial ical_demo
21+
rm -rf results timg_serial ical_demo *.o *.out

0 commit comments

Comments
 (0)