added basic support for nvptx target

This commit is contained in:
Evghenii
2014-01-10 08:47:59 +01:00
parent 84134678dc
commit 8190869714
2 changed files with 33 additions and 1 deletions

9
nvptxcc Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
PTXCC=ptxcc
ARGS=${@:2}
$($PTXCC $1 -o $1.o) && \
$(nvcc test_static_nvptx.cpp examples_ptx/nvcc_helpers.cu examples_ptx/ispc_malloc.cpp $1.o -arch=sm_35 -Iexamples_ptx/ -D_CUDA_ -lcudadevrt $ARGS)

View File

@@ -204,6 +204,7 @@ def run_test(testname):
return (1, 0)
else:
global is_generic_target
global is_nvptx_target
if is_windows:
if is_generic_target:
obj_name = "%s.cpp" % os.path.basename(filename)
@@ -218,6 +219,8 @@ def run_test(testname):
else:
if is_generic_target:
obj_name = "%s.cpp" % testname
elif is_nvptx_target:
obj_name = "%s.ptx" % testname
else:
obj_name = "%s.o" % testname
exe_name = "%s.run" % testname
@@ -248,6 +251,11 @@ def run_test(testname):
cc_cmd += ' -Wl,-no_pie'
if should_fail:
cc_cmd += " -DEXPECT_FAILURE"
if is_nvptx_target:
nvptxcc_exe = "nvptxcc"
nvptxcc_exe_rel = add_prefix(nvptxcc_exe)
cc_cmd = "%s %s -DTEST_SIG=%d -o %s" % \
(nvptxcc_exe_rel, obj_name, match, exe_name)
ispc_cmd = ispc_exe_rel + " --woff %s -o %s --arch=%s --target=%s" % \
(filename, obj_name, options.arch, options.target)
@@ -255,6 +263,16 @@ def run_test(testname):
ispc_cmd += " -O0"
if is_generic_target:
ispc_cmd += " --emit-c++ --c++-include-file=%s" % add_prefix(options.include_file)
if is_nvptx_target:
filename4ptx = filename+".ptx.parsed.ispc"
grep_cmd = "grep -v 'export uniform int width' %s > %s " % \
(filename, filename4ptx)
if options.verbose:
print "Grepping: %s" % grep_cmd
sp = subprocess.Popen(grep_cmd, shell=True)
sp.communicate()
ispc_cmd = ispc_exe_rel + " --woff %s -o %s --arch=%s --emit-asm --target=%s" % \
(filename4ptx, obj_name, options.arch, options.target)
# compile the ispc code, make the executable, and run it...
(compile_error, run_error) = run_cmds([ispc_cmd, cc_cmd],
@@ -290,6 +308,7 @@ def run_tasks_from_queue(queue, queue_ret, queue_skip, total_tests_arg, max_test
ispc_exe = glob_var[3]
global is_generic_target
is_generic_target = glob_var[4]
global is_nvptx_target
global run_tests_log
run_tests_log = glob_var[5]
@@ -503,6 +522,8 @@ def run_tests(options1, args, print_version):
if options.target == 'neon':
options.arch = 'arm'
if options.target == "nvptx":
options.arch = "nvptx64"
# use relative path to not depend on host directory, which may possibly
# have white spaces and unicode characters.
@@ -528,9 +549,11 @@ def run_tests(options1, args, print_version):
print_debug("Testing ispc: " + ispc_exe + "\n", s, run_tests_log)
ispc_exe += " " + options.ispc_flags
global is_generic_target
global is_generic_target
global is_nvptx_target
is_generic_target = (options.target.find("generic-") != -1 and
options.target != "generic-1" and options.target != "generic-x1")
is_nvptx_target = (options.target.find("nvptx") != -1)
if is_generic_target and options.include_file == None:
if options.target == "generic-4" or options.target == "generic-x4":
error("No generics #include specified; using examples/intrinsics/sse4.h\n", 2)