Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
89 changes: 56 additions & 33 deletions src/backend/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,55 @@ file_to_string(
)

set(nvrtc_src
${CUDA_TOOLKIT_ROOT_DIR}/include/cuComplex.h
${CUDA_INCLUDE_DIRS}/cuda_fp16.h
${CUDA_INCLUDE_DIRS}/cuda_fp16.hpp
${CUDA_TOOLKIT_ROOT_DIR}/include/cuComplex.h
${CUDA_TOOLKIT_ROOT_DIR}/include/math_constants.h

${PROJECT_SOURCE_DIR}/src/api/c/ops.hpp
${PROJECT_SOURCE_DIR}/src/api/c/optypes.hpp
${PROJECT_SOURCE_DIR}/include/af/defines.h
${PROJECT_SOURCE_DIR}/include/af/traits.hpp
${PROJECT_BINARY_DIR}/include/af/version.h

${CMAKE_CURRENT_SOURCE_DIR}/Param.hpp
${CMAKE_CURRENT_SOURCE_DIR}/backend.hpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel/interp.hpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel/shared.hpp
${CMAKE_CURRENT_SOURCE_DIR}/math.hpp
${CMAKE_CURRENT_SOURCE_DIR}/types.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../common/half.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../common/kernel_type.hpp

${CMAKE_CURRENT_SOURCE_DIR}/kernel/anisotropic_diffusion.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/approx1.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/approx2.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/bilateral.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/canny.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/convolve1.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/convolve2.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/convolve3.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/convolve_separable.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/exampleFunction.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/histogram.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/hsv_rgb.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/match_template.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/meanshift.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/medfilt.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/moments.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/morph.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/pad_array_borders.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/resize.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/rotate.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/scan_dim.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/scan_dim_by_key.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/scan_first.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/scan_first_by_key.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/shared.hpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel/sobel.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/transform.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/transpose.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/transpose_inplace.cuh
${CMAKE_CURRENT_SOURCE_DIR}/kernel/where.cuh

${PROJECT_SOURCE_DIR}/src/api/c/ops.hpp
${PROJECT_SOURCE_DIR}/src/api/c/optypes.hpp
${PROJECT_SOURCE_DIR}/include/af/defines.h
${PROJECT_SOURCE_DIR}/include/af/traits.hpp

${CMAKE_CURRENT_SOURCE_DIR}/Param.hpp
${CMAKE_CURRENT_SOURCE_DIR}/math.hpp
${CMAKE_CURRENT_SOURCE_DIR}/types.hpp
${CMAKE_CURRENT_SOURCE_DIR}/backend.hpp
)

