aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2020-12-30 00:03:09 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-01-13 17:00:15 +0000
commit45514031440880a9eecd2a8461e6741569d8119a (patch)
treecb1ade8c6d87a5092bdba66161350a5f5ccf286d /src
parentfefd16acf472dc7fddc57aab3773f2dec6602b20 (diff)
downloadComputeLibrary-45514031440880a9eecd2a8461e6741569d8119a.tar.gz
Add support for macOS
* Add 'macos' as an additional OS build option * Guard unsupported paths like thread scheduling control and hwcaps checking with the __APPLE__ macro * Map linker options to respective Mach-O linker options Change-Id: I67bd9fa3c20831427b218ca7d3b4b9d454ab4fec Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4788 Reviewed-by: Sang-Hoon Park <sang-hoon.park@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/CPP/CPPTypes.cpp10
-rw-r--r--src/runtime/CPP/CPPScheduler.cpp7
-rw-r--r--src/runtime/CPUUtils.cpp20
3 files changed, 19 insertions, 18 deletions
diff --git a/src/core/CPP/CPPTypes.cpp b/src/core/CPP/CPPTypes.cpp
index 55119d80a8..139e106ca6 100644
--- a/src/core/CPP/CPPTypes.cpp
+++ b/src/core/CPP/CPPTypes.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,7 +26,7 @@
#include "arm_compute/core/Error.h"
-#ifndef BARE_METAL
+#if !defined(BARE_METAL)
#include <sched.h>
#endif /* defined(BARE_METAL) */
@@ -110,9 +110,9 @@ CPUInfo::CPUInfo()
CPUModel CPUInfo::get_cpu_model() const
{
-#if defined(BARE_METAL) || (!defined(__arm__) && !defined(__aarch64__))
+#if defined(BARE_METAL) || defined(__APPLE__) || (!defined(__arm__) && !defined(__aarch64__))
return get_cpu_model(0);
-#else /* defined(BARE_METAL) || (!defined(__arm__) && !defined(__aarch64__)) */
+#else /* defined(BARE_METAL) || defined(__APPLE__) || (!defined(__arm__) && !defined(__aarch64__)) */
return get_cpu_model(sched_getcpu());
-#endif /* defined(BARE_METAL) || (!defined(__arm__) && !defined(__aarch64__)) */
+#endif /* defined(BARE_METAL) || defined(__APPLE__) || (!defined(__arm__) && !defined(__aarch64__)) */
}
diff --git a/src/runtime/CPP/CPPScheduler.cpp b/src/runtime/CPP/CPPScheduler.cpp
index 663cde7a21..e084cc6494 100644
--- a/src/runtime/CPP/CPPScheduler.cpp
+++ b/src/runtime/CPP/CPPScheduler.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2020 Arm Limited.
+ * Copyright (c) 2016-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -98,11 +98,12 @@ void set_thread_affinity(int core_id)
return;
}
+#if !defined(__APPLE__)
cpu_set_t set;
CPU_ZERO(&set);
CPU_SET(core_id, &set);
- ARM_COMPUTE_EXIT_ON_MSG(sched_setaffinity(0, sizeof(set), &set),
- "Error setting thread affinity");
+ ARM_COMPUTE_EXIT_ON_MSG(sched_setaffinity(0, sizeof(set), &set), "Error setting thread affinity");
+#endif /* !defined(__APPLE__) */
}
class Thread final
diff --git a/src/runtime/CPUUtils.cpp b/src/runtime/CPUUtils.cpp
index a7dd464540..74f0f58248 100644
--- a/src/runtime/CPUUtils.cpp
+++ b/src/runtime/CPUUtils.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -34,18 +34,18 @@
#include <fstream>
#include <map>
-#ifndef BARE_METAL
+#if !defined(BARE_METAL)
/* C++ std::regex takes up a lot of space in the standalone builds */
#include <regex.h>
#include <thread>
-#endif /* BARE_METAL */
+#endif /* !defined(BARE_METAL) */
-#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
+#if !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
#include <sys/auxv.h>
/* Get HWCAP bits from asm/hwcap.h */
#include <asm/hwcap.h>
-#endif /* !BARE_METAL */
+#endif /* !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__)) */
/* Make sure the bits we care about are defined, just in case asm/hwcap.h is
* out of date (or for bare metal mode) */
@@ -65,7 +65,7 @@ namespace
{
using namespace arm_compute;
-#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
+#if !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
bool model_supports_dot(CPUModel model)
{
@@ -346,7 +346,7 @@ int get_max_cpus()
}
return max_cpus;
}
-#endif /* !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__)) */
+#endif /* !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__)) */
} // namespace
@@ -358,7 +358,7 @@ namespace cpu
{
void get_cpu_configuration(CPUInfo &cpuinfo)
{
-#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
+#if !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
bool cpuid = false;
bool hwcaps_fp16_support = false;
bool hwcaps_dot_support = false;
@@ -406,9 +406,9 @@ void get_cpu_configuration(CPUInfo &cpuinfo)
}
cpuinfo.set_dotprod(one_supports_dot || hwcaps_dot_support);
cpuinfo.set_fp16(one_supports_fp16 || hwcaps_fp16_support);
-#else /* !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__)) */
+#else /* !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__)) */
ARM_COMPUTE_UNUSED(cpuinfo);
-#endif /* !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__)) */
+#endif /* !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__)) */
}
unsigned int get_threads_hint()