Skip to content
Closed
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
12 changes: 12 additions & 0 deletions include/af/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,35 @@
extern "C" {
#endif

#if AF_API_VERSION >= 32
/**
\param[in] bknd takes one of the values of enum \ref af_backend
\returns \ref af_err error code

\ingroup unified_func_setbackend
*/
AFAPI af_err af_set_backend(const af_backend bknd);
#endif

#if AF_API_VERSION >= 32
/**
\param[out] num_backends Number of available backends
\returns \ref af_err error code

\ingroup unified_func_getbackendcount
*/
AFAPI af_err af_get_backend_count(unsigned* num_backends);
#endif

#if AF_API_VERSION >= 32
/**
\param[out] backends is the OR sum of the backends available.
\returns \ref af_err error code

\ingroup unified_func_getavailbackends
*/
AFAPI af_err af_get_available_backends(int* backends);
#endif

#ifdef __cplusplus
}
Expand All @@ -46,26 +52,32 @@ AFAPI af_err af_get_available_backends(int* backends);
namespace af
{

#if AF_API_VERSION >= 32
/**
\param[in] bknd takes one of the values of enum \ref af_backend

\ingroup unified_func_setbackend
*/
AFAPI void setBackend(const Backend bknd);
#endif

#if AF_API_VERSION >= 32
/**
\returns Number of available backends

\ingroup unified_func_getbackendcount
*/
AFAPI unsigned getBackendCount();
#endif

#if AF_API_VERSION >= 32
/**
\returns OR sum of the backends available

\ingroup unified_func_getavailbackends
*/
AFAPI int getAvailableBackends();
#endif

}
#endif
33 changes: 32 additions & 1 deletion include/af/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ typedef enum {
///
AF_ERR_NOT_CONFIGURED = 302,

#if AF_API_VERSION >= 32
///
/// This build of ArrayFire is not compiled with "nonfree" algorithms
///
AFF_ERR_NONFREE = 303,
AF_ERR_NONFREE = 303,
#endif

// 400-499 Errors for missing hardware features

Expand All @@ -151,8 +153,21 @@ typedef enum {
AF_ERR_NO_GFX = 402,

// 500-599 Errors specific to heterogenous API

#if AF_API_VERSION >= 32
///
/// There was an error when loading the libraries
///
AF_ERR_LOAD_LIB = 501,
#endif

#if AF_API_VERSION >= 32
///
/// There was an error when loading the symbols
///
AF_ERR_LOAD_SYM = 502,
#endif


// 900-999 Errors from upstream libraries and runtimes

Expand Down Expand Up @@ -181,6 +196,8 @@ typedef enum {
u64, ///< 64-bit unsigned integral values
#if AF_API_VERSION >= 32
s16, ///< 16-bit signed integral values
#endif
#if AF_API_VERSION >= 32
u16, ///< 16-bit unsigned integral values
#endif
} af_dtype;
Expand Down Expand Up @@ -258,17 +275,21 @@ typedef enum {
AF_SHD ///< Match based on Sum of Hamming Distances (SHD)
} af_match_type;

#if AF_API_VERSION >= 31
typedef enum {
AF_YCC_601 = 601, ///< ITU-R BT.601 (formerly CCIR 601) standard
AF_YCC_709 = 709, ///< ITU-R BT.709 standard
AF_YCC_2020 = 2020 ///< ITU-R BT.2020 standard
} af_ycc_std;
#endif

typedef enum {
AF_GRAY = 0, ///< Grayscale
AF_RGB, ///< 3-channel RGB
AF_HSV, ///< 3-channel HSV
#if AF_API_VERSION >= 31
AF_YCbCr ///< 3-channel YCbCr
#endif
} af_cspace_t;

typedef enum {
Expand Down Expand Up @@ -309,6 +330,7 @@ typedef enum {
AF_COLORMAP_BLUE = 6 ///< Blue hue map
} af_colormap;

#if AF_API_VERSION >= 31
typedef enum {
AF_FIF_BMP = 0, ///< FreeImage Enum for Bitmap File
AF_FIF_ICO = 1, ///< FreeImage Enum for Windows Icon File
Expand All @@ -324,14 +346,17 @@ typedef enum {
AF_FIF_JP2 = 31, ///< FreeImage Enum for JPEG-2000 File
AF_FIF_RAW = 34 ///< FreeImage Enum for RAW Camera Image File
} af_image_format;
#endif

#if AF_API_VERSION >= 32
// These enums should be 2^x
typedef enum {
AF_BACKEND_DEFAULT = 0, ///< Default backend order: OpenCL -> CUDA -> CPU
AF_BACKEND_CPU = 1, ///< CPU a.k.a sequential algorithms
AF_BACKEND_CUDA = 2, ///< CUDA Compute Backend
AF_BACKEND_OPENCL = 4, ///< OpenCL Compute Backend
} af_backend;
#endif

// Below enum is purely added for example purposes
// it doesn't and shoudn't be used anywhere in the
Expand All @@ -357,9 +382,15 @@ namespace af
typedef af_mat_prop matProp;
typedef af_colormap ColorMap;
typedef af_norm_type normType;
#if AF_API_VERSION >= 31
typedef af_ycc_std YCCStd;
#endif
#if AF_API_VERSION >= 31
typedef af_image_format imageFormat;
#endif
#if AF_API_VERSION >= 32
typedef af_backend Backend;
#endif
}

#endif
13 changes: 12 additions & 1 deletion include/af/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class AFAPI Window {
*/
void image(const array& in, const char* title=NULL);

#if AF_API_VERSION >= 32
/**
Renders the input array as an 3d line plot to the window

Expand All @@ -139,6 +140,8 @@ class AFAPI Window {
\note \p in should be 1d array of size 3n or 2d array with (3 x n) or (n x 3) channels.
*/
void plot3(const array& in, const char* title=NULL);
#endif

/**
Renders the input arrays as a 2D plot to the window

Expand All @@ -163,6 +166,7 @@ class AFAPI Window {
*/
void hist(const array& X, const double minval, const double maxval, const char* const title=NULL);

#if AF_API_VERSION >= 32
/**
Renders the input arrays as a 3D surface plot to the window

Expand All @@ -172,7 +176,9 @@ class AFAPI Window {
\note \p S should be a 2D array
*/
void surface(const array& S, const char* const title);
#endif

#if AF_API_VERSION >= 32
/**
Renders the input arrays as a 3D surface plot to the window

Expand All @@ -183,7 +189,8 @@ class AFAPI Window {

\note \p X and \p Y should be vectors or 2D arrays \p S should be s 2D array
*/
void surface(const array& xVals, const array& yVals, const array& S, const char* const title);
void surface(const array& xVals, const array& yVals, const array& S, const char* const title);
#endif

/**
Setup grid layout for multiview mode in a window
Expand Down Expand Up @@ -324,6 +331,7 @@ AFAPI af_err af_draw_image(const af_window wind, const af_array in, const af_cel
*/
AFAPI af_err af_draw_plot(const af_window wind, const af_array X, const af_array Y, const af_cell* const props);

#if AF_API_VERSION >= 32
/**
C Interface wrapper for drawing an array as a plot

Expand All @@ -340,6 +348,7 @@ AFAPI af_err af_draw_plot(const af_window wind, const af_array X, const af_array
\ingroup gfx_func_draw
*/
AFAPI af_err af_draw_plot3(const af_window wind, const af_array P, const af_cell* const props);
#endif

/**
C Interface wrapper for drawing an array as a histogram
Expand All @@ -360,6 +369,7 @@ AFAPI af_err af_draw_plot3(const af_window wind, const af_array P, const af_cell
*/
AFAPI af_err af_draw_hist(const af_window wind, const af_array X, const double minval, const double maxval, const af_cell* const props);

#if AF_API_VERSION >= 32
/**
C Interface wrapper for drawing arrayis as a surface

Expand All @@ -379,6 +389,7 @@ AFAPI af_err af_draw_hist(const af_window wind, const af_array X, const double m
*/

af_err af_draw_surface(const af_window wind, const af_array xVals, const af_array yVals, const af_array S, const af_cell* const props);
#endif

/**
C Interface wrapper for grid setup in a window
Expand Down
10 changes: 10 additions & 0 deletions include/af/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ extern "C" {
const dim_t ndims, const af_index_t* indices,
const af_array rhs);

#if AF_API_VERSION >= 32
///
/// \brief Create an quadruple of af_index_t array
///
Expand All @@ -298,7 +299,9 @@ extern "C" {
/// \ingroup index_func_util
///
AFAPI af_err af_create_indexers(af_index_t** indexers);
#endif

#if AF_API_VERSION >= 32
///
/// \brief set \p dim to given indexer af_array \p idx
///
Expand All @@ -310,7 +313,9 @@ extern "C" {
/// \ingroup index_func_util
///
AFAPI af_err af_set_array_indexer(af_index_t* indexer, const af_array idx, const dim_t dim);
#endif

#if AF_API_VERSION >= 32
///
/// \brief set \p dim to given indexer af_array \p idx
///
Expand All @@ -323,7 +328,9 @@ extern "C" {
///
AFAPI af_err af_set_seq_indexer(af_index_t* indexer, const af_seq* idx,
const dim_t dim, const bool is_batch);
#endif

#if AF_API_VERSION >= 32
///
/// \brief set \p dim to given indexer af_array \p idx
///
Expand All @@ -340,7 +347,9 @@ extern "C" {
AFAPI af_err af_set_seq_param_indexer(af_index_t* indexer,
const double begin, const double end, const double step,
const dim_t dim, const bool is_batch);
#endif

#if AF_API_VERSION >= 32
///
/// \brief Release's the memory resource used by the quadruple af_index_t array
///
Expand All @@ -350,6 +359,7 @@ extern "C" {
/// \ingroup index_func_util
///
AFAPI af_err af_release_indexers(af_index_t* indexers);
#endif

#ifdef __cplusplus
}
Expand Down
4 changes: 4 additions & 0 deletions include/af/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ struct dtype_traits<unsigned long long> {
static const char* getName() { return "ulong"; }
};

#if AF_API_VERSION >= 32
template<>
struct dtype_traits<short> {
enum {
Expand All @@ -148,7 +149,9 @@ struct dtype_traits<short> {
typedef short base_type;
static const char* getName() { return "short"; }
};
#endif

#if AF_API_VERSION >= 32
template<>
struct dtype_traits<unsigned short> {
enum {
Expand All @@ -158,6 +161,7 @@ struct dtype_traits<unsigned short> {
typedef unsigned short base_type;
static const char* getName() { return "ushort"; }
};
#endif

}

Expand Down
13 changes: 3 additions & 10 deletions src/api/c/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,9 @@ af_err af_iota(af_array *result, const unsigned ndims, const dim_t * const dims,

DIM_ASSERT(1, ndims > 0 && ndims <= 4);
DIM_ASSERT(3, t_ndims > 0 && t_ndims <= 4);
dim4 d;
dim4 t;
for(unsigned i = 0; i < 4; i++) {
d[i] = dims[i];
DIM_ASSERT(2, d[i] >= 1);
}
for(unsigned i = 0; i < 4; i++) {
t[i] = tdims[i];
DIM_ASSERT(4, t[i] >= 1);
}

dim4 d = verifyDims(ndims, dims);
dim4 t = verifyDims(t_ndims, tdims);

switch(type) {
case f32: out = iota_<float >(d, t); break;
Expand Down
7 changes: 5 additions & 2 deletions src/api/c/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ af_err af_device_array(af_array *arr, const void *data,
AF_CHECK(af_init());

af_array res;
af::dim4 d((size_t)dims[0]);
for(unsigned i = 1; i < ndims; i++) {

DIM_ASSERT(1, ndims >= 1);
dim4 d(1, 1, 1, 1);
for(unsigned i = 0; i < ndims; i++) {
d[i] = dims[i];
DIM_ASSERT(3, dims[i] >= 1);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavanky while the older implementation in this would still be accurate, I think it is important to ensure that ndims >= 1 before running the loop. If you think this is not necessary, I'll revert the commit.


switch (type) {
Expand Down
4 changes: 2 additions & 2 deletions src/api/c/sift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ af_err af_sift(af_features* feat, af_array* desc, const af_array in, const unsig
}
std::swap(*desc, tmp_desc);
#else
AF_ERROR("ArrayFire was not built with nonfree support, SIFT disabled\n", AFF_ERR_NONFREE);
AF_ERROR("ArrayFire was not built with nonfree support, SIFT disabled\n", AF_ERR_NONFREE);
#endif
}
CATCHALL;
Expand Down Expand Up @@ -123,7 +123,7 @@ af_err af_gloh(af_features* feat, af_array* desc, const af_array in, const unsig
}
std::swap(*desc, tmp_desc);
#else
AF_ERROR("ArrayFire was not built with nonfree support, GLOH disabled\n", AFF_ERR_NONFREE);
AF_ERROR("ArrayFire was not built with nonfree support, GLOH disabled\n", AF_ERR_NONFREE);
#endif
}
CATCHALL;
Expand Down
Loading