From 15d5ac8dd039132926ac8012559ca5e3a405f858 Mon Sep 17 00:00:00 2001 From: Anthony Barbier Date: Mon, 17 Jul 2017 15:22:17 +0100 Subject: COMPMID-415 Fix issue with OpenCL examples Change-Id: Ie4797e88fd2ad38f30cb69651ed37481b835fae8 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/80781 Reviewed-by: Moritz Pflanzer Tested-by: Kaizen --- docs/00_introduction.dox | 10 +++++----- examples/SConscript | 4 ++-- examples/cl_convolution.cpp | 5 ++++- examples/cl_events.cpp | 5 ++++- examples/neoncl_scale_median_gaussian.cpp | 5 ++++- scripts/clang-tidy.sh | 2 +- tests/SConscript | 2 +- tests/benchmark_new/main.cpp | 8 ++++---- 8 files changed, 25 insertions(+), 16 deletions(-) diff --git a/docs/00_introduction.dox b/docs/00_introduction.dox index d4b4b6f10d..c4674a2c9c 100644 --- a/docs/00_introduction.dox +++ b/docs/00_introduction.dox @@ -424,11 +424,11 @@ To cross compile a NEON example for Linux 64bit: To cross compile an OpenCL example for Linux 32bit: - arm-linux-gnueabihf-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L. -larm_compute -lOpenCL -o cl_convolution + arm-linux-gnueabihf-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L. -larm_compute -lOpenCL -o cl_convolution -DARM_COMPUTE_CL To cross compile an OpenCL example for Linux 64bit: - aarch64-linux-gnu-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -L. -larm_compute -lOpenCL -o cl_convolution + aarch64-linux-gnu-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -L. -larm_compute -lOpenCL -o cl_convolution -DARM_COMPUTE_CL (notice the only difference with the 32 bit command is that we don't need the -mfpu option and the compiler's name is different) @@ -444,7 +444,7 @@ To compile natively (i.e directly on an ARM device) for NEON for Linux 64bit: To compile natively (i.e directly on an ARM device) for OpenCL for Linux 32bit or Linux 64bit: - g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -lOpenCL -o cl_convolution + g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -lOpenCL -o cl_convolution -DARM_COMPUTE_CL @note These two commands assume libarm_compute.so is available in your library path, if not add the path to it using -L @@ -509,9 +509,9 @@ To cross compile a NEON example: To cross compile an OpenCL example: #32 bit: - arm-linux-androideabi-clang++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_arm -static-libstdc++ -pie -lOpenCL + arm-linux-androideabi-clang++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_arm -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL #64 bit: - aarch64-linux-android-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_aarch64 -static-libstdc++ -pie -lOpenCL + aarch64-linux-android-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_aarch64 -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL @note Due to some issues in older versions of the Mali OpenCL DDK (<= r13p0), we recommend to link arm_compute statically on Android. diff --git a/examples/SConscript b/examples/SConscript index 04569c6ceb..2303109bf5 100644 --- a/examples/SConscript +++ b/examples/SConscript @@ -48,7 +48,7 @@ else: if env['opencl'] and env['neon']: for file in Glob("./neoncl_*.cpp"): example = os.path.basename(os.path.splitext(str(file))[0]) - prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = [arm_compute_lib, "OpenCL"]) + prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = [arm_compute_lib, "OpenCL"]) Depends(prog, [arm_compute_dependency, opencl]) alias = examples_env.Alias(example, prog) Default(alias) @@ -56,7 +56,7 @@ if env['opencl'] and env['neon']: if env['opencl']: for file in Glob("./cl_*.cpp"): example = os.path.basename(os.path.splitext(str(file))[0]) - prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = [arm_compute_lib, "OpenCL"]) + prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = [arm_compute_lib, "OpenCL"]) Depends(prog, [arm_compute_dependency, opencl]) alias = examples_env.Alias(example, prog) Default(alias) diff --git a/examples/cl_convolution.cpp b/examples/cl_convolution.cpp index 06f6f144e1..b780193f14 100644 --- a/examples/cl_convolution.cpp +++ b/examples/cl_convolution.cpp @@ -21,7 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#define ARM_COMPUTE_CL /* So that OpenCL exceptions get caught too */ +#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ +#error "This example needs to be built with -DARM_COMPUTE_CL" +#endif /* ARM_COMPUTE_CL */ + #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLFunctions.h" #include "arm_compute/runtime/CL/CLScheduler.h" diff --git a/examples/cl_events.cpp b/examples/cl_events.cpp index 768f620622..213f4a19df 100644 --- a/examples/cl_events.cpp +++ b/examples/cl_events.cpp @@ -21,7 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#define ARM_COMPUTE_CL /* So that OpenCL exceptions get caught too */ +#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ +#error "This example needs to be built with -DARM_COMPUTE_CL" +#endif /* ARM_COMPUTE_CL */ + #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLFunctions.h" #include "arm_compute/runtime/CL/CLScheduler.h" diff --git a/examples/neoncl_scale_median_gaussian.cpp b/examples/neoncl_scale_median_gaussian.cpp index a32ba6daf6..e53a48e07d 100644 --- a/examples/neoncl_scale_median_gaussian.cpp +++ b/examples/neoncl_scale_median_gaussian.cpp @@ -21,7 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#define ARM_COMPUTE_CL /* So that OpenCL exceptions get caught too */ +#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ +#error "This example needs to be built with -DARM_COMPUTE_CL" +#endif /* ARM_COMPUTE_CL */ + #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLFunctions.h" #include "arm_compute/runtime/CL/CLScheduler.h" diff --git a/scripts/clang-tidy.sh b/scripts/clang-tidy.sh index 3732e2ad46..6ba3bcad64 100755 --- a/scripts/clang-tidy.sh +++ b/scripts/clang-tidy.sh @@ -84,7 +84,7 @@ function aarch64 -std=c++11 \ -include $SCRIPT_PATH/clang-tidy.h \ $INCLUDE_PATHS \ - -DARM_COMPUTE_ENABLE_FP16 -DARM_COMPUTE_CPP_SCHEDULER=1 $USE_BOOST + -DARM_COMPUTE_CL -DARM_COMPUTE_ENABLE_FP16 -DARM_COMPUTE_CPP_SCHEDULER=1 $USE_BOOST } for f in $files; do diff --git a/tests/SConscript b/tests/SConscript index 291a7a5555..77d370f91a 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -150,7 +150,7 @@ files_benchmark += Glob('new/benchmark_new/*.cpp') if env['opencl']: Import('opencl') - benchmark_env.Append(CPPDEFINES=['OPENCL']) + benchmark_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) files_benchmark += Glob('new/benchmark_new/CL/*/*.cpp') files_benchmark += Glob('new/benchmark_new/CL/*.cpp') diff --git a/tests/benchmark_new/main.cpp b/tests/benchmark_new/main.cpp index 4c6811e372..46c51b6cfd 100644 --- a/tests/benchmark_new/main.cpp +++ b/tests/benchmark_new/main.cpp @@ -30,9 +30,9 @@ #include "support/ToolchainSupport.h" #include "tests/TensorLibrary.h" -#ifdef OPENCL +#ifdef ARM_COMPUTE_CL #include "arm_compute/runtime/CL/CLScheduler.h" -#endif /* OPENCL */ +#endif /* ARM_COMPUTE_CL */ #include "arm_compute/runtime/Scheduler.h" #include @@ -55,9 +55,9 @@ std::unique_ptr library; int main(int argc, char **argv) { -#ifdef OPENCL +#ifdef ARM_COMPUTE_CL CLScheduler::get().default_init(); -#endif /* OPENCL */ +#endif /* ARM_COMPUTE_CL */ framework::Framework &framework = framework::Framework::get(); -- cgit v1.2.1