[Beignet] [PATCH 21/22 V2] Use the PCH to accelerate the parsing speed of the ocl.h
junyan.he at inbox.com
junyan.he at inbox.com
Sun Aug 31 19:22:22 PDT 2014
From: Junyan He <junyan.he at linux.intel.com>
We disable the valid check for the PCH to avoid path
and modified time check, which is bring us some trouble.
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
backend/src/backend/program.cpp | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index d1f6904..4b336dd 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -616,6 +616,7 @@ namespace gbe {
}
+ SVAR(OCL_PCH_PATH, OCL_PCH_OBJECT);
SVAR(OCL_HEADER_FILE_DIR, OCL_HEADER_DIR);
static void processSourceAndOption(const char *source,
@@ -625,6 +626,10 @@ namespace gbe {
std::string& clName,
int& optLevel)
{
+ std::string dirs = OCL_PCH_PATH;
+ std::istringstream idirs(dirs);
+ std::string pchFileName;
+ bool findPCH = false;
size_t start = 0, end = 0;
std::string hdirs = OCL_HEADER_FILE_DIR;
@@ -664,6 +669,13 @@ namespace gbe {
free(str);
}
+ while (getline(idirs, pchFileName, ':')) {
+ if(access(pchFileName.c_str(), R_OK) == 0) {
+ findPCH = true;
+ break;
+ }
+ }
+
char clStr[] = "/tmp/XXXXXX.cl";
int clFd = mkstemps(clStr, 3);
clName = std::string(clStr);
@@ -671,8 +683,14 @@ namespace gbe {
FILE *clFile = fdopen(clFd, "w");
FATAL_IF(clFile == NULL, "Failed to open temporary file");
- clOpt.push_back("-include");
- clOpt.push_back("ocl.h");
+ if (!findPCH) {
+ clOpt.push_back("-include");
+ clOpt.push_back("ocl.h");
+ } else {
+ clOpt.push_back("-fno-validate-pch");
+ clOpt.push_back("-include-pch");
+ clOpt.push_back(pchFileName);
+ }
// Write the source to the cl file
fwrite(source, strlen(source), 1, clFile);
--
1.7.9.5
More information about the Beignet
mailing list