mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
CUDA Example: Refactor to Number 0
Less fiddeling in the scripts when adding more examples later on.
This commit is contained in:
parent
6c98c38dfa
commit
13ca58e189
@ -115,6 +115,8 @@ set(PYBIND11_EXAMPLES
|
||||
example/example13.cpp
|
||||
)
|
||||
|
||||
set(PYBIND11_FIRSTEXAMPLE 1)
|
||||
set(PYBIND11_LASTEXAMPLE 13)
|
||||
|
||||
if(${CUDA_FOUND})
|
||||
macro(add_library_wrapper)
|
||||
@ -125,7 +127,8 @@ if(${CUDA_FOUND})
|
||||
add_definitions(-DPYBIND11_CUDA=1)
|
||||
list(APPEND CUDA_NVCC_FLAGS -std=c++11)
|
||||
list(APPEND CUDA_NVCC_FLAGS -arch=${CUDA_ARCH})
|
||||
set(PYBIND11_EXAMPLES ${PYBIND11_EXAMPLES} example/example14.cu)
|
||||
set(PYBIND11_EXAMPLES ${PYBIND11_EXAMPLES} example/example0.cu)
|
||||
set(PYBIND11_FIRSTEXAMPLE 0)
|
||||
else()
|
||||
macro(add_library_wrapper)
|
||||
add_library(${ARGV})
|
||||
@ -207,9 +210,7 @@ endif()
|
||||
|
||||
enable_testing()
|
||||
set(RUN_TEST ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/run_test.py)
|
||||
list(LENGTH PYBIND11_EXAMPLES PYBIND11_NUMEXAMPLES)
|
||||
math(EXPR PYBIND11_NUMEXAMPLES "${PYBIND11_NUMEXAMPLES} - 1")
|
||||
foreach(i RANGE 1 ${PYBIND11_NUMEXAMPLES})
|
||||
foreach(i RANGE ${PYBIND11_FIRSTEXAMPLE} ${PYBIND11_LASTEXAMPLE})
|
||||
add_test(NAME example${i} COMMAND ${RUN_TEST} example${i})
|
||||
endforeach()
|
||||
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "example.h"
|
||||
|
||||
#if (PYBIND11_CUDA==1)
|
||||
void init_ex0(py::module &);
|
||||
#endif
|
||||
void init_ex1(py::module &);
|
||||
void init_ex2(py::module &);
|
||||
void init_ex3(py::module &);
|
||||
@ -23,13 +26,13 @@ void init_ex10(py::module &);
|
||||
void init_ex11(py::module &);
|
||||
void init_ex12(py::module &);
|
||||
void init_ex13(py::module &);
|
||||
#if (PYBIND11_CUDA==1)
|
||||
void init_ex14(py::module &);
|
||||
#endif
|
||||
|
||||
PYBIND11_PLUGIN(example) {
|
||||
py::module m("example", "pybind example plugin");
|
||||
|
||||
#if (PYBIND11_CUDA==1)
|
||||
init_ex0(m);
|
||||
#endif
|
||||
init_ex1(m);
|
||||
init_ex2(m);
|
||||
init_ex3(m);
|
||||
@ -43,9 +46,6 @@ PYBIND11_PLUGIN(example) {
|
||||
init_ex11(m);
|
||||
init_ex12(m);
|
||||
init_ex13(m);
|
||||
#if (PYBIND11_CUDA==1)
|
||||
init_ex14(m);
|
||||
#endif
|
||||
|
||||
return m.ptr();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
example/example14.cu -- CUDA acceleratred Mandelbrot example
|
||||
example/example0.cu -- CUDA acceleratred Mandelbrot example
|
||||
|
||||
Copyright (c) 2012-2016 Axel Huebl <a.huebl@hzdr.de>
|
||||
|
||||
@ -157,6 +157,6 @@ int mandelbrot() {
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
void init_ex14(py::module &m) {
|
||||
void init_ex0(py::module &m) {
|
||||
m.def("mandelbrot", &mandelbrot, "Start mandelbrot calculation");
|
||||
}
|
Loading…
Reference in New Issue
Block a user