added support to run test via NVVM
This commit is contained in:
@@ -199,7 +199,10 @@ namespace parser
|
|||||||
if (_alignment > 0)
|
if (_alignment > 0)
|
||||||
s << "__attribute__((aligned(" << _alignment << "))) ";
|
s << "__attribute__((aligned(" << _alignment << "))) ";
|
||||||
s << tokenToDataType(_dataTypeId, 0);
|
s << tokenToDataType(_dataTypeId, 0);
|
||||||
s << name << "[" << arrayDimensionsList[0] << "] = {0};\n\n";
|
if (arrayDimensionsList[0] == 0)
|
||||||
|
s << name << ";\n\n";
|
||||||
|
else
|
||||||
|
s << name << "[" << arrayDimensionsList[0] << "] = {0};\n\n";
|
||||||
std::cout << s.str();
|
std::cout << s.str();
|
||||||
arrayDimensionsList.clear();
|
arrayDimensionsList.clear();
|
||||||
}
|
}
|
||||||
@@ -225,16 +228,16 @@ namespace parser
|
|||||||
case TOKEN_U16: assert(0); s << "u16_t "; break;
|
case TOKEN_U16: assert(0); s << "u16_t "; break;
|
||||||
case TOKEN_S16: assert(0); s << "s16_t "; break;
|
case TOKEN_S16: assert(0); s << "s16_t "; break;
|
||||||
|
|
||||||
case TOKEN_B32: assert(dim == 1); s << "b32_t "; break;
|
case TOKEN_B32: assert(dim <= 1); s << "b32_t "; break;
|
||||||
case TOKEN_U32: assert(dim == 1); s << "u32_t "; break;
|
case TOKEN_U32: assert(dim <= 1); s << "u32_t "; break;
|
||||||
case TOKEN_S32: assert(dim == 1); s << "s32_t "; break;
|
case TOKEN_S32: assert(dim <= 1); s << "s32_t "; break;
|
||||||
|
|
||||||
case TOKEN_B64: assert(dim == 1); s << "b64_t "; break;
|
case TOKEN_B64: assert(dim <= 1); s << "b64_t "; break;
|
||||||
case TOKEN_U64: assert(dim == 1); s << "u64_t "; break;
|
case TOKEN_U64: assert(dim <= 1); s << "u64_t "; break;
|
||||||
case TOKEN_S64: assert(dim == 1); s << "s64_t "; break;
|
case TOKEN_S64: assert(dim <= 1); s << "s64_t "; break;
|
||||||
|
|
||||||
case TOKEN_F32: assert(dim == 1); s << "f32_t "; break;
|
case TOKEN_F32: assert(dim <= 1); s << "f32_t "; break;
|
||||||
case TOKEN_F64: assert(dim == 1); s << "f64_t "; break;
|
case TOKEN_F64: assert(dim <= 1); s << "f64_t "; break;
|
||||||
default: std::cerr << "token= " << token<< std::endl; assert(0);
|
default: std::cerr << "token= " << token<< std::endl; assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ TAB [\t]*
|
|||||||
"(" { return '(';}
|
"(" { return '(';}
|
||||||
")" { return ')';}
|
")" { return ')';}
|
||||||
"," { return ',';}
|
"," { return ',';}
|
||||||
|
";" { return ';';}
|
||||||
|
"=" { return '=';}
|
||||||
[0-9]+\.[0-9]+ { yylval->fvalue = atof(yytext); return TOKEN_FLOAT; }
|
[0-9]+\.[0-9]+ { yylval->fvalue = atof(yytext); return TOKEN_FLOAT; }
|
||||||
[0-9]+ { yylval->ivalue = atoi(yytext); return TOKEN_INT; }
|
[0-9]+ { yylval->ivalue = atoi(yytext); return TOKEN_INT; }
|
||||||
[a-zA-Z0-9_]+ { strcpy(yylval->svalue, yytext); return TOKEN_STRING;}
|
[a-zA-Z0-9_]+ { strcpy(yylval->svalue, yytext); return TOKEN_STRING;}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ DEPTX=dePTX
|
|||||||
NVCC=nvcc
|
NVCC=nvcc
|
||||||
|
|
||||||
$DEPTX < $PTXSRC > $PTXCU &&
|
$DEPTX < $PTXSRC > $PTXCU &&
|
||||||
$NVCC -arch=sm_35 -dc $NVCCPARM -dryrun $PTXCU 2>&1 | \
|
$NVCC -arch=sm_35 -G -dc $NVCCPARM -dryrun $PTXCU 2>&1 | \
|
||||||
sed 's/\#\$//g'| \
|
sed 's/\#\$//g'| \
|
||||||
awk '{ if ($1 == "LIBRARIES=") print $1$2; else if ($1 == "cicc") print "cp '$PTXSRC'", $NF; else print $0 }' > $PTXSH &&
|
awk '{ if ($1 == "LIBRARIES=") print $1$2; else if ($1 == "cicc") print "cp '$PTXSRC'", $NF; else print $0 }' > $PTXSH &&
|
||||||
sh $PTXSH
|
sh $PTXSH
|
||||||
|
|||||||
@@ -105,7 +105,10 @@ anytoken:
|
|||||||
| ']'
|
| ']'
|
||||||
| '('
|
| '('
|
||||||
| ')'
|
| ')'
|
||||||
| ',';
|
| ','
|
||||||
|
| ';'
|
||||||
|
| '='
|
||||||
|
;
|
||||||
|
|
||||||
ptxbody:
|
ptxbody:
|
||||||
ptxbody visibleFunctionDeclaration | visibleFunctionDeclaration
|
ptxbody visibleFunctionDeclaration | visibleFunctionDeclaration
|
||||||
@@ -157,9 +160,11 @@ visibleFunctionDeclaration: TOKEN_VISIBLE TOKEN_FUNC optionalReturnArgumentList
|
|||||||
|
|
||||||
visibleInitializableDeclaration :
|
visibleInitializableDeclaration :
|
||||||
TOKEN_VISIBLE TOKEN_GLOBAL addressableVariablePrefix identifier arrayDimensionSet
|
TOKEN_VISIBLE TOKEN_GLOBAL addressableVariablePrefix identifier arrayDimensionSet
|
||||||
{
|
{ state.visibleInitializableDeclaration($<svalue>4,@1); }
|
||||||
state.visibleInitializableDeclaration($<svalue>4,@1);
|
| TOKEN_VISIBLE TOKEN_GLOBAL addressableVariablePrefix identifier ';'
|
||||||
}
|
{state.arrayDimensions(0); state.visibleInitializableDeclaration($<svalue>4,@1); }
|
||||||
|
| TOKEN_VISIBLE TOKEN_GLOBAL addressableVariablePrefix identifier '='
|
||||||
|
{state.arrayDimensions(0); state.visibleInitializableDeclaration($<svalue>4,@1); }
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|||||||
45
module.cpp
45
module.cpp
@@ -2588,6 +2588,29 @@ lCreateDispatchModule(std::map<std::string, FunctionTargetVariants> &functions)
|
|||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string lCBEMangle(const std::string &S) {
|
||||||
|
std::string Result;
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = S.size(); i != e; ++i) {
|
||||||
|
if (i+1 != e && ((S[i] == '>' && S[i+1] == '>') ||
|
||||||
|
(S[i] == '<' && S[i+1] == '<'))) {
|
||||||
|
Result += '_';
|
||||||
|
Result += 'A'+(S[i]&15);
|
||||||
|
Result += 'A'+((S[i]>>4)&15);
|
||||||
|
Result += '_';
|
||||||
|
i++;
|
||||||
|
} else if (isalnum(S[i]) || S[i] == '_' || S[i] == '<' || S[i] == '>') {
|
||||||
|
Result += S[i];
|
||||||
|
} else {
|
||||||
|
Result += '_';
|
||||||
|
Result += 'A'+(S[i]&15);
|
||||||
|
Result += 'A'+((S[i]>>4)&15);
|
||||||
|
Result += '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Module::CompileAndOutput(const char *srcFile,
|
Module::CompileAndOutput(const char *srcFile,
|
||||||
@@ -2618,17 +2641,21 @@ Module::CompileAndOutput(const char *srcFile,
|
|||||||
*/
|
*/
|
||||||
if (g->target->getISA() == Target::NVPTX)
|
if (g->target->getISA() == Target::NVPTX)
|
||||||
{
|
{
|
||||||
llvm::Module::global_iterator
|
/* mangle global variables names */
|
||||||
I = m->module->global_begin(),
|
|
||||||
E = m->module->global_end();
|
|
||||||
for (; I != E; I++)
|
|
||||||
{
|
{
|
||||||
std::string name = I->getName();
|
llvm::Module::global_iterator I = m->module->global_begin(), E = m->module->global_end();
|
||||||
for (int i = 0; i < name.length(); i++)
|
for (; I != E; I++)
|
||||||
if (name[i] == '.')
|
I->setName(lCBEMangle(I->getName()));
|
||||||
name[i] = '_';
|
|
||||||
I->setName(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* mangles primitves as well grrr */
|
||||||
|
/* mangle functions names */
|
||||||
|
{
|
||||||
|
llvm::Module::iterator I = m->module->begin(), E = m->module->end();
|
||||||
|
for (; I != E; I++)
|
||||||
|
I->setName(lCBEMangle(I->getName()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputType == CXX) {
|
if (outputType == CXX) {
|
||||||
|
|||||||
14
run_tests.py
14
run_tests.py
@@ -205,6 +205,7 @@ def run_test(testname):
|
|||||||
else:
|
else:
|
||||||
global is_generic_target
|
global is_generic_target
|
||||||
global is_nvptx_target
|
global is_nvptx_target
|
||||||
|
global is_nvptx_nvvm
|
||||||
if is_windows:
|
if is_windows:
|
||||||
if is_generic_target:
|
if is_generic_target:
|
||||||
obj_name = "%s.cpp" % os.path.basename(filename)
|
obj_name = "%s.cpp" % os.path.basename(filename)
|
||||||
@@ -220,7 +221,12 @@ def run_test(testname):
|
|||||||
if is_generic_target:
|
if is_generic_target:
|
||||||
obj_name = "%s.cpp" % testname
|
obj_name = "%s.cpp" % testname
|
||||||
elif is_nvptx_target:
|
elif is_nvptx_target:
|
||||||
|
if os.environ.get("NVVM") == "1":
|
||||||
|
is_nvptx_nvvm = True
|
||||||
|
obj_name = "%s.bc" % testname
|
||||||
|
else:
|
||||||
obj_name = "%s.ptx" % testname
|
obj_name = "%s.ptx" % testname
|
||||||
|
is_nvptx_nvvm = False
|
||||||
else:
|
else:
|
||||||
obj_name = "%s.o" % testname
|
obj_name = "%s.o" % testname
|
||||||
exe_name = "%s.run" % testname
|
exe_name = "%s.run" % testname
|
||||||
@@ -271,8 +277,12 @@ def run_test(testname):
|
|||||||
print "Grepping: %s" % grep_cmd
|
print "Grepping: %s" % grep_cmd
|
||||||
sp = subprocess.Popen(grep_cmd, shell=True)
|
sp = subprocess.Popen(grep_cmd, shell=True)
|
||||||
sp.communicate()
|
sp.communicate()
|
||||||
ispc_cmd = ispc_exe_rel + " --woff %s -o %s -O3 --emit-asm --target=%s" % \
|
if is_nvptx_nvvm:
|
||||||
(filename4ptx, obj_name, options.target)
|
ispc_cmd = ispc_exe_rel + " --woff %s -o %s -O3 --emit-llvm --target=%s" % \
|
||||||
|
(filename4ptx, obj_name, options.target)
|
||||||
|
else:
|
||||||
|
ispc_cmd = ispc_exe_rel + " --woff %s -o %s -O3 --emit-asm --target=%s" % \
|
||||||
|
(filename4ptx, obj_name, options.target)
|
||||||
|
|
||||||
# compile the ispc code, make the executable, and run it...
|
# compile the ispc code, make the executable, and run it...
|
||||||
(compile_error, run_error) = run_cmds([ispc_cmd, cc_cmd],
|
(compile_error, run_error) = run_cmds([ispc_cmd, cc_cmd],
|
||||||
|
|||||||
Reference in New Issue
Block a user