Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .github/workflows/win_cpu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: CPU (fftw, OpenBLAS, windows-latest)
runs-on: windows-latest
env:
VCPKG_HASH: 6ca56aeb457f033d344a7106cb3f9f1abf8f4e98
VCPKG_HASH: f14984af3738e69f197bf0e647a8dca12de92996
VCPKG_DEFAULT_TRIPLET: x64-windows
steps:
- name: Checkout Repository
Expand Down
101 changes: 68 additions & 33 deletions CMakeModules/FindOpenCL.cmake
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#.rst:
# FindOpenCL
# ----------
#
# Try to find OpenCL
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines :prop_tgt:`IMPORTED` target ``OpenCL::OpenCL``, if
# OpenCL has been found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables::
#
# OpenCL_FOUND - True if OpenCL was found
# OpenCL_INCLUDE_DIRS - include directories for OpenCL
# OpenCL_LIBRARIES - link against this library to use OpenCL
# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation
# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation
#
# The module will also define two cache variables::
#
# OpenCL_INCLUDE_DIR - the OpenCL include directory
# OpenCL_LIBRARY - the path to the OpenCL library
#
#[=======================================================================[.rst:
FindOpenCL
----------

.. versionadded:: 3.1

Finds Open Computing Language (OpenCL)

.. versionadded:: 3.10
Detection of OpenCL 2.1 and 2.2.

IMPORTED Targets
^^^^^^^^^^^^^^^^

.. versionadded:: 3.7

This module defines :prop_tgt:`IMPORTED` target ``OpenCL::OpenCL``, if
OpenCL has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables::

OpenCL_FOUND - True if OpenCL was found
OpenCL_INCLUDE_DIRS - include directories for OpenCL
OpenCL_LIBRARIES - link against this library to use OpenCL
OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation
OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation

The module will also define two cache variables::

OpenCL_INCLUDE_DIR - the OpenCL include directory
OpenCL_LIBRARY - the path to the OpenCL library

#]=======================================================================]

function(_FIND_OPENCL_VERSION)
include(CheckSymbolExists)
include(CMakePushCheckState)
set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})

CMAKE_PUSH_CHECK_STATE()
foreach(VERSION "2_0" "1_2" "1_1" "1_0")
foreach(VERSION "3_0" "2_2" "2_1" "2_0" "1_2" "1_1" "1_0")
set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")

if(APPLE)
Expand Down Expand Up @@ -76,6 +84,9 @@ find_path(OpenCL_INCLUDE_DIR
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
/usr/local/cuda
/opt/cuda
PATH_SUFFIXES
include
OpenCL/common/inc
Expand All @@ -94,6 +105,7 @@ if(WIN32)
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
"AMD APP/lib/x86"
lib/x86
Expand All @@ -109,16 +121,39 @@ if(WIN32)
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
"AMD APP/lib/x86_64"
lib/x86_64
lib/x64
OpenCL/common/lib/x64)
endif()
else()
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATH_SUFFIXES lib64/)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATHS
ENV AMDAPPSDKROOT
ENV CUDA_PATH
/usr/local/cuda
/opt/cuda
PATH_SUFFIXES
lib/x86
lib)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATHS
ENV AMDAPPSDKROOT
ENV CUDA_PATH
/usr/local/cuda
/opt/cuda
PATH_SUFFIXES
lib/x86_64
lib/x64
lib
lib64)
endif()
endif()

set(OpenCL_LIBRARIES ${OpenCL_LIBRARY})
Expand Down
44 changes: 23 additions & 21 deletions CMakeModules/build_cl2hpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,30 @@

find_package(OpenCL)

find_path(cl2hpp_header_file_path
NAMES CL/cl2.hpp
PATHS ${OpenCL_INCLUDE_PATHS})

if(cl2hpp_header_file_path)
add_library(cl2hpp IMPORTED INTERFACE GLOBAL)
add_library(OpenCL::cl2hpp IMPORTED INTERFACE GLOBAL)

set_target_properties(cl2hpp OpenCL::cl2hpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${cl2hpp_header_file_path})
elseif (NOT TARGET OpenCL::cl2hpp OR NOT TARGET cl2hpp)
af_dep_check_and_populate(${cl2hpp_prefix}
URI https://github.com/KhronosGroup/OpenCL-CLHPP.git
REF v2.0.12)

find_path(cl2hpp_var
if(NOT TARGET OpenCL::cl2hpp)
find_path(cl2hpp_header_file_path
NAMES CL/cl2.hpp
PATHS ${ArrayFire_BINARY_DIR}/extern/${cl2hpp_prefix}-src/include)
PATHS ${OpenCL_INCLUDE_PATHS})

