MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
s2z.py
Go to the documentation of this file.
1 import os
2 import sys
3 
4 def freplace(fname, from_pattern, to_pattern):
5  data = open(fname).read().replace(from_pattern, to_pattern)
6  open(fname, "w").write(data)
7 
8 def main(argv):
9  for fname in argv[1:]:
10  head, rest = os.path.split(fname)
11  zfname = os.path.join(head, "z" + rest[1:]) # assumes "z" should go in the beginning of file name
12 
13  freplace(fname, "November 2010\n*/", "November 2010\n\n@precisions normal s -> z d c\n*/")
14  os.system("python %s -p z --file %s" % (os.environ.get("PATH_TO_CODEGEN_PY", "codegen.py"), fname))
15  freplace(zfname, "@generated z", "@precisions normal z -> s d c")
16 
17  return 0
18 
19 sys.exit(main(sys.argv))