Skip to content

Commit fecc51d

Browse files
authored
Merge pull request #19 from gjbex/development
Various fixes
2 parents 943bdf5 + 182693e commit fecc51d

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

python_for_hpc.pptx

14.2 KB
Binary file not shown.

source-code/cython/Primes/Makefile

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
VERSION = $(shell python3-config --extension-suffix)
2-
PRIMES_LIBS = primes_cython.$(VERSION).so primes_cython3.$(VERSION).so \
3-
primes_pure_python.$(VERSION).so primes_pure_malloc.$(VERSION).so \
4-
primes_malloc.$(VERSION).so
2+
SRC_FILES = primes_cython.pyx \
3+
primes_malloc.pyx \
4+
primes_pure_python.py \
5+
primes_pure_malloc.py
6+
PRIMES_LIBS = $(addsuffix $(VERSION), $(basename $(SRC_FILES)))
7+
C_FILES = $(addsuffix .c, $(basename $(SRC_FILES)))
58

69
all: $(PRIMES_LIBS)
710

8-
$(PRIMES_LIBS): primes_cython.pyx primes_pure_python.py
11+
%$(VERSION): %.pyx
12+
python setup.py build_ext --inplace
13+
14+
%$(VERSION): %.py
915
python setup.py build_ext --inplace
1016

1117
clean:
1218
python setup.py clean
13-
$(RM) primes_cython.c primes_cython3.c primes_pure_python.c primes_malloc.c $(PRIMES_LIBS)
19+
$(RM) $(PRIMES_LIBS)
20+
$(RM) $(C_FILES)
1421
$(RM) -r build/

source-code/interfacing-c-c++-fortran/Pybind11/Simple/computations.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ double mul(double a, double b) {
66
return a * b;
77
}
88

9-
double div(double a, double b) {
9+
double divide(double a, double b) {
1010
return a/b;
1111
}

source-code/interfacing-c-c++-fortran/Pybind11/Simple/computations.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
double add(double a, double b);
55
double mul(double a, double b);
6-
double div(double a, double b);
6+
double divide(double a, double b);
77

88
#endif
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include <pybind11/pybind11.h>
22
#include "computations.h"
33

4+
namespace py = pybind11;
5+
46
PYBIND11_MODULE(computations, m) {
57
m.doc() = "pybind11 wrapper module for cmoputations.h";
68
m.def("add", &add, "function that adds two numbers");
79
m.def("mul", &mul, "function that multiplies two numbers");
8-
m.def("div", &div, "function that divides two numbers"
9-
py::arg("left_op"), py::arg("right_op"));
10+
m.def("div", &divide, "function that divides two numbers",
11+
py::arg("num"), py::arg("denom"));
1012
}

0 commit comments

Comments
 (0)