add_library(cl2hpp IMPORTED INTERFACE GLOBAL)
add_library(OpenCL::cl2hpp IMPORTED INTERFACE GLOBAL)
if(cl2hpp_header_file_path)
add_library(cl2hpp IMPORTED INTERFACE GLOBAL)
add_library(OpenCL::cl2hpp IMPORTED INTERFACE GLOBAL)

set_target_properties(cl2hpp OpenCL::cl2hpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${cl2hpp_var})
set_target_properties(cl2hpp OpenCL::cl2hpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${cl2hpp_header_file_path})
elseif (NOT TARGET OpenCL::cl2hpp OR NOT TARGET cl2hpp)
af_dep_check_and_populate(${cl2hpp_prefix}
URI https://github.com/KhronosGroup/OpenCL-CLHPP.git
REF v2022.09.30)

find_path(cl2hpp_var
NAMES CL/cl2.hpp
PATHS ${ArrayFire_BINARY_DIR}/extern/${cl2hpp_prefix}-src/include)

add_library(cl2hpp IMPORTED INTERFACE GLOBAL)
add_library(OpenCL::cl2hpp IMPORTED INTERFACE GLOBAL)

set_target_properties(cl2hpp OpenCL::cl2hpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${cl2hpp_var})
endif()
endif()
2 changes: 1 addition & 1 deletion CMakeModules/vcpkg/ports/lapack-reference/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ vcpkg_cmake_configure(
OPTIONS
"-DUSE_OPTIMIZED_BLAS=${USE_OPTIMIZED_BLAS}"
"-DCBLAS=${CBLAS}"
"-DLAPACKE=ON"
"-DLAPACKE=ON"
${FORTRAN_CMAKE}
)

Expand Down
3 changes: 3 additions & 0 deletions include/af/opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
********************************************************/

#pragma once
#ifndef CL_TARGET_OPENCL_VERSION
#define CL_TARGET_OPENCL_VERSION 120
#endif
#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.h>
#else
Expand Down
9 changes: 5 additions & 4 deletions src/api/c/fftconvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ using std::vector;
template<typename T>
af_array fftconvolve_fallback(const af_array signal, const af_array filter,
const bool expand, const int baseDim) {
using convT =
typename conditional<is_integral<T>::value || is_same<T, float>::value,
float, double>::type;
using cT = typename conditional<is_same<convT, float>::value, cfloat,
using convT = typename conditional<is_integral<T>::value ||
is_same<T, float>::value ||
is_same<T, cfloat>::value,
float, double>::type;
using cT = typename conditional<is_same<convT, float>::value, cfloat,
cdouble>::type;

const Array<cT> S = castArray<cT>(signal);
Expand Down
1 change: 0 additions & 1 deletion src/api/c/imageio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,5 +1091,4 @@ af_err af_delete_image_memory(void *ptr) {
AF_RETURN_ERROR("ArrayFire compiled without Image IO (FreeImage) support",
AF_ERR_NOT_CONFIGURED);
}
} // namespace arrayfire
#endif // WITH_FREEIMAGE
22 changes: 8 additions & 14 deletions src/backend/common/ArrayFireTypesIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@

template<>
struct fmt::formatter<af_seq> {
// Parses format specifications of the form ['f' | 'e'].
constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
return ctx.begin();
}

// Formats the point p using the parsed format specification (presentation)
// stored in this formatter.
template<typename FormatContext>
auto format(const af_seq& p, FormatContext& ctx) -> decltype(ctx.out()) {
// ctx.out() is an output iterator to write to.
Expand Down Expand Up @@ -61,27 +58,24 @@ struct fmt::formatter<arrayfire::common::Version> {
}
++it;
} while (it != end && *it != '}');
return ctx.begin();
return it;
}

