fixed ptxdump for python3

remotes/origin/master-1.1.x
Martin Beyer 15 years ago committed by Victor Julien
parent 49d66430bc
commit 736f09c4bc

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
from string import * from string import *
import os, commands, getopt, sys, platform import os, getopt, sys, platform
header = '''/* Auto-generated by ptxdump.py DO NOT EDIT header = '''/* Auto-generated by ptxdump.py DO NOT EDIT
* *
@ -16,13 +16,13 @@ def FormatCharHex(d):
return s return s
def CleanFileName(f): def CleanFileName(f):
v = replace(f,"-","_") v = f.replace("-","_")
v = replace(v,".ptx","") v = v.replace(".ptx","")
return v return v
if not(len(sys.argv[1:]) >= 2): if not(len(sys.argv[1:]) >= 2):
print "Usage: ptx2c.py <output> <in.ptx ..> " print("Usage: ptx2c.py <output> <in.ptx ..> ")
print "Description: creates a header file containing the ptx files as character array" + os.linesep print("Description: creates a header file containing the ptx files as character array" + os.linesep)
sys.exit(0) sys.exit(0)
out_h = sys.argv[1] + ".h" out_h = sys.argv[1] + ".h"
@ -56,8 +56,8 @@ for file in sys.argv[2:]:
# write retrieval function # write retrieval function
out.writelines("const unsigned char* SCCudaPtxDumpGetModule(const char* module){\n"); out.writelines("const unsigned char* SCCudaPtxDumpGetModule(const char* module){\n");
for file in sys.argv[2:]: for file in sys.argv[2:]:
out.writelines('\tif (!strcmp(module, "'+replace(file,".ptx","")+'"))\n') out.writelines('\tif (!strcmp(module, "' + file.replace(".ptx","")+'"))\n')
out.writelines("\t\treturn "+CleanFileName(file)+";\n") out.writelines("\t\treturn " + CleanFileName(file)+";\n")
out.writelines('\tSCLogError(SC_ERR_FATAL, "Error in SCCudaPtxDumpGetModule, module %s not found. Exiting...",module);\n') out.writelines('\tSCLogError(SC_ERR_FATAL, "Error in SCCudaPtxDumpGetModule, module %s not found. Exiting...",module);\n')
out.writelines("\texit(EXIT_FAILURE);\n") out.writelines("\texit(EXIT_FAILURE);\n")
out.writelines("};\n") out.writelines("};\n")

Loading…
Cancel
Save