Пример #1
0
def CustomSourceModule(kernel_code):
	a = None
	try:
		a = SourceModule(kernel_code, no_extern_c = True, options = ["-use_fast_math", "-O3"])
	except:
		import sys, traceback
		print "Python Trace back"
		print "======================"
		exc_type, exc_value, exc_traceback = sys.exc_info()
		a = ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback))
		idx = a.find('kernel.cu(')
		aa = a[idx:]
		print aa

		eidx = aa.find(')')
		num = aa[10:eidx]
		line = int(num)
		print "Error code line:"
		print kernel_code.split("\n")[line-1:line][0]
		print "======================"

		exit()

	return a