autumnai / collenchyma

Extendable HPC-Framework for CUDA, OpenCL and common CPU
http://autumnai.github.io/collenchyma
Apache License 2.0
475 stars 33 forks source link

Add documentation on how to use feature flags #36

Open hobofan opened 8 years ago

hobofan commented 8 years ago

Since we heavily use feature flags for frameworks across all plugins, we will want a documentation on how to use them (in combinatinon with plugins) to lower the barrier of entry.

Example:

[dependencies]
collenchyma      = { version = "~0.0.6", default-features = false }
collenchyma-blas = { version = "0.1", default-features = false }
collenchyma-nn   = { version = "0.1.0", default-features = false }

[features]
default = ["native", "cuda", "opencl"]
native  = ["collenchyma/native", "collenchyma-blas/native", "collenchyma-nn/native"]
cuda    = ["collenchyma/cuda", "collenchyma-blas/cuda", "collenchyma-nn/cuda"]
opencl  = ["collenchyma/opencl", "collenchyma-blas/opencl", "collenchyma-nn/opencl"]
hobofan commented 8 years ago

During work on #40, #42 it also came to my wind that this should also include tips on how to keep backend independence.

For example import via

use collenchyma::framworks::*;

instead of

use collenchyma::framworks::{Native,Cuda};

which would actually need to look like this if it should be properly backend independent and compileable.

#[cfg(feature = "native")]
use collenchyma::framworks::Native;
#[cfg(feature = "cuda")]
use collenchyma::framworks::Cuda;