From c5777cc486dd042c1df8d13dcf90acebe7d2d86d Mon Sep 17 00:00:00 2001 From: Jaume Bosch Date: Tue, 19 Jun 2018 15:43:46 +0200 Subject: [PATCH] Allow GPU and OpenCL helpers share the cpu Do not fail when the GPU or OpenCL plugin try to reserve an SMP processor but there are not available. Instead, the runtime will show a warning and share the core with another thread --- src/arch/gpu/gpuplugin.cpp | 12 +++++++++--- src/arch/opencl/openclplugin.cpp | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/arch/gpu/gpuplugin.cpp b/src/arch/gpu/gpuplugin.cpp index 71a39b158..89cf4698f 100644 --- a/src/arch/gpu/gpuplugin.cpp +++ b/src/arch/gpu/gpuplugin.cpp @@ -67,11 +67,17 @@ class GPUPlugin : public ArchPlugin if ( core == NULL ) { core = sys.getSMPPlugin()->getLastFreeSMPProcessorAndReserve(); if ( core == NULL ) { - fatal0("Unable to get a core to run the GPU thread."); + core = sys.getSMPPlugin()->getLastSMPProcessor(); + if ( core == NULL ) { + fatal0("Unable to get a core to run the GPU thread."); + } + warning0("Unable to get an exclusive cpu to run the CPU thread. The thread will run on PE " << core->getId() << " and share the cpu"); + } + if (node != core->getNumaNode()) { + warning0("Unable to get a cpu on numa node " << node << " to run the CPU thread. Will run on numa node "<< core->getNumaNode()); } - warning0("Unable to get a cpu on numa node " << node << " to run the CPU thread. Will run on numa node "<< core->getNumaNode()); } - core->setNumFutureThreads( 1 ); + core->setNumFutureThreads( core->getNumFutureThreads() + 1 ); //bool reserved; //unsigned pe = sys.reservePE( numa, node, reserved ); diff --git a/src/arch/opencl/openclplugin.cpp b/src/arch/opencl/openclplugin.cpp index 2b925256e..a80390015 100644 --- a/src/arch/opencl/openclplugin.cpp +++ b/src/arch/opencl/openclplugin.cpp @@ -64,9 +64,13 @@ namespace ext { ext::SMPProcessor *core = sys.getSMPPlugin()->getLastFreeSMPProcessorAndReserve(); if ( core == NULL ) { - fatal0("Unable to get a core to run the GPU thread."); + core = sys.getSMPPlugin()->getLastSMPProcessor(); + if ( core == NULL ) { + fatal0("Unable to get a core to run the OpenCL host thread."); + } + warning0("Unable to get an exclusive cpu to run the OpenCL thread. The thread will run on PE " << core->getId() << " and share the cpu"); } - core->setNumFutureThreads( 1 ); + core->setNumFutureThreads( core->getNumFutureThreads() + 1 ); _opencls.push_back( NEW nanos::ext::OpenCLProcessor( openclC, id, core, oclmemory ) ); } -- GitLab