Skip to content
2 changes: 1 addition & 1 deletion CMakeModules/CMakeSYCLInformation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ endif()

if(NOT CMAKE_SYCL_LINK_EXECUTABLE)
set(CMAKE_SYCL_LINK_EXECUTABLE
"<CMAKE_SYCL_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
"<CMAKE_SYCL_COMPILER> <FLAGS> <CMAKE_SYCL_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endif()


Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
cmake_policy(VERSION 3.5)
project(ArrayFire-Examples
VERSION 3.7.0
Expand Down
2 changes: 1 addition & 1 deletion examples/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Benchmarks
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/computer_vision/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Computer-Vision
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/financial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Financial
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/getting_started/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Getting-Started
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Graphics
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-HelloWorld
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/image_processing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Image-Processing
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/lin_algebra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Linear-Algebra
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/machine_learning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Linear-Algebra
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/pde/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-PDE
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/unified/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(ArrayFire-Example-Unified
VERSION 3.5.0
LANGUAGES CXX)
Expand Down
55 changes: 28 additions & 27 deletions src/api/c/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using af::dim4;
using arrayfire::copyData;
using arrayfire::copySparseArray;
using arrayfire::getSparseArrayBase;
using arrayfire::getUseCount;
using arrayfire::releaseHandle;
using arrayfire::releaseSparseHandle;
using arrayfire::retainSparseHandle;
Expand Down Expand Up @@ -192,24 +193,24 @@ af_err af_copy_array(af_array *out, const af_array in) {
// Strong Exception Guarantee
af_err af_get_data_ref_count(int *use_count, const af_array in) {
try {
const ArrayInfo &info = getInfo(in, false, false);
const ArrayInfo &info = getInfo(in, false);
const af_dtype type = info.getType();

int res;
switch (type) {
case f32: res = getArray<float>(in).useCount(); break;
case c32: res = getArray<cfloat>(in).useCount(); break;
case f64: res = getArray<double>(in).useCount(); break;
case c64: res = getArray<cdouble>(in).useCount(); break;
case b8: res = getArray<char>(in).useCount(); break;
case s32: res = getArray<int>(in).useCount(); break;
case u32: res = getArray<uint>(in).useCount(); break;
case u8: res = getArray<uchar>(in).useCount(); break;
case s64: res = getArray<intl>(in).useCount(); break;
case u64: res = getArray<uintl>(in).useCount(); break;
case s16: res = getArray<short>(in).useCount(); break;
case u16: res = getArray<ushort>(in).useCount(); break;
case f16: res = getArray<half>(in).useCount(); break;
case f32: res = getUseCount<float>(in); break;
case c32: res = getUseCount<cfloat>(in); break;
case f64: res = getUseCount<double>(in); break;
case c64: res = getUseCount<cdouble>(in); break;
case b8: res = getUseCount<char>(in); break;
case s32: res = getUseCount<int>(in); break;
case u32: res = getUseCount<uint>(in); break;
case u8: res = getUseCount<uchar>(in); break;
case s64: res = getUseCount<intl>(in); break;
case u64: res = getUseCount<uintl>(in); break;
case s16: res = getUseCount<short>(in); break;
case u16: res = getUseCount<ushort>(in); break;
case f16: res = getUseCount<half>(in); break;
default: TYPE_ERROR(1, type);
}
std::swap(*use_count, res);
Expand All @@ -221,7 +222,7 @@ af_err af_get_data_ref_count(int *use_count, const af_array in) {
af_err af_release_array(af_array arr) {
try {
if (arr == 0) { return AF_SUCCESS; }
const ArrayInfo &info = getInfo(arr, false, false);
const ArrayInfo &info = getInfo(arr, false);
af_dtype type = info.getType();

if (info.isSparse()) {
Expand Down Expand Up @@ -335,7 +336,7 @@ af_err af_write_array(af_array arr, const void *data, const size_t bytes,
af_err af_get_elements(dim_t *elems, const af_array arr) {
try {
// Do not check for device mismatch
*elems = getInfo(arr, false, false).elements();
*elems = getInfo(arr, false).elements();
}
CATCHALL
return AF_SUCCESS;
Expand All @@ -344,7 +345,7 @@ af_err af_get_elements(dim_t *elems, const af_array arr) {
af_err af_get_type(af_dtype *type, const af_array arr) {
try {
// Do not check for device mismatch
*type = getInfo(arr, false, false).getType();
*type = getInfo(arr, false).getType();
}
CATCHALL
return AF_SUCCESS;
Expand All @@ -354,7 +355,7 @@ af_err af_get_dims(dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3,
const af_array in) {
try {
// Do not check for device mismatch
const ArrayInfo &info = getInfo(in, false, false);
const ArrayInfo &info = getInfo(in, false);
*d0 = info.dims()[0];
*d1 = info.dims()[1];
*d2 = info.dims()[2];
Expand All @@ -367,22 +368,22 @@ af_err af_get_dims(dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3,
af_err af_get_numdims(unsigned *nd, const af_array in) {
try {
// Do not check for device mismatch
const ArrayInfo &info = getInfo(in, false, false);
const ArrayInfo &info = getInfo(in, false);
*nd = info.ndims();
}
CATCHALL
return AF_SUCCESS;
}

#undef INSTANTIATE
#define INSTANTIATE(fn1, fn2) \
af_err fn1(bool *result, const af_array in) { \
try { \
const ArrayInfo &info = getInfo(in, false, false); \
*result = info.fn2(); \
} \
CATCHALL \
return AF_SUCCESS; \
#define INSTANTIATE(fn1, fn2) \
af_err fn1(bool *result, const af_array in) { \
try { \
const ArrayInfo &info = getInfo(in, false); \
*result = info.fn2(); \
} \
CATCHALL \
return AF_SUCCESS; \
}

INSTANTIATE(af_is_empty, isEmpty)
Expand Down
16 changes: 8 additions & 8 deletions src/api/c/binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ af_err af_add(af_array *out, const af_array lhs, const af_array rhs,
const bool batchMode) {
try {
// Check if inputs are sparse
const ArrayInfo &linfo = getInfo(lhs, false, true);
const ArrayInfo &rinfo = getInfo(rhs, false, true);
const ArrayInfo &linfo = getInfo(lhs, false);
const ArrayInfo &rinfo = getInfo(rhs, false);

if (linfo.isSparse() && rinfo.isSparse()) {
return af_arith_sparse<af_add_t>(out, lhs, rhs);
Expand All @@ -301,8 +301,8 @@ af_err af_mul(af_array *out, const af_array lhs, const af_array rhs,
const bool batchMode) {
try {
// Check if inputs are sparse
const ArrayInfo &linfo = getInfo(lhs, false, true);
const ArrayInfo &rinfo = getInfo(rhs, false, true);
const ArrayInfo &linfo = getInfo(lhs, false);
const ArrayInfo &rinfo = getInfo(rhs, false);

if (linfo.isSparse() && rinfo.isSparse()) {
// return af_arith_sparse<af_mul_t>(out, lhs, rhs);
Expand All @@ -327,8 +327,8 @@ af_err af_sub(af_array *out, const af_array lhs, const af_array rhs,
const bool batchMode) {
try {
// Check if inputs are sparse
const ArrayInfo &linfo = getInfo(lhs, false, true);
const ArrayInfo &rinfo = getInfo(rhs, false, true);
const ArrayInfo &linfo = getInfo(lhs, false);
const ArrayInfo &rinfo = getInfo(rhs, false);

if (linfo.isSparse() && rinfo.isSparse()) {
return af_arith_sparse<af_sub_t>(out, lhs, rhs);
Expand All @@ -350,8 +350,8 @@ af_err af_div(af_array *out, const af_array lhs, const af_array rhs,
const bool batchMode) {
try {
// Check if inputs are sparse
const ArrayInfo &linfo = getInfo(lhs, false, true);
const ArrayInfo &rinfo = getInfo(rhs, false, true);
const ArrayInfo &linfo = getInfo(lhs, false);
const ArrayInfo &rinfo = getInfo(rhs, false);

if (linfo.isSparse() && rinfo.isSparse()) {
// return af_arith_sparse<af_div_t>(out, lhs, rhs);
Expand Down
8 changes: 4 additions & 4 deletions src/api/c/blas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ af_err af_gemm(af_array *out, const af_mat_prop optLhs,
const af_mat_prop optRhs, const void *alpha, const af_array lhs,
const af_array rhs, const void *beta) {
try {
const ArrayInfo &lhsInfo = getInfo(lhs, false, true);
const ArrayInfo &rhsInfo = getInfo(rhs, true, true);
const ArrayInfo &lhsInfo = getInfo(lhs, false);
const ArrayInfo &rhsInfo = getInfo(rhs, true);

af_dtype lhs_type = lhsInfo.getType();
af_dtype rhs_type = rhsInfo.getType();
Expand Down Expand Up @@ -227,8 +227,8 @@ af_err af_gemm(af_array *out, const af_mat_prop optLhs,
af_err af_matmul(af_array *out, const af_array lhs, const af_array rhs,
const af_mat_prop optLhs, const af_mat_prop optRhs) {
try {
const ArrayInfo &lhsInfo = getInfo(lhs, false, true);
const ArrayInfo &rhsInfo = getInfo(rhs, true, true);
const ArrayInfo &lhsInfo = getInfo(lhs, false);
const ArrayInfo &rhsInfo = getInfo(rhs, true);

if (lhsInfo.isSparse()) {
return af_sparse_matmul(out, lhs, rhs, optLhs, optRhs);
Expand Down
4 changes: 2 additions & 2 deletions src/api/c/cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using detail::uintl;
using detail::ushort;

static af_array cast(const af_array in, const af_dtype type) {
const ArrayInfo& info = getInfo(in, false, true);
const ArrayInfo& info = getInfo(in, false);

if (info.getType() == type) { return retain(in); }

Expand Down Expand Up @@ -68,7 +68,7 @@ static af_array cast(const af_array in, const af_dtype type) {

af_err af_cast(af_array* out, const af_array in, const af_dtype type) {
try {
const ArrayInfo& info = getInfo(in, false, true);
const ArrayInfo& info = getInfo(in, false);

af_dtype inType = info.getType();
if ((inType == c32 || inType == c64) &&
Expand Down
4 changes: 2 additions & 2 deletions src/api/c/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ af_err af_get_available_backends(int* result) {
af_err af_get_backend_id(af_backend* result, const af_array in) {
try {
if (in) {
const ArrayInfo& info = getInfo(in, false, false);
const ArrayInfo& info = getInfo(in, false);
*result = info.getBackendId();
} else {
return AF_ERR_ARG;
Expand All @@ -93,7 +93,7 @@ af_err af_get_backend_id(af_backend* result, const af_array in) {
af_err af_get_device_id(int* device, const af_array in) {
try {
if (in) {
const ArrayInfo& info = getInfo(in, false, false);
const ArrayInfo& info = getInfo(in, false);
*device = static_cast<int>(info.getDevId());
} else {
return AF_ERR_ARG;
Expand Down
6 changes: 3 additions & 3 deletions src/api/c/handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using detail::ushort;
namespace arrayfire {

af_array retain(const af_array in) {
const ArrayInfo &info = getInfo(in, false, false);
const ArrayInfo &info = getInfo(in, false);
af_dtype ty = info.getType();

if (info.isSparse()) {
Expand Down Expand Up @@ -139,9 +139,9 @@ dim4 verifyDims(const unsigned ndims, const dim_t *const dims) {

template<typename T>
void releaseHandle(const af_array arr) {
auto &Arr = getArray<T>(arr);
auto &info = getInfo(arr);
int old_device = detail::getActiveDeviceId();
int array_id = Arr.getDevId();
int array_id = info.getDevId();
if (array_id != old_device) {
detail::setDevice(array_id);
detail::destroyArray(static_cast<detail::Array<T> *>(arr));
Expand Down
16 changes: 14 additions & 2 deletions src/api/c/handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ af_array createHandleFromDeviceData(const af::dim4 &d, af_dtype dtype,
void *data);

namespace common {
const ArrayInfo &getInfo(const af_array arr, bool sparse_check = true,
bool device_check = true);
const ArrayInfo &getInfo(const af_array arr, bool sparse_check = true);

template<typename To>
detail::Array<To> castArray(const af_array &in);
Expand All @@ -53,6 +52,7 @@ const detail::Array<T> &getArray(const af_array &arr) {
const detail::Array<T> *A = static_cast<const detail::Array<T> *>(arr);
if ((af_dtype)af::dtype_traits<T>::af_type != A->getType())
AF_ERROR("Invalid type for input array.", AF_ERR_INTERNAL);
checkAndMigrate(*const_cast<detail::Array<T> *>(A));
return *A;
}

Expand All @@ -61,9 +61,21 @@ detail::Array<T> &getArray(af_array &arr) {
detail::Array<T> *A = static_cast<detail::Array<T> *>(arr);
if ((af_dtype)af::dtype_traits<T>::af_type != A->getType())
AF_ERROR("Invalid type for input array.", AF_ERR_INTERNAL);
checkAndMigrate(*A);
return *A;
}

/// Returns the use count
///
/// \note This function is called separately because we cannot call getArray in
/// case the data was built on a different context. so we are avoiding the check
/// and migrate function
template<typename T>
int getUseCount(const af_array &arr) {
detail::Array<T> *A = static_cast<detail::Array<T> *>(arr);
return A->useCount();
}

template<typename T>
af_array getHandle(const detail::Array<T> &A) {
detail::Array<T> *ret = new detail::Array<T>(A);
Expand Down
Loading