#!/usr/bin/env /usr/bin/python

# Copyright (C) 2014 Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import multibench
import comp_timing
import sys, argparse, math
from numpy import array
from pycbc import scheme

parser = argparse.ArgumentParser(description = "Dummy program to keep all cores occupied"
                                 " while benchmarking complex correlations as used in pycbc")
parser.add_argument("--problem",
                    help = "String describing the problem to benchmark, in the form"
                    " [s|d]<size>.")
parser.add_argument("--method",
                    help = "Which correlation method to use",
                    choices = comp_timing.corr_valid_methods,
                    default = comp_timing.corr_valid_methods[0])

# Now call functions to parse arguments from modules
multibench.insert_timing_option_group(parser)
scheme.insert_processing_option_group(parser)

# And parse
opt, remainder = parser.parse_known_args()

# Check that the values returned for the options make sense
scheme.verify_processing_options(opt, parser)

# Do what we can with command line options
ctx = scheme.from_cli(opt)

prob_class, size, dtype = comp_timing.parse_corr_problem(opt.problem, opt.method)

with ctx:
    # Create the problem instance:
    ourprob = prob_class(size, dtype=dtype)
    # Find the planning time:
    ourprob.setup()
    while True:
        ourprob.execute()
