summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorSamuel Antao <sfantao@us.ibm.com>2016-02-06 02:12:34 +0000
committerSamuel Antao <sfantao@us.ibm.com>2016-02-06 02:12:34 +0000
commit3f465c095b22400c1d08295b8890477fa4e6ffda (patch)
tree8d372f71bfd5afcbe31831d52e903e05ef1dfd24 /clang/lib/CodeGen/CodeGenModule.cpp
parentaada85c5f707eafc2abbc92696c3394b7be762bd (diff)
downloadbcm5719-llvm-3f465c095b22400c1d08295b8890477fa4e6ffda.tar.gz
bcm5719-llvm-3f465c095b22400c1d08295b8890477fa4e6ffda.zip
[OpenMP] Reorganize code to allow specialized code generation for different devices.
Summary: Different devices may in some cases require different code generation schemes in order to implement OpenMP. This is required not only for performance reasons, but also because it may not be possible to have the current (default) implementation working for these devices. E.g. GPU's cannot implement the same scheme a target such as powerpc or x86b would use, in the sense that it does not have the ability to fork threads, instead all the threads are always executing and need to be managed by the implementation. This patch proposes a reorganization of the code in the OpenMP code generation to pave the way to have specialized implementation of OpenMP support. More than a "real" patch this is more a request for comments in order to understand if what is proposed is acceptable or if there are better/easier ways to do it. In this patch part of the common OpenMP codegen infrastructure is moved to a new file under a new namespace (CGOpenMPCommon) so it can be shared between the default implementation and the specialized one. When CGOpenMPRuntime is created, an attempt to select a specialized implementation is done. In the patch a specialization for nvptx targets is done which currently checks if the target is an OpenMP device and trap if it is not. Let me know comments suggestions you may have. Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev Subscribers: Hahnfeld, cfe-commits, fraggamuffin, caomhin, jholewinski Differential Revision: http://reviews.llvm.org/D16784 llvm-svn: 259977
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index a30e62499fa..aabcc524c93 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -20,6 +20,7 @@
#include "CGObjCRuntime.h"
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
+#include "CGOpenMPRuntimeNVPTX.h"
#include "CodeGenFunction.h"
#include "CodeGenPGO.h"
#include "CodeGenTBAA.h"
@@ -200,7 +201,20 @@ void CodeGenModule::createOpenCLRuntime() {
}
void CodeGenModule::createOpenMPRuntime() {
- OpenMPRuntime = new CGOpenMPRuntime(*this);
+ // Select a specialized code generation class based on the target, if any.
+ // If it does not exist use the default implementation.
+ switch (getTarget().getTriple().getArch()) {
+
+ case llvm::Triple::nvptx:
+ case llvm::Triple::nvptx64:
+ assert(getLangOpts().OpenMPIsDevice &&
+ "OpenMP NVPTX is only prepared to deal with device code.");
+ OpenMPRuntime = new CGOpenMPRuntimeNVPTX(*this);
+ break;
+ default:
+ OpenMPRuntime = new CGOpenMPRuntime(*this);
+ break;
+ }
}
void CodeGenModule::createCUDARuntime() {
OpenPOWER on IntegriCloud