file_to_string(
Expand Down Expand Up @@ -165,32 +187,32 @@ cuda_add_library(afcuda
sort.hpp

all.cu
anisotropic_diffusion.cu
anisotropic_diffusion.cpp
any.cu
approx.cu
approx.cpp
assign.cu
bilateral.cu
canny.cu
bilateral.cpp
canny.cpp
cholesky.cu
copy.cu
count.cu
diagonal.cu
diff.cu
dilate.cu
dilate3d.cu
erode.cu
erode3d.cu
dilate.cpp
dilate3d.cpp
erode.cpp
erode3d.cpp
Event.cpp
Event.hpp
exampleFunction.cu
exampleFunction.cpp
fast.cu
fast_pyramid.cu
fftconvolve.cu
gradient.cu
harris.cu
histogram.cu
histogram.cpp
homography.cu
hsv_rgb.cu
hsv_rgb.cpp
identity.cu
iir.cu
index.cu
Expand All @@ -200,28 +222,28 @@ cuda_add_library(afcuda
join.cu
lookup.cu
lu.cu
match_template.cu
match_template.cpp
max.cu
mean.cu
meanshift.cu
medfilt.cu
meanshift.cpp
medfilt.cpp
min.cu
moments.cu
moments.cpp
nearest_neighbour.cu
orb.cu
pad_array_borders.cu
pad_array_borders.cpp
product.cu
qr.cu
random_engine.cu
range.cu
regions.cu
reorder.cu
resize.cu
rotate.cu
resize.cpp
rotate.cpp
select.cu
set.cu
sift.cu
sobel.cu
sobel.cpp
solve.cu
sort.cu
sort_by_key.cu
Expand All @@ -233,9 +255,9 @@ cuda_add_library(afcuda
svd.cu
tile.cu
topk.cu
transform.cu
transform.cpp
transpose.cpp
transpose_inplace.cu
transpose_inplace.cpp
triangle.cu
unwrap.cu
wrap.cu
Expand Down Expand Up @@ -440,6 +462,7 @@ cuda_add_library(afcuda
types.hpp
unary.hpp
unwrap.hpp
utility.cpp
utility.hpp
vector_field.cpp
vector_field.hpp
Expand Down
3 changes: 0 additions & 3 deletions src/backend/cuda/Param.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

#include <backend.hpp>
#include <types.hpp>

#ifndef __CUDACC_RTC__
#include <af/defines.h>
#endif

namespace cuda {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ template<typename T>
void anisotropicDiffusion(Array<T>& inout, const float dt, const float mct,
const af::fluxFunction fftype,
const af::diffusionEq eq) {
if (eq == AF_DIFFUSION_MCDE)
kernel::anisotropicDiffusion<T, true>(inout, dt, mct, fftype);
else
kernel::anisotropicDiffusion<T, false>(inout, dt, mct, fftype);
kernel::anisotropicDiffusion<T>(inout, dt, mct, fftype,
eq == AF_DIFFUSION_MCDE);
}

#define INSTANTIATE(T) \
Expand Down
46 changes: 5 additions & 41 deletions src/backend/cuda/approx.cu → src/backend/cuda/approx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,15 @@
#include <approx.hpp>
#include <err_cuda.hpp>
#include <kernel/approx.hpp>
#include <stdexcept>
#include <utility.hpp>

namespace cuda {
template<typename Ty, typename Tp>
void approx1(Array<Ty> &yo, const Array<Ty> &yi, const Array<Tp> &xo,
const int xdim, const Tp &xi_beg, const Tp &xi_step,
const af_interp_type method, const float offGrid) {
switch (method) {
case AF_INTERP_NEAREST:
case AF_INTERP_LOWER:
kernel::approx1<Ty, Tp, 1>(yo, yi, xo, xdim, xi_beg, xi_step,
offGrid, method);
break;
case AF_INTERP_LINEAR:
case AF_INTERP_LINEAR_COSINE:
kernel::approx1<Ty, Tp, 2>(yo, yi, xo, xdim, xi_beg, xi_step,
offGrid, method);
break;
case AF_INTERP_CUBIC:
case AF_INTERP_CUBIC_SPLINE:
kernel::approx1<Ty, Tp, 3>(yo, yi, xo, xdim, xi_beg, xi_step,
offGrid, method);
break;
default: break;
}
kernel::approx1<Ty, Tp>(yo, yi, xo, xdim, xi_beg, xi_step, offGrid, method,
interpOrder(method));
}

template<typename Ty, typename Tp>
Expand All @@ -50,28 +34,8 @@ Array<Ty> approx2(const Array<Ty> &zi, const Array<Tp> &xo, const int xdim,
// Create output placeholder
Array<Ty> zo = createEmptyArray<Ty>(odims);

switch (method) {
case AF_INTERP_NEAREST:
case AF_INTERP_LOWER:
kernel::approx2<Ty, Tp, 1>(zo, zi, xo, xdim, xi_beg, xi_step, yo,
ydim, yi_beg, yi_step, offGrid, method);
break;
case AF_INTERP_LINEAR:
case AF_INTERP_BILINEAR:
case AF_INTERP_LINEAR_COSINE:
case AF_INTERP_BILINEAR_COSINE:
kernel::approx2<Ty, Tp, 2>(zo, zi, xo, xdim, xi_beg, xi_step, yo,
ydim, yi_beg, yi_step, offGrid, method);
break;
case AF_INTERP_CUBIC:
case AF_INTERP_BICUBIC:
case AF_INTERP_CUBIC_SPLINE:
case AF_INTERP_BICUBIC_SPLINE:
kernel::approx2<Ty, Tp, 3>(zo, zi, xo, xdim, xi_beg, xi_step, yo,
ydim, yi_beg, yi_step, offGrid, method);
break;
default: break;
}
kernel::approx2<Ty, Tp>(zo, zi, xo, xdim, xi_beg, xi_step, yo, ydim, yi_beg,
yi_step, offGrid, method, interpOrder(method));
return zo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ namespace cuda {
template<typename inType, typename outType, bool isColor>
Array<outType> bilateral(const Array<inType> &in, const float &s_sigma,
const float &c_sigma) {
UNUSED(isColor);
Array<outType> out = createEmptyArray<outType>(in.dims());
kernel::bilateral<inType, outType, isColor>(out, in, s_sigma, c_sigma);
kernel::bilateral<inType, outType>(out, in, s_sigma, c_sigma);
return out;
}

Expand Down
4 changes: 0 additions & 4 deletions src/backend/cuda/canny.cu → src/backend/cuda/canny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@ Array<float> nonMaximumSuppression(const Array<float>& mag,
const Array<float>& gx,
const Array<float>& gy) {
Array<float> out = createValueArray<float>(mag.dims(), 0);

kernel::nonMaxSuppression<float>(out, mag, gx, gy);

return out;
}

Array<char> edgeTrackingByHysteresis(const Array<char>& strong,
const Array<char>& weak) {
Array<char> out = createValueArray<char>(strong.dims(), 0);

kernel::edgeTrackingHysteresis<char>(out, strong, weak);

return out;
}
} // namespace cuda
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/

#include <Array.hpp> // header with cuda backend specific
// Array class implementation that inherits
// ArrayInfo base class
// header with cuda backend specific
// Array class implementation that inherits
// ArrayInfo base class
#include <Array.hpp>

#include <exampleFunction.hpp> // cuda backend function header

#include <err_cuda.hpp> // error check functions and Macros
// specific to cuda backend
// error check functions and Macros
// specific to cuda backend
#include <err_cuda.hpp>

#include <kernel/exampleFunction.hpp> // this header under the folder src/cuda/kernel
// defines the CUDA kernel and its wrapper
// function to which the main computation of your
// algorithm should be relayed to
// this header is under the folder src/cuda/kernel
// defines the CUDA kernel and its wrapper
// function to which the main computation of your
// algorithm should be relayed to
#include <kernel/exampleFunction.hpp>

using af::dim4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ Array<outType> histogram(const Array<inType> &in, const unsigned &nbins,
dim4 outDims = dim4(nbins, 1, dims[2], dims[3]);
Array<outType> out = createValueArray<outType>(outDims, outType(0));

kernel::histogram<inType, outType, isLinear>(out, in, nbins, minval,
maxval);

kernel::histogram<inType, outType>(out, in, nbins, minval, maxval,
isLinear);
return out;
}

Expand Down
8 changes: 2 additions & 6 deletions src/backend/cuda/hsv_rgb.cu → src/backend/cuda/hsv_rgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ namespace cuda {
template<typename T>
Array<T> hsv2rgb(const Array<T>& in) {
Array<T> out = createEmptyArray<T>(in.dims());

kernel::hsv2rgb_convert<T, true>(out, in);

kernel::hsv2rgb_convert<T>(out, in, true);
return out;
}

template<typename T>
Array<T> rgb2hsv(const Array<T>& in) {
Array<T> out = createEmptyArray<T>(in.dims());

kernel::hsv2rgb_convert<T, false>(out, in);

kernel::hsv2rgb_convert<T>(out, in, false);
return out;
}

Expand Down
Loading