Skip to content
Draft
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
10 changes: 9 additions & 1 deletion .github/workflows/unix_cpu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ jobs:
blas_backend: [Atlas, MKL, OpenBLAS]
os: [ubuntu-20.04, macos-latest]
compiler: [gcc, clang, icx]
graphics: [ON]
include:
- os: ubuntu-20.04
blas_backend: OpenBLAS
compiler: gcc
graphics: OFF
exclude:
- os: macos-latest
blas_backend: Atlas
Expand Down Expand Up @@ -163,6 +169,7 @@ jobs:
env:
USE_MKL: ${{ matrix.blas_backend == 'MKL' }}
BLAS_BACKEND: ${{ matrix.blas_backend }}
GRAPHICS: ${{ matrix.graphics }}
CC: ${{ matrix.compiler }}
OS_NAME: ${{ matrix.os }}
run: |
Expand All @@ -172,7 +179,7 @@ jobs:
buildname=$(if [ -z "$prnum" ]; then echo "$branch"; else echo "PR-$prnum"; fi)
dashboard=$(if [ -z "$prnum" ]; then echo "Continuous"; else echo "Experimental"; fi)
backend=$(if [ "$USE_MKL" == true ]; then echo "Intel-MKL"; else echo "FFTW/LAPACK/BLAS"; fi)
buildname="$buildname-cpu-$BLAS_BACKEND"
buildname="$buildname-cpu-$BLAS_BACKEND$(if [ "$GRAPHICS" == OFF ]; then echo "-nogfx"; fi)"
cmake_rpath=$(if [ $OS_NAME == 'macos-latest' ]; then echo "-DCMAKE_INSTALL_RPATH=/opt/arrayfire/lib"; fi)
if [ "$CC" == 'icx' ] || [ "$USE_MKL" == true ]; then source /opt/intel/oneapi/setvars.sh; fi
mkdir build && cd build && unset VCPKG_ROOT
Expand All @@ -181,6 +188,7 @@ jobs:
-DAF_BUILD_CUDA:BOOL=OFF -DAF_BUILD_OPENCL:BOOL=OFF \
-DAF_BUILD_UNIFIED:BOOL=OFF -DAF_BUILD_EXAMPLES:BOOL=ON \
-DAF_BUILD_FORGE:BOOL=ON \
-DAF_WITH_GRAPHICS:BOOL=${GRAPHICS} \
-DAF_COMPUTE_LIBRARY:STRING=${backend} \
"$cmake_rpath" \
-DBUILDNAME:STRING=${buildname} ..
Expand Down
19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ endif()
find_package(CUDA 10.2)
find_package(cuDNN 4.0)
find_package(OpenCL 1.2)
find_package(OpenGL)
find_package(glad CONFIG QUIET)
option(AF_WITH_GRAPHICS
"Build the graphics API (Forge, OpenGL, glad). When OFF the graphics functions return AF_ERR_NOT_CONFIGURED" ON)
if(AF_WITH_GRAPHICS)
find_package(OpenGL)
find_package(glad CONFIG QUIET)
endif()
find_package(FreeImage)
find_package(Threads)
find_package(FFTW)
Expand Down Expand Up @@ -98,8 +102,9 @@ option(AF_BUILD_UNIFIED "Build Backend-Independent ArrayFire API" ON)
option(AF_BUILD_DOCS "Create ArrayFire Documentation" ${DOXYGEN_FOUND})
option(AF_BUILD_EXAMPLES "Build Examples" ON)
option(AF_WITH_CUDNN "Use cuDNN for convolveNN functions" ${cuDNN_FOUND})
option(AF_BUILD_FORGE
"Forge libs are not built by default as it is not link time dependency" OFF)
cmake_dependent_option(AF_BUILD_FORGE
"Forge libs are not built by default as it is not link time dependency" OFF
"AF_WITH_GRAPHICS" OFF)

option(AF_WITH_NONFREE "Build ArrayFire nonfree algorithms" OFF)
option(AF_WITH_LOGGING "Build ArrayFire with logging support" ON)
Expand Down Expand Up @@ -252,7 +257,9 @@ endif()
#Configure forge submodule
#forge is included in ALL target if AF_BUILD_FORGE is ON
#otherwise, forge is not built at all
include(AFconfigure_forge_dep)
if(AF_WITH_GRAPHICS)
include(AFconfigure_forge_dep)
endif()

