From 0f0eb09281840e4dc66725c20bbe603b66fde4d3 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Sun, 18 Aug 2024 18:44:11 +0200 Subject: [PATCH] Added basic test and disclaimer --- README.md | 2 ++ unit_tests/Test_arrayfire.cpp | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 unit_tests/Test_arrayfire.cpp diff --git a/README.md b/README.md index de9d835..17dbb0d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ You must have the ArrayFire library installed on your system. +*Disclaimer: Eclipse Aidge is not affiliated with or endorsed by ArrayFire. The ArrayFire literal mark is used under a limited license granted by ArrayFire the trademark holder in the United States and other countries.* + ## Pip installation You will need to install first the aidge_core library before installing aidge_backend_arrayfire. diff --git a/unit_tests/Test_arrayfire.cpp b/unit_tests/Test_arrayfire.cpp new file mode 100644 index 0000000..ed4a0c2 --- /dev/null +++ b/unit_tests/Test_arrayfire.cpp @@ -0,0 +1,57 @@ +/******************************************************************************** + * Copyright (c) 2023 CEA-List + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +#include <catch2/catch_test_macros.hpp> +#include <arrayfire.h> + +void testBackend() +{ + af::info(); + af_print(af::randu(5, 4)); +} + +TEST_CASE("[arrayfire] arrayfire") { + try { + printf("Trying CPU Backend\n"); + af::setBackend(AF_BACKEND_CPU); + testBackend(); + } catch (af::exception& e) { + printf("Caught exception when trying CPU backend\n"); + fprintf(stderr, "%s\n", e.what()); + } + + try { + printf("Trying oneAPI Backend\n"); + af::setBackend(AF_BACKEND_ONEAPI); + testBackend(); + } catch (af::exception& e) { + printf("Caught exception when trying oneAPI backend\n"); + fprintf(stderr, "%s\n", e.what()); + } + + try { + printf("Trying CUDA Backend\n"); + af::setBackend(AF_BACKEND_CUDA); + testBackend(); + } catch (af::exception& e) { + printf("Caught exception when trying CUDA backend\n"); + fprintf(stderr, "%s\n", e.what()); + } + + try { + printf("Trying OpenCL Backend\n"); + af::setBackend(AF_BACKEND_OPENCL); + testBackend(); + } catch (af::exception& e) { + printf("Caught exception when trying OpenCL backend\n"); + fprintf(stderr, "%s\n", e.what()); + } +} -- GitLab