Commit af67d2ed authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Hooked CLI options to control runtime optimization



Tested by: using qcor with those options

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 80fde681
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -100,10 +100,6 @@ using GradientEvaluator =
    std::function<void(std::vector<double> x, std::vector<double> &dx)>;

namespace __internal__ {
// !! TEMP CODE !!
// This will eventually be parsed from the CLI
#define __internal__qcor__compile__opt__level 1
#define __internal__qcor__compile__opt__print__stats
// This class gives us a way to
// run some startup routine before
// main(). Specifically we use it to ensure that
+15 −0
Original line number Diff line number Diff line
@@ -77,6 +77,21 @@ def main(argv=None):
        sys.argv.remove('-print-qir')
        sHandlerArgs += ['-Xclang', '-load', '-Xclang', '@CMAKE_INSTALL_PREFIX@/qopt-plugins/libprint_llvm_qir.so']

    # Optimization level for flattened (runtime) kernel
    # Default: 0 (no optimization)
    qrtOptLevel = 0
    if '-opt' in sys.argv[1:]:
        sidx = sys.argv.index('-opt')
        qrtOptLevel = sys.argv[sidx+1]
        sys.argv.remove(qrtOptLevel)
        sys.argv.remove('-opt')
        sys.argv += ['-D__internal__qcor__compile__opt__level='+qrtOptLevel]
    # Enable runtime kernel optimization stats print-out:
    # i.e. passes that are executed and their info (walltime, gate count reduction, etc.)
    if '-print-opt-stats' in sys.argv[1:]:
        sys.argv.remove('-print-opt-stats')
        sys.argv += ['-D__internal__qcor__compile__opt__print__stats']

    # Get the filename we are compiling or the object file
    filename = ''
    fileType = ''