if(TARGET fmt::fmt AND AF_WITH_FMT_HEADER_ONLY)
set_target_properties(fmt::fmt
Expand Down Expand Up @@ -297,7 +304,7 @@ else()
endif()
endif()

if(NOT TARGET glad::glad)
if(AF_WITH_GRAPHICS AND NOT TARGET glad::glad)
af_dep_check_and_populate(${glad_prefix}
URI https://github.com/arrayfire/glad.git
REF main
Expand Down
4 changes: 3 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ add_subdirectory(benchmarks)
add_subdirectory(computer_vision)
add_subdirectory(financial)
add_subdirectory(getting_started)
add_subdirectory(graphics)
if(AF_WITH_GRAPHICS)
add_subdirectory(graphics)
endif()
add_subdirectory(helloworld)
add_subdirectory(image_processing)
add_subdirectory(lin_algebra)
Expand Down
23 changes: 17 additions & 6 deletions src/api/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ target_sources(c_api_interface
${CMAKE_CURRENT_SOURCE_DIR}/handle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/handle.hpp
${CMAKE_CURRENT_SOURCE_DIR}/harris.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hist.cpp
${CMAKE_CURRENT_SOURCE_DIR}/histeq.cpp
${CMAKE_CURRENT_SOURCE_DIR}/histogram.cpp
${CMAKE_CURRENT_SOURCE_DIR}/homography.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hsv_rgb.cpp
${CMAKE_CURRENT_SOURCE_DIR}/iir.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imageio.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imageio2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/implicit.cpp
Expand All @@ -124,7 +122,6 @@ target_sources(c_api_interface
${CMAKE_CURRENT_SOURCE_DIR}/optypes.hpp
${CMAKE_CURRENT_SOURCE_DIR}/orb.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pinverse.cpp
${CMAKE_CURRENT_SOURCE_DIR}/plot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/print.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qr.cpp
${CMAKE_CURRENT_SOURCE_DIR}/random.cpp
Expand All @@ -149,7 +146,6 @@ target_sources(c_api_interface
${CMAKE_CURRENT_SOURCE_DIR}/sparse_handle.hpp
${CMAKE_CURRENT_SOURCE_DIR}/stdev.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stream.cpp
${CMAKE_CURRENT_SOURCE_DIR}/surface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/susan.cpp
${CMAKE_CURRENT_SOURCE_DIR}/svd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile.cpp
Expand All @@ -162,10 +158,8 @@ target_sources(c_api_interface
${CMAKE_CURRENT_SOURCE_DIR}/unary.cpp
${CMAKE_CURRENT_SOURCE_DIR}/unwrap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/var.cpp
${CMAKE_CURRENT_SOURCE_DIR}/vector_field.cpp
${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/where.cpp
${CMAKE_CURRENT_SOURCE_DIR}/window.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wrap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ycbcr_rgb.cpp
)
Expand Down Expand Up @@ -205,3 +199,20 @@ target_include_directories(c_api_interface
${CMAKE_SOURCE_DIR}/include
$<TARGET_PROPERTY:afcommon_interface,INTERFACE_INCLUDE_DIRECTORIES>
)

if(AF_WITH_GRAPHICS)
target_sources(c_api_interface
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/hist.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image.cpp
${CMAKE_CURRENT_SOURCE_DIR}/plot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/surface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/vector_field.cpp
${CMAKE_CURRENT_SOURCE_DIR}/window.cpp
)
else()
target_sources(c_api_interface
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/graphics_stubs.cpp
)
endif()
167 changes: 167 additions & 0 deletions src/api/c/graphics_stubs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*******************************************************
* Copyright (c) 2026, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/

// Compiled instead of the graphics sources when AF_WITH_GRAPHICS is OFF.
// Every graphics entry point reports AF_ERR_NOT_CONFIGURED, the same way
// the image IO functions do when FreeImage is not built in.

#include <common/err_common.hpp>
#include <af/graphics.h>

#define AF_GRAPHICS_NOT_CONFIGURED() \
AF_RETURN_ERROR( \
"ArrayFire compiled without graphics support (AF_WITH_GRAPHICS)", \
AF_ERR_NOT_CONFIGURED)

af_err af_create_window(af_window *, const int, const int, const char* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_position(const af_window, const unsigned, const unsigned) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_title(const af_window, const char* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_size(const af_window, const unsigned, const unsigned) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_image(const af_window, const af_array, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_plot(const af_window, const af_array, const af_array,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_plot3(const af_window, const af_array, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_plot_nd(const af_window, const af_array, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_plot_2d(const af_window, const af_array, const af_array,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_plot_3d(const af_window, const af_array, const af_array,
const af_array, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_scatter(const af_window, const af_array, const af_array,
const af_marker_type, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_scatter3(const af_window, const af_array, const af_marker_type,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_scatter_nd(const af_window, const af_array,
const af_marker_type, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_scatter_2d(const af_window, const af_array, const af_array,
const af_marker_type, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_scatter_3d(const af_window, const af_array, const af_array,
const af_array, const af_marker_type,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_hist(const af_window, const af_array, const double,
const double, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_surface(const af_window, const af_array, const af_array,
const af_array, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_vector_field_nd(const af_window, const af_array,
const af_array, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_vector_field_3d(const af_window, const af_array,
const af_array, const af_array, const af_array,
const af_array, const af_array,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_draw_vector_field_2d(const af_window, const af_array,
const af_array, const af_array, const af_array,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_grid(const af_window, const int, const int) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_axes_limits_compute(const af_window, const af_array,
const af_array, const af_array, const bool,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_axes_limits_2d(const af_window, const float, const float,
const float, const float, const bool,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_axes_limits_3d(const af_window, const float, const float,
const float, const float, const float,
const float, const bool, const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_axes_titles(const af_window, const char * const,
const char * const, const char * const,
const af_cell* const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_axes_label_format(const af_window, const char *const,
const char *const, const char *const,
const af_cell *const) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_show(const af_window) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_is_window_closed(bool *, const af_window) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_set_visibility(const af_window, const bool) {
AF_GRAPHICS_NOT_CONFIGURED();
}

af_err af_destroy_window(const af_window) {
AF_GRAPHICS_NOT_CONFIGURED();
}
1 change: 0 additions & 1 deletion src/api/c/moments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <common/ArrayInfo.hpp>
#include <common/cast.hpp>
#include <common/err_common.hpp>
#include <common/graphics_common.hpp>
#include <handle.hpp>
#include <join.hpp>
#include <moments.hpp>
Expand Down
Loading
Loading