[Beignet] [PATCH] GBE: fix printf class static variable bug
Pan, Xiuli
xiuli.pan at intel.com
Thu Nov 5 17:44:16 PST 2015
Ping for review.
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Pan Xiuli
Sent: Tuesday, November 3, 2015 11:30 AM
To: beignet at lists.freedesktop.org
Cc: Pan, Xiuli <xiuli.pan at intel.com>
Subject: [Beignet] [PATCH] GBE: fix printf class static variable bug
The PrintfParse::printfs static is not thread
safe and maybe reset or adding something wrong
when runing in mutlithread. Fix the problem by
change the printfs to a thread local variable.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
backend/src/llvm/llvm_printf_parser.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp
index bdaed8a..93f87ea 100644
--- a/backend/src/llvm/llvm_printf_parser.cpp
+++ b/backend/src/llvm/llvm_printf_parser.cpp
@@ -45,6 +45,8 @@ namespace gbe
{
using namespace ir;
+ thread_local map<CallInst*, PrintfSet::PrintfFmt*> printfs;
+
/* Return the conversion_specifier if succeed, -1 if failed. */
static char __parse_printf_state(char *begin, char *end, char** rend, PrintfState * state)
{
@@ -301,7 +303,6 @@ error:
Value* g1Xg2Xg3;
Value* wg_offset;
int out_buf_sizeof_offset;
- static map<CallInst*, PrintfSet::PrintfFmt*> printfs;
int printf_num;
int totalSizeofSize;
@@ -972,12 +973,10 @@ error:
return false;
}
- map<CallInst*, PrintfSet::PrintfFmt*> PrintfParser::printfs;
-
void* getPrintfInfo(CallInst* inst)
{
- if (PrintfParser::printfs[inst])
- return (void*)PrintfParser::printfs[inst];
+ if (printfs[inst])
+ return (void*)printfs[inst];
return NULL;
}
--
2.1.4
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list