// Formats the point p using the parsed format specification (presentation)
// stored in this formatter.
template<typename FormatContext>
auto format(const arrayfire::common::Version& ver, FormatContext& ctx)
-> decltype(ctx.out()) {
// ctx.out() is an output iterator to write to.
// if (ver.major == -1) return format_to(ctx.out(), "N/A");
if (ver.minor == -1) show_minor = false;
if (ver.patch == -1) show_patch = false;
if (ver.major() == -1) return format_to(ctx.out(), "N/A");
if (ver.minor() == -1) show_minor = false;
if (ver.patch() == -1) show_patch = false;
if (show_major && !show_minor && !show_patch) {
return format_to(ctx.out(), "{}", ver.major);
return format_to(ctx.out(), "{}", ver.major());
}
if (show_major && show_minor && !show_patch) {
return format_to(ctx.out(), "{}.{}", ver.major, ver.minor);
return format_to(ctx.out(), "{}.{}", ver.major(), ver.minor());
}
if (show_major && show_minor && show_patch) {
return format_to(ctx.out(), "{}.{}.{}", ver.major, ver.minor,
ver.patch);
return format_to(ctx.out(), "{}.{}.{}", ver.major(), ver.minor(),
ver.patch());
}
return ctx.out();
}
Expand Down
9 changes: 5 additions & 4 deletions src/backend/common/DependencyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ vector<string> libNames(const std::string& name, const string& suffix,
UNUSED(suffix);
const string noVerName = libraryPrefix + name + librarySuffix;
if (ver != arrayfire::common::NullVersion) {
const string infix = "." + to_string(ver.major) + ".";
const string infix = "." + to_string(ver.major()) + ".";
return {libraryPrefix + name + infix + librarySuffix, noVerName};
} else {
return {noVerName};
Expand All @@ -71,10 +71,11 @@ vector<string> libNames(const std::string& name, const string& suffix,
UNUSED(suffix);
const string noVerName = libraryPrefix + name + librarySuffix;
if (ver != arrayfire::common::NullVersion) {
const string soname("." + to_string(ver.major));
const string soname("." + to_string(ver.major()));

const string vsfx = "." + to_string(ver.major) + "." +
to_string(ver.minor) + "." + to_string(ver.patch);
const string vsfx = "." + to_string(ver.major()) + "." +
to_string(ver.minor()) + "." +
to_string(ver.patch());
return {noVerName + vsfx, noVerName + soname, noVerName};
} else {
return {noVerName};
Expand Down
25 changes: 15 additions & 10 deletions src/backend/common/Version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

namespace arrayfire {
namespace common {
struct Version {
int major = -1;
int minor = -1;
int patch = -1;
class Version {
int major_ = -1;
int minor_ = -1;
int patch_ = -1;

public:
/// Checks if the major version is defined before minor and minor is defined
/// before patch
constexpr static bool validate(int major_, int minor_,
Expand All @@ -34,14 +35,18 @@ struct Version {
!(minor_ < 0 && patch_ >= 0);
}

constexpr int major() const { return major_; }
constexpr int minor() const { return minor_; }
constexpr int patch() const { return patch_; }

constexpr Version(const int ver_major, const int ver_minor = -1,
const int ver_patch = -1) noexcept
: major(ver_major), minor(ver_minor), patch(ver_patch) {}
: major_(ver_major), minor_(ver_minor), patch_(ver_patch) {}
};

constexpr bool operator==(const Version& lhs, const Version& rhs) {
return lhs.major == rhs.major && lhs.minor == rhs.minor &&
lhs.patch == rhs.patch;
return lhs.major() == rhs.major() && lhs.minor() == rhs.minor() &&
lhs.patch() == rhs.patch();
}

constexpr bool operator!=(const Version& lhs, const Version& rhs) {
Expand All @@ -52,11 +57,11 @@ constexpr static Version NullVersion{-1, -1, -1};

constexpr bool operator<(const Version& lhs, const Version& rhs) {
if (lhs == NullVersion || rhs == NullVersion) return false;
if (lhs.major != -1 && rhs.major != -1 && lhs.major < rhs.major)
if (lhs.major() != -1 && rhs.major() != -1 && lhs.major() < rhs.major())
return true;
if (lhs.minor != -1 && rhs.minor != -1 && lhs.minor < rhs.minor)
if (lhs.minor() != -1 && rhs.minor() != -1 && lhs.minor() < rhs.minor())
return true;
if (lhs.patch != -1 && rhs.patch != -1 && lhs.patch < rhs.patch)
if (lhs.patch() != -1 && rhs.patch() != -1 && lhs.patch() < rhs.patch())
return true;
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/backend/cuda/convolveNN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pair<cudnnConvolutionFwdAlgo_t, size_t> getForwardAlgorithm(
size_t workspace_bytes = 0;

auto version = getCudnnPlugin().getVersion();
if (version.major >= 8) {
if (version.major() >= 8) {
int maxAlgoCount = 0;
CUDNN_CHECK(cuda::cudnnGetConvolutionForwardAlgorithmMaxCount(
cudnn, &maxAlgoCount));
Expand Down Expand Up @@ -419,7 +419,7 @@ pair<cudnnConvolutionBwdFilterAlgo_t, size_t> getBackwardFilterAlgorithm(
size_t workspace_bytes = 0;

auto version = getCudnnPlugin().getVersion();
if (version.major >= 8) {
if (version.major() >= 8) {
int maxAlgoCount = 0;
CUDNN_CHECK(cuda::cudnnGetConvolutionBackwardFilterAlgorithmMaxCount(
cudnn, &maxAlgoCount));
Expand Down
Loading