コード例 #1
0
# Run Autotuning

#search_param_dict = {}
#search_param_dict['method'] = 'MLA'
#
#search = Search(problem, search_param_dict)
#
#search.run()

if __name__ == '__main__':
    computer = Computer(nodes=1, cores=2, hosts=None)
    options = Options()
    # options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = True
    # options['mpi_comm'] = None
    #options['mpi_comm'] = mpi4py.MPI.COMM_WORLD
    options['model_class '] = 'Model_LCM'

    options.validate(computer=computer)
    data = Data(problem)
    gt = GPTune(problem, computer=computer, data=data, options=options)
    # print('demo before MLA')
    (data, modeler, stats) = gt.MLA(NS=20, NI=1, NS1=10)
    print("stats: ", stats)
    print(data.Y)
    print([(y[-1], min(y)[0], max(y)[0]) for y in data.Y])
コード例 #2
0
def main():

    global ROOTDIR
    global nodes
    global cores
    global JOBID
    global nprocmax
    global nprocmin

    # Parse command line arguments
    args = parse_args()

    mmax = args.mmax
    nmax = args.nmax
    ntask = args.ntask
    nodes = args.nodes
    cores = args.cores
    nprocmin_pernode = args.nprocmin_pernode
    machine = args.machine
    nruns = args.nruns
    truns = args.truns
    JOBID = args.jobid
    TUNER_NAME = args.optimization

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME
    os.system(
        "mkdir -p scalapack-driver/bin/%s; cp ../build/pdqrdriver scalapack-driver/bin/%s/.;"
        % (machine, machine))

    nprocmax = nodes * cores - 1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(
        nodes * nprocmin_pernode, nprocmax - 1
    )  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

    mmin = 128
    nmin = 128

    m = Integer(mmin, mmax, transform="normalize", name="m")
    n = Integer(nmin, nmax, transform="normalize", name="n")
    b = Integer(4, 16, transform="normalize", name="b")
    nproc = Integer(nprocmin, nprocmax, transform="normalize", name="nproc")
    p = Integer(0, nprocmax, transform="normalize", name="p")
    r = Real(float("-Inf"), float("Inf"), name="r")

    IS = Space([m, n])
    PS = Space([b, nproc, p])
    OS = Space([r])
    cst1 = "b*8 * p <= m"
    cst2 = "b*8 * nproc <= n * p"
    cst3 = "nproc >= p"
    constraints = {"cst1": cst1, "cst2": cst2, "cst3": cst3}
    print(IS, PS, OS, constraints)

    problem = TuningProblem(IS, PS, OS, objectives, constraints,
                            models)  # use performance models
    # problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
    computer = Computer(nodes=nodes, cores=cores, hosts=None)
    """ Set and validate options """
    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    # options['model_restart_threads'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    # options['mpi_comm'] = None
    options['model_class '] = 'Model_LCM'
    options['verbose'] = False
    options.validate(computer=computer)
    """ Intialize the tuner with existing data stored as last check point"""
    try:
        data = pickle.load(
            open(
                'Data_nodes_%d_cores_%d_mmax_%d_nmax_%d_machine_%s_jobid_%d.pkl'
                % (nodes, cores, mmax, nmax, machine, JOBID), 'rb'))
        giventask = data.I
    except (OSError, IOError) as e:
        data = Data(problem)
        giventask = [[randint(mmin, mmax),
                      randint(nmin, nmax)] for i in range(ntask)]

    # giventask = [[5000, 5000]]
    # # giventask = [[177, 1303],[367, 381],[1990, 1850],[1123, 1046],[200, 143],[788, 1133],[286, 1673],[1430, 512],[1419, 1320],[622, 263] ]

    # # the following will use only task lists stored in the pickle file
    # data = Data(problem)

    if (TUNER_NAME == 'GPTune'):

        gt = GPTune(problem,
                    computer=computer,
                    data=data,
                    options=options,
                    driverabspath=os.path.abspath(__file__))
        """ Building MLA with NI random tasks """
        NI = ntask
        NS = nruns
        (data, model, stats) = gt.MLA(NS=NS,
                                      Igiven=giventask,
                                      NI=NI,
                                      NS1=max(NS // 2, 1))
        print("stats: ", stats)

        # """ Dump the data to file as a new check point """
        # pickle.dump(data, open('Data_nodes_%d_cores_%d_mmax_%d_nmax_%d_machine_%s_jobid_%d.pkl' % (nodes, cores, mmax, nmax, machine, JOBID), 'wb'))

        # """ Dump the tuner to file for TLA use """
        # pickle.dump(gt, open('MLA_nodes_%d_cores_%d_mmax_%d_nmax_%d_machine_%s_jobid_%d.pkl' % (nodes, cores, mmax, nmax, machine, JOBID), 'wb'))
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'opentuner'):
        NI = ntask
        NS = nruns
        (data, stats) = OpenTuner(T=giventask,
                                  NS=NS,
                                  tp=problem,
                                  computer=computer,
                                  run_id="OpenTuner",
                                  niter=1,
                                  technique=None)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'hpbandster'):
        NI = ntask
        NS = nruns
        (data, stats) = HpBandSter(T=giventask,
                                   NS=NS,
                                   tp=problem,
                                   computer=computer,
                                   run_id="HpBandSter",
                                   niter=1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #3
0
def main(): 
    global nodes
    global cores
    global JOBID
    global nprocmax
    global nprocmin

    # Parse command line arguments
    args = parse_args()

    nxmax = args.nxmax
    nymax = args.nymax
    nzmax = args.nzmax
    nodes = args.nodes
    cores = args.cores
    nprocmin_pernode = args.nprocmin_pernode
    machine = args.machine
    ntask = args.ntask
    nruns = args.nruns
    JOBID = args.jobid
    TUNER_NAME = args.optimization
    TLA = False

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME
    # os.system("mkdir -p scalapack-driver/bin/%s; cp ../build/pdqrdriver scalapack-driver/bin/%s/.;" %(machine, machine))

    nprocmax = nodes*cores-1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(nodes*nprocmin_pernode,nprocmax-1)  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space 

    
    nxmin = 20
    nymin = 20
    nzmin = 20
    nx = Integer(nxmin, nxmax, transform="normalize", name="nx")
    ny = Integer(nymin, nymax, transform="normalize", name="ny")
    nz = Integer(nzmin, nzmax, transform="normalize", name="nz")
    Px = Integer(1, nprocmax, transform="normalize", name="Px")
    Py = Integer(1, nprocmax, transform="normalize", name="Py")
    Nproc = Integer(nprocmin, nprocmax, transform="normalize", name="Nproc")
    strong_threshold = Real(0, 1, transform="normalize", name="strong_threshold")
    trunc_factor =  Real(0, 1, transform="normalize", name="trunc_factor")
    P_max_elmts = Integer(1, 12,  transform="normalize", name="P_max_elmts")
    coarsen_type = Categoricalnorm (['0', '1', '2', '3', '4', '6', '8', '10'], transform="onehot", name="coarsen_type")
    relax_type = Categoricalnorm (['-1', '0', '6', '8', '16', '18'], transform="onehot", name="relax_type")
    smooth_type = Categoricalnorm (['5', '6', '7', '8', '9'], transform="onehot", name="smooth_type")
    smooth_num_levels = Integer(0, 5,  transform="normalize", name="smooth_num_levels")
    interp_type = Categoricalnorm (['0', '3', '4', '5', '6', '8', '12'], transform="onehot", name="interp_type")
    agg_num_levels = Integer(0, 5,  transform="normalize", name="agg_num_levels")
    r = Real(float("-Inf"), float("Inf"), name="r")
    
    IS = Space([nx, ny, nz])
    PS = Space([Px, Py, Nproc, strong_threshold, trunc_factor, P_max_elmts, coarsen_type, relax_type, smooth_type, smooth_num_levels, interp_type, agg_num_levels])
    OS = Space([r])
    
    # Question: how to set constraints
    cst1 = f"Px * Py  <= Nproc"
    cst2 = f"not(coarsen_type=='0' and P_max_elmts==10 and relax_type=='18' and smooth_type=='6' and smooth_num_levels==3 and interp_type=='8' and agg_num_levels==1)"
    constraints = {"cst1": cst1,"cst2": cst2}

    print(IS, PS, OS, constraints)

    problem = TuningProblem(IS, PS, OS, objectives, constraints, None) # no performance model
    computer = Computer(nodes=nodes, cores=cores, hosts=None)

    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    # options['mpi_comm'] = None
    options['model_class '] = 'Model_LCM'
    options['verbose'] = False
    options.validate(computer=computer)
    
    
    """ Intialize the tuner with existing data stored as last check point"""
    try:
        data = pickle.load(open('Data_nodes_%d_cores_%d_nxmax_%d_nymax_%d_nzmax_%d_machine_%s_jobid_%d.pkl' % (nodes, cores, nxmax, nymax, nzmax, machine, JOBID), 'rb'))
        giventask = data.I
    except (OSError, IOError) as e:
        data = Data(problem)
        giventask = [[randint(nxmin,nxmax),randint(nymin,nymax),randint(nzmin,nzmax)] for i in range(ntask)]

    # giventask = [[50, 60, 80], [60, 80, 100]]
    # # the following will use only task lists stored in the pickle file
    # data = Data(problem)


    if(TUNER_NAME=='GPTune'):
        gt = GPTune(problem, computer=computer, data=data, options=options, driverabspath=os.path.abspath(__file__))        
        """ Building MLA with the given list of tasks """
        NI = len(giventask)
        NS = nruns
        (data, model, stats) = gt.MLA(NS=NS, NI=NI, Igiven=giventask, NS1=max(NS//2, 1))
        print("stats: ", stats)
        
        """ Dump the data to file as a new check point """
        pickle.dump(data, open('Data_nodes_%d_cores_%d_nxmax_%d_nymax_%d_nzmax_%d_machine_%s_jobid_%d.pkl' % (nodes, cores, nxmax, nymax, nzmax, machine, JOBID), 'wb'))
        
        """ Dump the tuner to file for TLA use """
        pickle.dump(gt, open('MLA_nodes_%d_cores_%d_nxmax_%d_nymax_%d_nzmax_%d_machine_%s_jobid_%d.pkl' % (nodes, cores, nxmax, nymax, nzmax, machine, JOBID), 'wb'))


        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    nx:%d ny:%d nz:%d" % (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

        if TLA is True:
            """ Call TLA for 2 new tasks using the constructed LCM model"""
            newtask = [[50, 50, 60], [80, 60, 70]]
            (aprxopts, objval, stats) = gt.TLA1(newtask, NS=None)
            print("stats: ", stats)

            """ Print the optimal parameters and function evaluations"""
            for tid in range(len(newtask)):
                print("new task: %s" % (newtask[tid]))
                print('    predicted Popt: ', aprxopts[tid], ' objval: ', objval[tid])

    
    if(TUNER_NAME=='opentuner'):
        NI = ntask
        NS = nruns
        (data,stats) = OpenTuner(T=giventask, NS=NS, tp=problem, computer=computer, run_id="OpenTuner", niter=1, technique=None)
        print("stats: ", stats)

        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    nx:%d ny:%d nz:%d" % (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if(TUNER_NAME=='hpbandster'):
        NI = ntask
        NS = nruns
        (data,stats)=HpBandSter(T=giventask, NS=NS, tp=problem, computer=computer, run_id="HpBandSter", niter=1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    nx:%d ny:%d nz:%d" % (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #4
0
ファイル: hypre_MB_Rtrue.py プロジェクト: xinranzhu/GPTune-1
def main():
    global nodes
    global cores
    global JOBID
    global nprocmax
    global nprocmin

    # Parse command line arguments
    args = parse_args()

    amin = args.amin
    amax = args.amax
    cmin = args.cmin
    cmax = args.cmax
    nodes = args.nodes
    cores = args.cores
    nprocmin_pernode = args.nprocmin_pernode
    machine = args.machine
    ntask = args.ntask
    Nloop = args.Nloop
    JOBID = args.jobid
    restart = args.restart
    TUNER_NAME = args.optimization
    TLA = False

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME
    # os.system("mkdir -p scalapack-driver/bin/%s; cp ../build/pdqrdriver scalapack-driver/bin/%s/.;" %(machine, machine))

    nprocmax = nodes * cores - 1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(
        nodes * nprocmin_pernode, nprocmax - 1
    )  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

    a_val = Real(amin, amax, transform="normalize", name="a_val")
    c_val = Real(cmin, cmax, transform="normalize", name="c_val")
    Px = Integer(1, nprocmax, transform="normalize", name="Px")
    Py = Integer(1, nprocmax, transform="normalize", name="Py")
    Nproc = Integer(nprocmin, nprocmax, transform="normalize", name="Nproc")
    strong_threshold = Real(0,
                            1,
                            transform="normalize",
                            name="strong_threshold")
    trunc_factor = Real(0, 0.999, transform="normalize", name="trunc_factor")
    P_max_elmts = Integer(1, 12, transform="normalize", name="P_max_elmts")
    # coarsen_type = Categoricalnorm (['0', '1', '2', '3', '4', '6', '8', '10'], transform="onehot", name="coarsen_type")
    coarsen_type = Categoricalnorm(['0', '1', '2', '3', '4', '8', '10'],
                                   transform="onehot",
                                   name="coarsen_type")
    relax_type = Categoricalnorm(['-1', '0', '6', '8', '16', '18'],
                                 transform="onehot",
                                 name="relax_type")
    smooth_type = Categoricalnorm(['5', '6', '8', '9'],
                                  transform="onehot",
                                  name="smooth_type")
    smooth_num_levels = Integer(0,
                                5,
                                transform="normalize",
                                name="smooth_num_levels")
    interp_type = Categoricalnorm(['0', '3', '4', '5', '6', '8', '12'],
                                  transform="onehot",
                                  name="interp_type")
    agg_num_levels = Integer(0,
                             5,
                             transform="normalize",
                             name="agg_num_levels")
    r = Real(float("-Inf"), float("Inf"), name="r")

    IS = Space([a_val, c_val])
    PS = Space([
        Px, Py, Nproc, strong_threshold, trunc_factor, P_max_elmts,
        coarsen_type, relax_type, smooth_type, smooth_num_levels, interp_type,
        agg_num_levels
    ])
    OS = Space([r])

    cst1 = f"Px * Py  <= Nproc"
    cst2 = f"not(P_max_elmts==10 and coarsen_type=='6' and relax_type=='18' and smooth_type=='6' and smooth_num_levels==3 and interp_type=='8' and agg_num_levels==1)"
    constraints = {"cst1": cst1, "cst2": cst2}

    print(IS, PS, OS, constraints)

    problem = TuningProblem(IS, PS, OS, objectives, constraints,
                            None)  # no performance model
    computer = Computer(nodes=nodes, cores=cores, hosts=None)

    options = Options()
    options['model_processes'] = 4  # parallel cholesky for each LCM kernel
    # options['model_threads'] = 1

    # options['model_restarts'] = args.Nrestarts
    # options['distributed_memory_parallelism'] = False

    # parallel model restart
    options['model_restarts'] = restart
    options['distributed_memory_parallelism'] = False

    options['shared_memory_parallelism'] = False
    # options['mpi_comm'] = None
    options['model_class'] = 'Model_LCM'  # Model_GPy_LCM or Model_LCM
    options['verbose'] = False

    # choose sampler
    # options['sample_class'] = 'SampleOpenTURNS'
    # if args.lhs == 1:
    options['sample_class'] = 'SampleLHSMDU'
    options['sample_algo'] = 'LHS-MDU'
    options.validate(computer=computer)

    options['budget_min'] = bmin
    options['budget_max'] = bmax
    options['budget_base'] = eta
    budgets = [
        options['budget_max'] / options['budget_base']**x
        for x in range(smax + 1)
    ]
    NSs = [
        int((smax + 1) / (s + 1)) * options['budget_base']**s
        for s in range(smax + 1)
    ]
    NSs_all = NSs.copy()
    budget_all = budgets.copy()
    for s in range(smax + 1):
        for n in range(s):
            NSs_all.append(int(NSs[s] / options['budget_base']**(n + 1)))
            budget_all.append(int(budgets[s] *
                                  options['budget_base']**(n + 1)))
    Ntotal = int(sum(NSs_all) * Nloop)
    Btotal = int(
        np.dot(np.array(NSs_all), np.array(budget_all)) /
        options['budget_max'] * Nloop
    )  # total number of evaluations at highest budget -- used for single-fidelity tuners
    print(f"bmin = {bmin}, bmax = {bmax}, eta = {eta}, smax = {smax}")
    print("samples in one multi-armed bandit loop, NSs_all = ", NSs_all)
    print("total number of samples: ", Ntotal)
    print("total number of evaluations at highest budget: ", Btotal)
    print()

    data = Data(problem)
    # giventask = [[(amax-amin)*random.random()+amin,(cmax-cmin)*random.random()+cmin] for i in range(ntask)]
    # giventask = [[0.2, 0.5]]

    # a, c in [0, 2], 20 tasks
    # giventask = [[1.764404747086545, 0.1690780613092806], [0.04112427493772097, 0.8085715496434904],
    #              [0.22710987838880214, 1.88151014852883], [1.4295598579456825, 0.6777959247566412],
    #              [1.2113920952170643, 1.2736211372774706], [1.9506691433602787, 1.6164125044517066],
    #              [1.0599323074104676, 0.31237589097846064], [0.5539778042983943, 1.7201524881603167],
    #              [1.1202117146999948, 1.4008498376477942], [1.9764454822916864, 0.49519243217069175],
    #              [1.6242107544285, 1.546469305586815], [0.48556463965870966, 0.9104470584141897],
    #              [0.24335919069425582, 1.9474734644218745], [1.4548622289600037, 0.44034181519644044],
    #              [0.30572684587777066, 1.744356822716747], [1.3121087439465606, 1.8289812234496303],
    #              [0.4368157748180814, 1.7463601854749693], [1.179881068844456, 0.31389817437239453],
    #              [0.6840593333787133, 1.2532549528173518], [0.808378518110451, 0.7833341762792181]]
    # a, c in [0, 1], 10 tasks
    # giventask = [[0.023181354151175504, 0.6816796355829654], [0.15948672790394447, 0.545007082153842],
    #              [0.3061777407959666, 0.2613262568641622], [0.13635922601717265, 0.42633245310802903],
    #              [0.007106878341192613, 0.1275649768730277], [0.14739645464726914, 0.7387029572331887],
    #              [0.03343150589405264, 0.5281563810546017], [0.09379810626184892, 0.4018339729841335],
    #              [0.698222888451084, 0.30201670579496664], [0.6026109961485946, 0.07835020207209975]]
    if ntask == 10:
        giventask = [[0.2, 0.5], [0.159, 0.545], [0.02, 0.682], [0.9, 0.02],
                     [0.7, 0.3], [0.147, 0.739], [0.033, 0.528],
                     [0.094, 0.402], [0.698, 0.302], [0.603, 0.0784]]
    if ntask == 3:
        # group 1
        giventask = [[0.2, 0.5], [0.159, 0.545], [0.02, 0.682]]
        # group 2
        # giventask = [[0.9, 0.02],
        #             [0.7, 0.3], [0.147, 0.739]]
        # grioup
        # giventask = [[0.147, 0.739],
        #             [0.033, 0.528], [0.094, 0.402]]

    if ntask == 2:
        # giventask = [[0.9, 0.02],
        #             [0.7, 0.3]]
        giventask = [[0.698, 0.302], [0.603, 0.0784]]
    if ntask == 4:
        giventask = [[0.033, 0.528], [0.094, 0.402], [0.698, 0.302],
                     [0.603, 0.0784]]
    if ntask == 5:
        giventask = [[0.2, 0.5], [0.02, 0.682], [0.9, 0.02], [0.7, 0.3],
                     [0.147, 0.739]]

    if ntask == 6:
        giventask = [[0.2, 0.5], [0.159, 0.545], [0.02, 0.682], [0.9, 0.02],
                     [0.7, 0.3], [0.147, 0.739]]

    if ntask == 1:
        giventask = [[args.a, args.c]]

    NI = len(giventask)
    assert NI == ntask  # make sure number of tasks match

    # # the following will use only task lists stored in the pickle file
    # data = Data(problem)

    if (TUNER_NAME == 'GPTune'):
        gt = GPTune(problem,
                    computer=computer,
                    data=data,
                    options=options,
                    driverabspath=os.path.abspath(__file__))
        """ Building MLA with the given list of tasks """
        if args.nrun > 0:
            NS = args.nrun
        # NS1 = max(NS//2, 1)
        NS1 = NS

        def merge_dict(mydict, newdict):
            for key in mydict.keys():
                mydict[key] += newdict[key]

        data_all = []
        stats_all = {}
        for singletask in giventask:
            NI = 1
            cur_task = [singletask]
            data = Data(problem)
            gt = GPTune(problem,
                        computer=computer,
                        data=data,
                        options=options,
                        driverabspath=os.path.abspath(__file__))
            (data, model, stats) = gt.MLA(NS=NS,
                                          NI=NI,
                                          Igiven=cur_task,
                                          NS1=NS1)
            data_all.append(data)
            merge_dict(stats_all, stats)
            print("Finish one single task tuning")
            print("Tuner: ", TUNER_NAME)
            print("stats: ", stats)
            tid = 0
            print(
                f"   [a_val, c_val] = [{data.I[tid][0]:.3f}, {data.I[tid][1]:.3f}]"
            )
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #5
0
def main():

    global ROOTDIR
    global nodes
    global cores
    global JOBID
    global nprocmax
    global nprocmin

    # Parse command line arguments
    args = parse_args()

    mmax = args.mmax
    nmax = args.nmax
    ntask = args.ntask
    nodes = args.nodes
    cores = args.cores
    nprocmin_pernode = args.nprocmin_pernode
    machine = args.machine
    nruns = args.nruns
    truns = args.truns
    JOBID = args.jobid
    TUNER_NAME = args.optimization

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME
    os.system(
        "mkdir -p scalapack-driver/bin/%s; cp ../build/pdqrdriver scalapack-driver/bin/%s/.;"
        % (machine, machine))

    nprocmax = nodes * cores - 1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(
        nodes * nprocmin_pernode, nprocmax - 1
    )  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

    mmin = 128
    nmin = 128
    m = Integer(mmin, mmax, transform="normalize", name="m")
    n = Integer(nmin, nmax, transform="normalize", name="n")
    mb = Integer(1, 128, transform="normalize", name="mb")
    nb = Integer(1, 128, transform="normalize", name="nb")
    nproc = Integer(nprocmin, nprocmax, transform="normalize", name="nproc")
    p = Integer(0, nprocmax, transform="normalize", name="p")
    r = Real(float("-Inf"), float("Inf"), name="r")

    IS = Space([m, n])
    PS = Space([mb, nb, nproc, p])
    OS = Space([r])
    cst1 = "mb * p <= m"
    cst2 = "nb * nproc <= n * p"
    cst3 = "nproc >= p"
    constraints = {"cst1": cst1, "cst2": cst2, "cst3": cst3}
    print(IS, PS, OS, constraints)

    # problem = TuningProblem(IS, PS, OS, objectives, constraints, models) # use performance models
    problem = TuningProblem(IS, PS, OS, objectives, constraints,
                            None)  # no performance model

    computer = Computer(nodes=nodes, cores=cores, hosts=None)
    """ Set and validate options """
    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    # options['model_restart_threads'] = 1

    # options['objective_evaluation_parallelism'] = True

    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    # options['mpi_comm'] = None
    options['model_class'] = 'Model_GPy_LCM'
    options['verbose'] = False

    options.validate(computer=computer)
    # giventask = [[2000, 2000]]
    # giventask = [[randint(mmin,mmax),randint(nmin,nmax)] for i in range(ntask)]
    giventask = [[460, 500], [800, 690]]

    data = Data(problem)
    gt = GPTune(problem,
                computer=computer,
                data=data,
                options=options,
                driverabspath=os.path.abspath(__file__))

    if (TUNER_NAME == 'GPTune'):
        """ Building MLA with the given list of tasks """
        NI = len(giventask)
        NS = nruns
        (data, model, stats) = gt.MLA(NS=NS,
                                      NI=NI,
                                      Igiven=giventask,
                                      NS1=max(NS // 2, 1))
        print("stats: ", stats)
        pickle.dump(
            gt,
            open(
                'MLA_nodes_%d_cores_%d_mmax_%d_nmax_%d_machine_%s_jobid_%d.pkl'
                % (nodes, cores, mmax, nmax, machine, JOBID), 'wb'))
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Yopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
        """ Call TLA for 2 new tasks using the constructed LCM model"""
        newtask = [[400, 500], [800, 600]]
        (aprxopts, objval, stats) = gt.TLA1(newtask, NS=None)
        print("stats: ", stats)
        """ Print the optimal parameters and function evaluations"""
        for tid in range(len(newtask)):
            print("new task: %s" % (newtask[tid]))
            print('    predicted Popt: ', aprxopts[tid], ' objval: ',
                  objval[tid])

    if (TUNER_NAME == 'opentuner'):
        NI = ntask
        NS = nruns
        (data, stats) = OpenTuner(T=giventask,
                                  NS=NS,
                                  tp=problem,
                                  computer=computer,
                                  run_id="OpenTuner",
                                  niter=1,
                                  technique=None)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'hpbandster'):
        NI = ntask
        NS = nruns
        (data, stats) = HpBandSter(T=giventask,
                                   NS=NS,
                                   tp=problem,
                                   computer=computer,
                                   run_id="HpBandSter",
                                   niter=1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #6
0
ファイル: superlu.py プロジェクト: liuyangzhuan/GPTune
def main_interactive():

    global ROOTDIR
    global nodes
    global cores
    global target

    # Parse command line arguments

    parser = argparse.ArgumentParser()

    # Problem related arguments
    # parser.add_argument('-mmax', type=int, default=-1, help='Number of rows')
    # parser.add_argument('-nmax', type=int, default=-1, help='Number of columns')
    # Machine related arguments
    parser.add_argument('-nodes',
                        type=int,
                        default=1,
                        help='Number of machine nodes')
    parser.add_argument('-cores',
                        type=int,
                        default=1,
                        help='Number of cores per machine node')
    parser.add_argument('-machine',
                        type=str,
                        help='Name of the computer (not hostname)')
    # Algorithm related arguments
    parser.add_argument(
        '-optimization',
        type=str,
        help='Optimization algorithm (opentuner, spearmint, mogpo)')
    parser.add_argument('-ntask', type=int, default=-1, help='Number of tasks')
    parser.add_argument('-nruns', type=int, help='Number of runs per task')
    parser.add_argument('-truns', type=int, help='Time of runs')
    # Experiment related arguments
    parser.add_argument(
        '-jobid', type=int, default=-1,
        help='ID of the batch job')  #0 means interactive execution (not batch)

    args = parser.parse_args()

    # Extract arguments

    # mmax = args.mmax
    # nmax = args.nmax
    ntask = args.ntask
    nodes = args.nodes
    cores = args.cores
    machine = args.machine
    optimization = args.optimization
    nruns = args.nruns
    truns = args.truns
    # JOBID = args.jobid

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = 'GPTune'
    TUNER_NAME = os.environ['TUNER_NAME']

    # YL: for the spaces, the following datatypes are supported:
    # Real(lower, upper, transform="normalize", name="yourname")
    # Integer(lower, upper, transform="normalize", name="yourname")
    # Categoricalnorm(categories, transform="onehot", name="yourname")

    matrices = ["big.rua", "g4.rua", "g20.rua"]
    # matrices = ["Si2.rb", "SiH4.rb", "SiNa.rb", "Na5.rb", "benzene.rb", "Si10H16.rb", "Si5H12.rb", "SiO.rb", "Ga3As3H12.rb", "GaAsH6.rb", "H2O.rb"]

    # Task parameters
    matrix = Categoricalnorm(matrices, transform="onehot", name="matrix")

    # Input parameters
    COLPERM = Categoricalnorm(['2', '4'], transform="onehot", name="COLPERM")
    LOOKAHEAD = Integer(5, 20, transform="normalize", name="LOOKAHEAD")
    nprows = Integer(1, nodes * cores, transform="normalize", name="nprows")
    nproc = Integer(nodes, nodes * cores, transform="normalize", name="nproc")
    NSUP = Integer(30, 300, transform="normalize", name="NSUP")
    NREL = Integer(10, 40, transform="normalize", name="NREL")
    runtime = Real(float("-Inf"),
                   float("Inf"),
                   transform="normalize",
                   name="r")

    IS = Space([matrix])
    PS = Space([COLPERM, LOOKAHEAD, nproc, nprows, NSUP, NREL])
    OS = Space([runtime])

    cst1 = "%d * %d" % (
        nodes, cores
    ) + ">= nproc+2"  # YL: there are at least 2 cores working on other stuff
    cst2 = "NSUP >= NREL"
    cst3 = "nproc >= nprows"  # intrinsically implies "p <= nproc"

    constraints = {"cst1": cst1, "cst2": cst2, "cst3": cst3}
    models = {}

    print(IS, PS, OS, constraints, models)

    # target='memory'
    target = 'time'

    problem = TuningProblem(IS, PS, OS, objective, constraints, None)
    computer = Computer(nodes=nodes, cores=cores, hosts=None)

    options = Options()
    # options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    options['distributed_memory_parallelism'] = True
    options['shared_memory_parallelism'] = False
    options['model_class '] = 'Model_LCM'
    options['verbose'] = False

    options.validate(computer=computer)
    data = Data(problem)
    gt = GPTune(problem, computer=computer, data=data, options=options)

    # """ Building MLA with NI random tasks """
    # NI = ntask
    # NS = nruns
    # (data, model,stats) = gt.MLA(NS=NS, NI=NI, NS1 = max(NS//2,1))
    # print("stats: ",stats)
    """ Building MLA with the given list of tasks """
    giventask = [["big.rua"], ["g4.rua"], ["g20.rua"]]
    NI = len(giventask)
    NS = nruns
    (data, model, stats) = gt.MLA(NS=NS,
                                  NI=NI,
                                  Tgiven=giventask,
                                  NS1=max(NS // 2, 1))
    print("stats: ", stats)

    for tid in range(NI):
        print("tid: %d" % (tid))
        print("    matrix:%s" % (data.T[tid][0]))
        print("    Xs ", data.X[tid])
        print("    Ys ", data.Y[tid])
        print('    Xopt ', data.X[tid][np.argmin(data.Y[tid])], 'Yopt ',
              min(data.Y[tid])[0])

    newtask = [["big.rua"], ["g4.rua"]]
    (aprxopts, objval, stats) = gt.TLA1(newtask, nruns)
    print("stats: ", stats)

    for tid in range(len(newtask)):
        print("new task: %s" % (newtask[tid]))
        print('    predicted Xopt: ', aprxopts[tid], ' objval: ', objval[tid])
コード例 #7
0
ファイル: superlu_single.py プロジェクト: temp3rr0r/GPTune
def main():

	global ROOTDIR
	global nodes
	global cores
	global target
	global nprocmax
	global nprocmin

	# Parse command line arguments

	args   = parse_args()

	# Extract arguments

	# mmax = args.mmax
	# nmax = args.nmax
	ntask = args.ntask
	nodes = args.nodes
	cores = args.cores
	nprocmin_pernode = args.nprocmin_pernode
	machine = args.machine
	optimization = args.optimization
	nruns = args.nruns
	truns = args.truns
	# JOBID = args.jobid
	
	TUNER_NAME = args.optimization
	os.environ['MACHINE_NAME'] = machine
	os.environ['TUNER_NAME'] = TUNER_NAME
	
	
	nprocmax = nodes*cores-1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
	nprocmin = min(nodes*nprocmin_pernode,nprocmax-1)  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

	# matrices = ["big.rua", "g4.rua", "g20.rua"]
	# matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin","H2O.bin"]
	matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin", "GaAsH6.bin", "H2O.bin"]

	# Task parameters
	matrix    = Categoricalnorm (matrices, transform="onehot", name="matrix")

	# Input parameters
	COLPERM   = Categoricalnorm (['2', '4'], transform="onehot", name="COLPERM")
	LOOKAHEAD = Integer     (5, 20, transform="normalize", name="LOOKAHEAD")
	nprows    = Integer     (1, nprocmax, transform="normalize", name="nprows")
	nproc     = Integer     (nprocmin, nprocmax, transform="normalize", name="nproc")
	NSUP      = Integer     (30, 300, transform="normalize", name="NSUP")
	NREL      = Integer     (10, 40, transform="normalize", name="NREL")	
	result   = Real        (float("-Inf") , float("Inf"),name="r")
	IS = Space([matrix])
	PS = Space([COLPERM, LOOKAHEAD, nproc, nprows, NSUP, NREL])
	OS = Space([result])
	cst1 = "NSUP >= NREL"
	cst2 = "nproc >= nprows" # intrinsically implies "p <= nproc"
	constraints = {"cst1" : cst1, "cst2" : cst2}
	models = {}

	""" Print all input and parameter samples """	
	print(IS, PS, OS, constraints, models)



	target='memory'
	# target='time'


	problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
	computer = Computer(nodes = nodes, cores = cores, hosts = None)  

	""" Set and validate options """	
	options = Options()
	options['model_processes'] = 1
	# options['model_threads'] = 1
	options['model_restarts'] = 1
	# options['search_multitask_processes'] = 1
	# options['model_restart_processes'] = 1
	options['distributed_memory_parallelism'] = False
	options['shared_memory_parallelism'] = False
	options['model_class '] = 'Model_LCM' # 'Model_GPy_LCM'
	options['verbose'] = False

	options.validate(computer = computer)
	


	""" Intialize the tuner with existing data stored as last check point"""
	try:
		data = pickle.load(open('Data_nodes_%d_cores_%d_nprocmin_pernode_%d_tasks_%s_machine_%s.pkl' % (nodes, cores, nprocmin_pernode, matrices, machine), 'rb'))
		giventask = data.I
	except (OSError, IOError) as e:
		data = Data(problem)
		giventask = [[np.random.choice(matrices,size=1)[0]] for i in range(ntask)]


	# """ Building MLA with the given list of tasks """
	# giventask = [["big.rua"]]		
	giventask = [["Si2.bin"]]		
	data = Data(problem)



	if(TUNER_NAME=='GPTune'):
		gt = GPTune(problem, computer=computer, data=data, options=options, driverabspath=os.path.abspath(__file__))        
		
		NI = len(giventask)
		NS = nruns
		(data, model, stats) = gt.MLA(NS=NS, NI=NI, Igiven=giventask, NS1=max(NS//2, 1))
		print("stats: ", stats)


		""" Dump the data to file as a new check point """
		pickle.dump(data, open('Data_nodes_%d_cores_%d_nprocmin_pernode_%d_tasks_%s_machine_%s.pkl' % (nodes, cores, nprocmin_pernode, matrices, machine), 'wb'))

		""" Dump the tuner to file for TLA use """
		pickle.dump(gt, open('MLA_nodes_%d_cores_%d_nprocmin_pernode_%d_tasks_%s_machine_%s.pkl' % (nodes, cores, nprocmin_pernode, matrices, machine), 'wb'))

		""" Print all input and parameter samples """	
		for tid in range(NI):
			print("tid: %d"%(tid))
			print("    matrix:%s"%(data.I[tid][0]))
			print("    Ps ", data.P[tid])
			print("    Os ", data.O[tid])
			print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

	if(TUNER_NAME=='opentuner'):
		NI = ntask
		NS = nruns
		(data,stats) = OpenTuner(T=giventask, NS=NS, tp=problem, computer=computer, run_id="OpenTuner", niter=1, technique=None)
		print("stats: ", stats)

		""" Print all input and parameter samples """
		for tid in range(NI):
			print("tid: %d"%(tid))
			print("    matrix:%s"%(data.I[tid][0]))
			print("    Ps ", data.P[tid])
			print("    Os ", data.O[tid])
			print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

	if(TUNER_NAME=='hpbandster'):
		NI = ntask
		NS = nruns
		(data,stats)=HpBandSter(T=giventask, NS=NS, tp=problem, computer=computer, run_id="HpBandSter", niter=1)
		print("stats: ", stats)
		""" Print all input and parameter samples """
		for tid in range(NI):
			print("tid: %d"%(tid))
			print("    matrix:%s"%(data.I[tid][0]))
			print("    Ps ", data.P[tid])
			print("    Os ", data.O[tid])
			print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #8
0
ファイル: run_autotuner.py プロジェクト: gptune/CK-GPTune
def main():

    global ROOTDIR
    global nodes
    global cores
    global target
    global nprocmax
    global nprocmin


    # Get arguments from CK-GPTune
    # if not given by CK-GPTune: -nodes 1 -cores 4 -nprocmin_pernode 1 -ntask 1 -nrun 10 -machine youmachine -optimization 'GPTune'
    nodes = int(os.environ.get('nodes','1'))
    cores = int(os.environ.get('cores','4'))
    if cores < 4:
        cores = 4

    ntask = int(os.environ.get('ntask','1'))
    nruns = int(os.environ.get('nruns','10'))

    nprocmin_pernode = int(os.environ.get('nprocmin_pernode','1'))
    machine = str(os.environ.get('machine','mymachine'))
    JOBID = int(os.environ.get('jobid','0'))
    TUNER_NAME = str(os.environ.get('optimization','GPTune'))

    compile_deps = os.environ.get('compile_deps','')
    print (compile_deps)

    print ('run_autotuner arguments\n \
            nodes: %d\
            cores: %d\
            ntask: %d\
            nruns: %d\
            nprocmin_pernode: %d\
            machine: %s\
            jobid: %d\
            tuner: %s'
            %(nodes, cores, ntask, nruns, nprocmin_pernode, machine, JOBID, TUNER_NAME))

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME

    nprocmax = nodes*cores-1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(nodes*nprocmin_pernode,nprocmax-1)  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space
    matrices = ["big.rua", "g4.rua", "g20.rua"]
    # matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin","H2O.bin"]
    # matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin", "GaAsH6.bin", "H2O.bin"]
    # Task parameters
    matrix    = Categoricalnorm (matrices, transform="onehot", name="matrix")
    # Input parameters
    COLPERM   = Categoricalnorm (['2', '4'], transform="onehot", name="COLPERM")
    LOOKAHEAD = Integer     (5, 20, transform="normalize", name="LOOKAHEAD")
    nprows    = Integer     (1, nprocmax, transform="normalize", name="nprows")
    nproc     = Integer     (nprocmin, nprocmax, transform="normalize", name="nproc")
    NSUP      = Integer     (30, 300, transform="normalize", name="NSUP")
    NREL      = Integer     (10, 40, transform="normalize", name="NREL")
    runtime   = Real        (float("-Inf") , float("Inf"), name="runtime")
    memory    = Real        (float("-Inf") , float("Inf"), name="memory")
    IS = Space([matrix])
    PS = Space([COLPERM, LOOKAHEAD, nproc, nprows, NSUP, NREL])
    OS = Space([runtime, memory])
    cst1 = "NSUP >= NREL"
    cst2 = "nproc >= nprows" # intrinsically implies "p <= nproc"
    constraints = {"cst1" : cst1, "cst2" : cst2}
    models = {}

    """ Print all input and parameter samples """
    print(IS, PS, OS, constraints, models)

    problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
    computer = Computer(nodes = nodes, cores = cores, hosts = None)

    """ Set and validate options """
    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    options['model_class '] = 'Model_LCM'
    options['verbose'] = False
    options['search_algo'] = 'nsga2' #'maco' #'moead' #'nsga2' #'nspso'
    options['search_pop_size'] = 1000
    options['search_gen'] = 10
    options['search_more_samples'] = 4
    options.validate(computer = computer)

    """ Intialize the tuner with existing data"""
    data = Data(problem)
    gt = GPTune(problem, computer = computer, data = data, options = options)

    if(TUNER_NAME=='GPTune'):

        #""" Building MLA with NI random tasks """
        #NI = ntask
        #NS = nruns
        #(data, model,stats) = gt.MLA(NS=NS, NI=NI, NS1 = max(NS//2,1))
        #print("stats: ",stats)

        """ Building MLA with the given list of tasks """
        giventask = [["big.rua"], ["g4.rua"], ["g20.rua"]]
        # giventask = [["Si2.bin"]]
        # giventask = [["Si2.bin"],["SiH4.bin"], ["SiNa.bin"], ["Na5.bin"], ["benzene.bin"], ["Si10H16.bin"], ["Si5H12.bin"], ["SiO.bin"], ["Ga3As3H12.bin"],["GaAsH6.bin"],["H2O.bin"]]
        # giventask = [["Si2.bin"],["SiH4.bin"], ["SiNa.bin"], ["Na5.bin"], ["benzene.bin"], ["Si10H16.bin"], ["Si5H12.bin"], ["SiO.bin"]]

        NI = len(giventask)
        NS = nruns
        (data, model,stats) = gt.MLA(NS=NS, NI=NI, Igiven =giventask, NS1 = max(NS//2,1))
        print("stats: ",stats)


        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d"%(tid))
            print("    matrix:%s"%(data.I[tid][0]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            ndf, dl, dc, ndr = pg.fast_non_dominated_sorting(data.O[tid])
            front = ndf[0]
            # print('front id: ',front)
            fopts = data.O[tid][front]
            xopts = [data.P[tid][i] for i in front]
            print('    Popts ', xopts)
            print('    Oopts ', fopts.tolist())
コード例 #9
0
    # giventask = [[i] for i in np.arange(0, 10, 0.5).tolist()]

    NI = len(giventask)
    NS = 100

    TUNER_NAME = os.environ['TUNER_NAME']

    if (TUNER_NAME == 'GPTune'):
        data = Data(problem)
        gt = GPTune(problem,
                    computer=computer,
                    data=data,
                    options=options,
                    driverabspath=os.path.abspath(__file__))
        (data, modeler, stats) = gt.MLA(NS=NS,
                                        Igiven=giventask,
                                        NI=NI,
                                        NS1=int(NS / 2))
        # (data, modeler, stats) = gt.MLA(NS=NS, Igiven=giventask, NI=NI, NS1=NS-1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    t:%d " % (data.I[tid][0]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'opentuner'):
        (data, stats) = OpenTuner(T=giventask,
                                  NS=NS,
コード例 #10
0
def main():
    global nodes
    global cores
    global JOBID
    global nprocmax
    global nprocmin

    # Get arguments from CK-GPTune
    # if not given by CK-GPTune: -nxmax 100 -nymax 100 -nzmax 100 -nodes 1 -cores 32 -nprocmin_pernode 1 -ntask 2 -nrun 5 -machine cori -jobid 0
    nxmax = int(os.environ.get('nxmax','100'))
    nymax = int(os.environ.get('nymax','100'))
    nzmax = int(os.environ.get('nzmax','100'))
    nodes = int(os.environ.get('nodes','1'))
    cores = int(os.environ.get('cores','4'))
    nprocmin_pernode = int(os.environ.get('nprocmin_pernode','1'))
    machine = str(os.environ.get('machine','mymachine'))
    ntask = int(os.environ.get('ntask','2'))
    nruns = int(os.environ.get('nruns','5'))
    JOBID = int(os.environ.get('jobid','0'))
    TUNER_NAME = str(os.environ.get('optimization','GPTune'))
    TLA = False

    print ('run_autotuner arguments\n \
            nxmax: %d\
            nymax: %d\
            nzmax: %d\
            nodes: %d\
            cores: %d\
            nprocmin_pernode: %d\
            machine: %s\
            ntask: %d\
            nruns: %d\
            jobid: %d\
            tuner: %s'
            %(nxmax, nymax, nzmax, nodes, cores, nprocmin_pernode, machine, ntask, nruns, JOBID, TUNER_NAME))

#    # Parse command line arguments
#    args = parse_args()
#
#    nxmax = args.nxmax
#    nymax = args.nymax
#    nzmax = args.nzmax
#    nodes = args.nodes
#    cores = args.cores
#    nprocmin_pernode = args.nprocmin_pernode
#    machine = args.machine
#    ntask = args.ntask
#    nruns = args.nruns
#    JOBID = args.jobid
#    TUNER_NAME = args.optimization
#    TLA = False

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME
    # os.system("mkdir -p scalapack-driver/bin/%s; cp ../build/pdqrdriver scalapack-driver/bin/%s/.;" %(machine, machine))

    nprocmax = nodes*cores-1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(nodes*nprocmin_pernode,nprocmax-1)  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space


    nxmin = 20
    nymin = 20
    nzmin = 20
    nx = Integer(nxmin, nxmax, transform="normalize", name="nx")
    ny = Integer(nymin, nymax, transform="normalize", name="ny")
    nz = Integer(nzmin, nzmax, transform="normalize", name="nz")
    Px = Integer(1, nprocmax, transform="normalize", name="Px")
    Py = Integer(1, nprocmax, transform="normalize", name="Py")
    Nproc = Integer(nprocmin, nprocmax, transform="normalize", name="Nproc")
    strong_threshold = Real(0, 1, transform="normalize", name="strong_threshold")
    trunc_factor =  Real(0, 1, transform="normalize", name="trunc_factor")
    P_max_elmts = Integer(1, 12,  transform="normalize", name="P_max_elmts")
    coarsen_type = Categoricalnorm (['0', '1', '2', '3', '4', '6', '8', '10'], transform="onehot", name="coarsen_type")
    relax_type = Categoricalnorm (['-1', '0', '6', '8', '16', '18'], transform="onehot", name="relax_type")
    smooth_type = Categoricalnorm (['5', '6', '7', '8', '9'], transform="onehot", name="smooth_type")
    smooth_num_levels = Integer(0, 5,  transform="normalize", name="smooth_num_levels")
    interp_type = Categoricalnorm (['0', '3', '4', '5', '6', '8', '12'], transform="onehot", name="interp_type")
    agg_num_levels = Integer(0, 5,  transform="normalize", name="agg_num_levels")
    r = Real(float("-Inf"), float("Inf"), name="r")

    IS = Space([nx, ny, nz])
    PS = Space([Px, Py, Nproc, strong_threshold, trunc_factor, P_max_elmts, coarsen_type, relax_type, smooth_type, smooth_num_levels, interp_type, agg_num_levels])
    OS = Space([r])

    # Question: how to set constraints
    cst1 = f"Px * Py  <= Nproc"
    cst2 = f"not(coarsen_type=='0' and P_max_elmts==10 and relax_type=='18' and smooth_type=='6' and smooth_num_levels==3 and interp_type=='8' and agg_num_levels==1)"
    constraints = {"cst1": cst1,"cst2": cst2}

    print(IS, PS, OS, constraints)

    problem = TuningProblem(IS, PS, OS, objectives, constraints, None) # no performance model
    computer = Computer(nodes=nodes, cores=cores, hosts=None)

    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    # options['mpi_comm'] = None
    options['model_class '] = 'Model_LCM'
    options['verbose'] = False
    options.validate(computer=computer)

    data = Data(problem)
    giventask = [[randint(nxmin,nxmax),randint(nymin,nymax),randint(nzmin,nzmax)] for i in range(ntask)]

    if(TUNER_NAME=='GPTune'):
        gt = GPTune(problem, computer=computer, data=data, options=options, driverabspath=os.path.abspath(__file__))
        """ Building MLA with the given list of tasks """
        NI = len(giventask)
        NS = nruns
        (data, model, stats) = gt.MLA(NS=NS, NI=NI, Igiven=giventask, NS1=max(NS//2, 1))
        print("stats: ", stats)

        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    nx:%d ny:%d nz:%d" % (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

        if TLA is True:
            """ Call TLA for 2 new tasks using the constructed LCM model"""
            newtask = [[50, 50, 60], [80, 60, 70]]
            (aprxopts, objval, stats) = gt.TLA1(newtask, NS=None)
            print("stats: ", stats)

            """ Print the optimal parameters and function evaluations"""
            for tid in range(len(newtask)):
                print("new task: %s" % (newtask[tid]))
                print('    predicted Popt: ', aprxopts[tid], ' objval: ', objval[tid])


    if(TUNER_NAME=='opentuner'):
        NI = ntask
        NS = nruns
        (data,stats) = OpenTuner(T=giventask, NS=NS, tp=problem, computer=computer, run_id="OpenTuner", niter=1, technique=None)
        print("stats: ", stats)

        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    nx:%d ny:%d nz:%d" % (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if(TUNER_NAME=='hpbandster'):
        NI = ntask
        NS = nruns
        (data,stats)=HpBandSter(T=giventask, NS=NS, tp=problem, computer=computer, run_id="HpBandSter", niter=1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    nx:%d ny:%d nz:%d" % (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #11
0
def main():

	global ROOTDIR
	global nodes
	global cores
	global target
	global nprocmax
	global nprocmin

	# Parse command line arguments

	args   = parse_args()

	# Extract arguments

	# mmax = args.mmax
	# nmax = args.nmax
	ntask = args.ntask
	nodes = args.nodes
	cores = args.cores
	nprocmin_pernode = args.nprocmin_pernode
	machine = args.machine
	optimization = args.optimization
	nruns = args.nruns
	truns = args.truns
	# JOBID = args.jobid
	
	TUNER_NAME = args.optimization
	os.environ['MACHINE_NAME'] = machine
	os.environ['TUNER_NAME'] = TUNER_NAME
	
	
	# nprocmax = nodes*cores-1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
	# nprocmin = min(nodes*nprocmin_pernode,nprocmax-1)  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

	# matrices = ["big.rua", "g4.rua", "g20.rua"]
	# matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin","H2O.bin"]
	# matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin", "GaAsH6.bin", "H2O.bin"]

	# Task parameters
	gridsize = Integer     (30, 100, transform="normalize", name="gridsize")

	# Input parameters
	sp_reordering_method   = Categoricalnorm (['metis','parmetis','geometric'], transform="onehot", name="sp_reordering_method")
	# sp_reordering_method   = Categoricalnorm (['metis','geometric'], transform="onehot", name="sp_reordering_method")
	# sp_compression   = Categoricalnorm (['none','hss'], transform="onehot", name="sp_compression")
	# sp_compression   = Categoricalnorm (['none','hss','hodlr','hodbf'], transform="onehot", name="sp_compression")
	sp_compression   = Categoricalnorm (['none','hss','hodlr','hodbf','blr'], transform="onehot", name="sp_compression")
	npernode     = Integer     (0, 5, transform="normalize", name="npernode")
	sp_nd_param     = Integer     (8, 32, transform="normalize", name="sp_nd_param")
	sp_compression_min_sep_size     = Integer     (2, 5, transform="normalize", name="sp_compression_min_sep_size")
	sp_compression_min_front_size     = Integer     (4, 10, transform="normalize", name="sp_compression_min_front_size")
	sp_compression_leaf_size     = Integer     (5, 9, transform="normalize", name="sp_compression_leaf_size")
	sp_compression_rel_tol     = Integer(-6, -1, transform="normalize", name="sp_compression_rel_tol")


	result   = Real        (float("-Inf") , float("Inf"),name="r")
	IS = Space([gridsize])
	PS = Space([sp_reordering_method,sp_compression,sp_nd_param,sp_compression_min_sep_size,sp_compression_min_front_size,sp_compression_leaf_size,sp_compression_rel_tol,npernode])
	OS = Space([result])
	constraints = {}
	models = {}

	""" Print all input and parameter samples """	
	print(IS, PS, OS, constraints, models)


	problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
	computer = Computer(nodes = nodes, cores = cores, hosts = None)  

	""" Set and validate options """	
	options = Options()
	options['model_processes'] = 1
	# options['model_threads'] = 1
	options['model_restarts'] = 1
	# options['search_multitask_processes'] = 1
	# options['model_restart_processes'] = 1
	options['distributed_memory_parallelism'] = False
	options['shared_memory_parallelism'] = False
	options['model_class '] = 'Model_LCM' # 'Model_GPy_LCM'
	options['verbose'] = False

	options.validate(computer = computer)
	
	
	# """ Building MLA with the given list of tasks """
	giventask = [[80]]		
	data = Data(problem)



	if(TUNER_NAME=='GPTune'):
		gt = GPTune(problem, computer=computer, data=data, options=options, driverabspath=os.path.abspath(__file__))        
		
		NI = len(giventask)
		NS = nruns
		(data, model, stats) = gt.MLA(NS=NS, NI=NI, Igiven=giventask, NS1=max(NS//2, 1))
		print("stats: ", stats)

		""" Print all input and parameter samples """	
		for tid in range(NI):
			print("tid: %d"%(tid))
			print("    matrix:%s"%(data.I[tid][0]))
			print("    Ps ", data.P[tid])
			print("    Os ", data.O[tid])
			print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

	if(TUNER_NAME=='opentuner'):
		NI = ntask
		NS = nruns
		(data,stats) = OpenTuner(T=giventask, NS=NS, tp=problem, computer=computer, run_id="OpenTuner", niter=1, technique=None)
		print("stats: ", stats)

		""" Print all input and parameter samples """
		for tid in range(NI):
			print("tid: %d"%(tid))
			print("    matrix:%s"%(data.I[tid][0]))
			print("    Ps ", data.P[tid])
			print("    Os ", data.O[tid])
			print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

	if(TUNER_NAME=='hpbandster'):
		NI = ntask
		NS = nruns
		(data,stats)=HpBandSter(T=giventask, NS=NS, tp=problem, computer=computer, run_id="HpBandSter", niter=1)
		print("stats: ", stats)
		""" Print all input and parameter samples """
		for tid in range(NI):
			print("tid: %d"%(tid))
			print("    matrix:%s"%(data.I[tid][0]))
			print("    Ps ", data.P[tid])
			print("    Os ", data.O[tid])
			print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ', min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #12
0
ファイル: run_autotuner.py プロジェクト: gptune/CK-GPTune
def main():

    global ROOTDIR
    global nodes
    global cores
    global JOBID
    global nprocmax
    global nprocmin

    # Get arguments from CK-GPTune
    # if not given by CK-GPTune: -mmax 1000 -nmax 1000 -nodes 1 -cores 4 -nprocmin_pernode 1 -ntask 2 -nrun 20 -machine yourmachine -optimization 'GPTune'
    mmax = int(os.environ.get('mmax', '1000'))
    nmax = int(os.environ.get('nmax', '1000'))
    ntask = int(os.environ.get('ntask', '2'))
    nodes = int(os.environ.get('nodes', '1'))
    cores = int(os.environ.get('cores', '4'))
    nprocmin_pernode = int(os.environ.get('nprocmin_pernode', '1'))
    machine = str(os.environ.get('machine', 'mymachine'))
    nruns = int(os.environ.get('nruns', '20'))
    JOBID = int(os.environ.get('jobid', '0'))
    TUNER_NAME = str(os.environ.get('optimization', 'GPTune'))

    print('run_autotuner arguments\n \
            mmax: %d\
            nmax: %d\
            ntask: %d\
            nodes: %d\
            cores: %d\
            nprocmin_pernode: %d\
            machine: %s\
            nruns: %d\
            jobid: %d\
            tuner: %s' % (mmax, nmax, ntask, nodes, cores, nprocmin_pernode,
                          machine, nruns, JOBID, TUNER_NAME))

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME
    #os.system("mkdir -p scalapack-driver/bin/%s; cp ../build/pdqrdriver scalapack-driver/bin/%s/.;" %(machine, machine))
    file_dir_path = str(Path(__file__).parent.absolute())
    os.system(
        "mkdir -p %s/scalapack-driver/bin/%s; cp ./GPTune/build/pdqrdriver %s/scalapack-driver/bin/%s/.;"
        % (file_dir_path, machine, file_dir_path, machine))

    nprocmax = nodes * cores - 1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(
        nodes * nprocmin_pernode, nprocmax - 1
    )  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

    mmin = 128
    nmin = 128

    m = Integer(mmin, mmax, transform="normalize", name="m")
    n = Integer(nmin, nmax, transform="normalize", name="n")
    mb = Integer(1, 16, transform="normalize", name="mb")
    nb = Integer(1, 16, transform="normalize", name="nb")
    nproc = Integer(nprocmin, nprocmax, transform="normalize", name="nproc")
    p = Integer(0, nprocmax, transform="normalize", name="p")
    r = Real(float("-Inf"), float("Inf"), name="r")

    IS = Space([m, n])
    PS = Space([mb, nb, nproc, p])
    OS = Space([r])
    cst1 = "mb*8 * p <= m"
    cst2 = "nb*8 * nproc <= n * p"
    cst3 = "nproc >= p"
    constraints = {"cst1": cst1, "cst2": cst2, "cst3": cst3}
    print(IS, PS, OS, constraints)

    problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
    computer = Computer(nodes=nodes, cores=cores, hosts=None)
    """ Set and validate options """
    options = Options()
    # options['model_processes'] = 16
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    # options['model_restart_threads'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    # options['mpi_comm'] = None
    options['model_class '] = 'Model_LCM'
    options['verbose'] = False
    options.validate(computer=computer)

    data = Data(problem)
    giventask = [[randint(mmin, mmax),
                  randint(nmin, nmax)] for i in range(ntask)]

    if (TUNER_NAME == 'GPTune'):

        gt = GPTune(problem, computer=computer, data=data, options=options)
        """ Building MLA with NI random tasks """
        NI = ntask
        NS = nruns
        (data, model, stats) = gt.MLA(NS=NS,
                                      Igiven=giventask,
                                      NI=NI,
                                      NS1=max(NS // 2, 1))
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'opentuner'):
        NI = ntask
        NS = nruns
        (data, stats) = OpenTuner(T=giventask,
                                  NS=NS,
                                  tp=problem,
                                  computer=computer,
                                  run_id="OpenTuner",
                                  niter=1,
                                  technique=None)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'hpbandster'):
        NI = ntask
        NS = nruns
        (data, stats) = HpBandSter(T=giventask,
                                   NS=NS,
                                   tp=problem,
                                   computer=computer,
                                   run_id="HpBandSter",
                                   niter=1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    m:%d n:%d" % (data.I[tid][0], data.I[tid][1]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid].tolist())
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #13
0
ファイル: scalapack.py プロジェクト: liuyangzhuan/GPTune
def main_interactive():

    global ROOTDIR
    global nodes
    global cores
    global JOBID

    # Parse command line arguments

    parser = argparse.ArgumentParser()

    # Problem related arguments
    parser.add_argument('-mmax', type=int, default=-1, help='Number of rows')
    parser.add_argument('-nmax',
                        type=int,
                        default=-1,
                        help='Number of columns')
    # Machine related arguments
    parser.add_argument('-nodes',
                        type=int,
                        default=1,
                        help='Number of machine nodes')
    parser.add_argument('-cores',
                        type=int,
                        default=1,
                        help='Number of cores per machine node')
    parser.add_argument('-machine',
                        type=str,
                        help='Name of the computer (not hostname)')
    # Algorithm related arguments
    parser.add_argument(
        '-optimization',
        type=str,
        help='Optimization algorithm (opentuner, spearmint, mogpo)')
    parser.add_argument('-ntask', type=int, default=-1, help='Number of tasks')
    parser.add_argument('-nruns', type=int, help='Number of runs per task')
    parser.add_argument('-truns', type=int, help='Time of runs')
    # Experiment related arguments
    parser.add_argument(
        '-jobid', type=int, default=-1,
        help='ID of the batch job')  #0 means interactive execution (not batch)

    args = parser.parse_args()

    # Extract arguments

    mmax = args.mmax
    nmax = args.nmax
    ntask = args.ntask
    nodes = args.nodes
    cores = args.cores
    machine = args.machine
    optimization = args.optimization
    nruns = args.nruns
    truns = args.truns
    JOBID = args.jobid

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = 'GPTune'
    # print(os.environ)

    os.system(
        "mkdir -p scalapack-driver/bin/%s; cp ../build/pdqrdriver scalapack-driver/bin/%s/.;"
        % (machine, machine))

    # YL: for the spaces, the following datatypes are supported:
    # Real(lower, upper, transform="normalize", name="yourname")
    # Integer(lower, upper, transform="normalize", name="yourname")
    # Categoricalnorm(categories, transform="onehot", name="yourname")

    m = Integer(128, mmax, transform="normalize", name="m")
    n = Integer(128, nmax, transform="normalize", name="n")
    mb = Integer(1, 128, transform="normalize", name="mb")
    nb = Integer(1, 128, transform="normalize", name="nb")
    nproc = Integer(nodes,
                    nodes * cores - 1,
                    transform="normalize",
                    name="nproc")  # YL: there are is one proc doing spawning
    p = Integer(1, nodes * cores, transform="normalize", name="p")
    r = Real(float("-Inf"), float("Inf"), name="r")

    IS = Space([m, n])
    PS = Space([mb, nb, nproc, p])
    OS = Space([r])

    #    cst1 = "mb <= int(m / p) if (m / p) >= 1 else False"
    #    cst2 = "nb <= int(n / int(nproc / p)) if (n / int(nproc / p)) >= 1 else False"
    #    #cst3 = "int(nodes * cores / nproc) == (nodes * cores / nproc)"
    #    cst3 = "int(%d * %d / nproc) == (%d * %d / nproc)"%(nodes, cores, nodes, cores)
    #    cst4 = "int(nproc / p) == (nproc / p)" # intrinsically implies "p <= nproc"
    cst1 = "mb * p <= m"
    cst2 = "nb * nproc <= n * p"
    #cst3 = "int(nodes * cores / nproc) == (nodes * cores / nproc)"
    # cst3 = "%d * %d"%(nodes, cores) + ">= nproc+2"
    cst3 = "nproc >= p"  # intrinsically implies "p <= nproc"

    constraints = {"cst1": cst1, "cst2": cst2, "cst3": cst3}
    # constraints = {"cst1" : cst1, "cst2" : cst2, "cst3" : cst3}

    models = {}

    print(IS, PS, OS, constraints, models)

    problem = TuningProblem(IS, PS, OS, objective, constraints, None)
    computer = Computer(nodes=nodes, cores=cores, hosts=None)

    options = Options()
    # options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    # options['model_restart_threads'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    # options['mpi_comm'] = None
    options['model_class '] = 'Model_LCM'
    options['verbose'] = False

    options.validate(computer=computer)
    data = Data(problem)
    gt = GPTune(problem, computer=computer, data=data, options=options)

    # """ Building MLA with NI random tasks """
    # NI = ntask
    # NS = nruns
    # (data, model,stats) = gt.MLA(NS=NS, NI=NI, NS1 = max(NS//2,1))
    # print("stats: ",stats)
    """ Building MLA with the given list of tasks """
    giventask = [[460, 500], [800, 690]]
    NI = len(giventask)
    NS = nruns
    (data, model, stats) = gt.MLA(NS=NS,
                                  NI=NI,
                                  Tgiven=giventask,
                                  NS1=max(NS // 2, 1))
    print("stats: ", stats)

    pickle.dump(
        gt,
        open(
            'MLA_nodes_%d_cores_%d_mmax_%d_nmax_%d_machine_%s_jobid_%d.pkl' %
            (nodes, cores, mmax, nmax, machine, JOBID), 'wb'))

    for tid in range(NI):
        print("tid: %d" % (tid))
        print("    m:%d n:%d" % (data.T[tid][0], data.T[tid][1]))
        print("    Xs ", data.X[tid])
        print("    Ys ", data.Y[tid])
        print('    Xopt ', data.X[tid][np.argmin(data.Y[tid])], 'Yopt ',
              min(data.Y[tid])[0])

    newtask = [[400, 500], [800, 600]]
    (aprxopts, objval, stats) = gt.TLA1(newtask, nruns)
    print("stats: ", stats)

    for tid in range(len(newtask)):
        print("new task: %s" % (newtask[tid]))
        print('    predicted Xopt: ', aprxopts[tid], ' objval: ', objval[tid])
コード例 #14
0
def main():

    global ROOTDIR
    global nodes
    global cores
    global target
    global nprocmax
    global nprocmin

    # Parse command line arguments

    args = parse_args()

    # Extract arguments

    # mmax = args.mmax
    # nmax = args.nmax
    ntask = args.ntask
    nodes = args.nodes
    cores = args.cores
    nprocmin_pernode = args.nprocmin_pernode
    machine = args.machine
    optimization = args.optimization
    nruns = args.nruns
    truns = args.truns
    # JOBID = args.jobid

    TUNER_NAME = args.optimization
    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME

    nprocmax = nodes * cores - 1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(
        nodes * nprocmin_pernode, nprocmax - 1
    )  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

    # Task parameters
    geomodels = [
        "cavity_5cell_30K_feko", "pillbox_4000", "pillbox_1000",
        "cavity_wakefield_4K_feko", "cavity_rec_5K_feko", "cavity_rec_17K_feko"
    ]
    # geomodels = ["cavity_wakefield_4K_feko"]
    model = Categoricalnorm(geomodels, transform="onehot", name="model")

    # Input parameters  # the frequency resolution is 100Khz
    # freq      = Integer     (22000, 23500, transform="normalize", name="freq")
    freq = Integer(6320, 6430, transform="normalize", name="freq")
    # freq      = Integer     (21000, 22800, transform="normalize", name="freq")
    # freq      = Integer     (11400, 12000, transform="normalize", name="freq")
    # freq      = Integer     (500, 900, transform="normalize", name="freq")
    result1 = Real(float("-Inf"), float("Inf"), name="r1")
    result2 = Real(float("-Inf"), float("Inf"), name="r2")

    IS = Space([model])
    PS = Space([freq])
    # OS = Space([result1,result2])
    OS = Space([result1])

    constraints = {}
    models = {}
    """ Print all input and parameter samples """
    print(IS, PS, OS, constraints, models)

    problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
    computer = Computer(nodes=nodes, cores=cores, hosts=None)
    """ Set and validate options """
    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    options['model_class '] = 'Model_LCM'  # 'Model_GPy_LCM'
    options['verbose'] = False

    # options['search_algo'] = 'nsga2' #'maco' #'moead' #'nsga2' #'nspso'
    # options['search_pop_size'] = 1000 # 1000
    # options['search_gen'] = 10

    options.validate(computer=computer)

    # """ Intialize the tuner with existing data stored as last check point"""
    # try:
    # 	data = pickle.load(open('Data_nodes_%d_cores_%d_nprocmin_pernode_%d_tasks_%s_machine_%s.pkl' % (nodes, cores, nprocmin_pernode, geomodels, machine), 'rb'))
    # 	giventask = data.I
    # except (OSError, IOError) as e:
    # 	data = Data(problem)
    # 	giventask = [[np.random.choice(geomodels,size=1)[0]] for i in range(ntask)]

    # """ Building MLA with the given list of tasks """
    # giventask = [["big.rua"]]
    # giventask = [["pillbox_4000"]]
    giventask = [["cavity_5cell_30K_feko"]]
    # giventask = [["cavity_rec_17K_feko"]]
    # giventask = [["cavity_wakefield_4K_feko"]]
    data = Data(problem)

    if (TUNER_NAME == 'GPTune'):
        gt = GPTune(problem,
                    computer=computer,
                    data=data,
                    options=options,
                    driverabspath=os.path.abspath(__file__))

        NI = len(giventask)
        NS = nruns
        (data, model, stats) = gt.MLA(NS=NS,
                                      NI=NI,
                                      Igiven=giventask,
                                      NS1=max(NS // 2, 1))
        print("stats: ", stats)

        # """ Dump the data to file as a new check point """
        # pickle.dump(data, open('Data_nodes_%d_cores_%d_nprocmin_pernode_%d_tasks_%s_machine_%s.pkl' % (nodes, cores, nprocmin_pernode, matrices, machine), 'wb'))

        # """ Dump the tuner to file for TLA use """
        # pickle.dump(gt, open('MLA_nodes_%d_cores_%d_nprocmin_pernode_%d_tasks_%s_machine_%s.pkl' % (nodes, cores, nprocmin_pernode, matrices, machine), 'wb'))
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    matrix:%s" % (data.I[tid][0]))
            print("    Ps ", data.P[tid])

            OL = np.asarray([o[0] for o in data.O[tid]], dtype=np.float64)
            np.set_printoptions(suppress=False, precision=8)
            print("    Os ", OL)
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

            # ndf, dl, dc, ndr = pg.fast_non_dominated_sorting(data.O[tid])
            # front = ndf[0]
            # # print('front id: ',front)
            # fopts = data.O[tid][front]
            # xopts = [data.P[tid][i] for i in front]
            # print('    Popts ', xopts)
            # print('    Oopts ', fopts)

    if (TUNER_NAME == 'opentuner'):
        NI = ntask
        NS = nruns
        (data, stats) = OpenTuner(T=giventask,
                                  NS=NS,
                                  tp=problem,
                                  computer=computer,
                                  run_id="OpenTuner",
                                  niter=1,
                                  technique=None)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    matrix:%s" % (data.I[tid][0]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'hpbandster'):
        NI = ntask
        NS = nruns
        (data, stats) = HpBandSter(T=giventask,
                                   NS=NS,
                                   tp=problem,
                                   computer=computer,
                                   run_id="HpBandSter",
                                   niter=1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    matrix:%s" % (data.I[tid][0]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #15
0
def main():

    global ROOTDIR
    global nodes
    global cores
    global target
    global nprocmax

    # Parse command line arguments

    parser = argparse.ArgumentParser()

    # Problem related arguments
    # parser.add_argument('-mmax', type=int, default=-1, help='Number of rows')
    # parser.add_argument('-nmax', type=int, default=-1, help='Number of columns')
    # Machine related arguments
    parser.add_argument('-nodes',
                        type=int,
                        default=1,
                        help='Number of machine nodes')
    parser.add_argument('-cores',
                        type=int,
                        default=1,
                        help='Number of cores per machine node')
    parser.add_argument('-machine',
                        type=str,
                        help='Name of the computer (not hostname)')
    # Algorithm related arguments
    parser.add_argument(
        '-optimization',
        type=str,
        help='Optimization algorithm (opentuner, spearmint, mogpo)')
    parser.add_argument('-ntask', type=int, default=-1, help='Number of tasks')
    parser.add_argument('-nruns', type=int, help='Number of runs per task')
    parser.add_argument('-truns', type=int, help='Time of runs')
    # Experiment related arguments
    parser.add_argument(
        '-jobid', type=int, default=-1,
        help='ID of the batch job')  #0 means interactive execution (not batch)

    args = parser.parse_args()

    # Extract arguments

    # mmax = args.mmax
    # nmax = args.nmax
    ntask = args.ntask
    nodes = args.nodes
    cores = args.cores
    machine = args.machine
    optimization = args.optimization
    nruns = args.nruns
    truns = args.truns
    # JOBID = args.jobid

    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = 'GPTune'
    TUNER_NAME = os.environ['TUNER_NAME']

    nprocmax = nodes * cores
    # nprocmax = 256

    # Input parameters
    ROWPERM = Categoricalnorm(['1', '2'], transform="onehot", name="ROWPERM")
    COLPERM = Categoricalnorm(['2', '4'], transform="onehot", name="COLPERM")
    # nprows    = Integer     (0, 5, transform="normalize", name="nprows")
    # nproc    = Integer     (5, 6, transform="normalize", name="nproc")
    NSUP = Integer(30, 300, transform="normalize", name="NSUP")
    NREL = Integer(10, 40, transform="normalize", name="NREL")
    nbx = Integer(1, 3, transform="normalize", name="nbx")
    nby = Integer(1, 3, transform="normalize", name="nby")

    result = Real(float("-Inf"), float("Inf"), transform="normalize", name="r")

    nstep = Integer(3, 15, transform="normalize", name="nstep")
    lphi = Integer(2, 3, transform="normalize", name="lphi")
    mx = Integer(5, 6, transform="normalize", name="mx")
    my = Integer(7, 8, transform="normalize", name="my")

    IS = Space([mx, my, lphi, nstep])
    # PS = Space([ROWPERM, COLPERM, nprows, nproc, NSUP, NREL])
    PS = Space([ROWPERM, COLPERM, NSUP, NREL, nbx, nby])
    OS = Space([result])
    cst1 = "NSUP >= NREL"
    constraints = {"cst1": cst1}
    models = {}
    """ Print all input and parameter samples """
    print(IS, PS, OS, constraints, models)

    BINDIR = os.path.abspath(
        "/project/projectdirs/m2957/liuyangz/my_research/nimrod/nimdevel_spawn/build_haswell_gnu_openmpi/bin"
    )
    RUNDIR = os.path.abspath(
        "/project/projectdirs/m2957/liuyangz/my_research/nimrod/nimrod_input")
    os.system("cp %s/nimrod.in ./nimrod_template.in" % (RUNDIR))
    os.system("cp %s/fluxgrid.in ." % (RUNDIR))
    os.system("cp %s/g163518.03130 ." % (RUNDIR))
    os.system("cp %s/p163518.03130 ." % (RUNDIR))
    os.system("cp %s/nimset ." % (RUNDIR))
    os.system("cp %s/nimrod ./nimrod_spawn" % (BINDIR))

    # target='memory'
    target = 'time'

    problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
    computer = Computer(nodes=nodes, cores=cores, hosts=None)
    """ Set and validate options """
    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 8
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    options['model_class '] = 'Model_LCM'
    options['verbose'] = True

    options.validate(computer=computer)
    """ Intialize the tuner with existing data"""
    data = Data(problem)
    gt = GPTune(problem, computer=computer, data=data, options=options)

    # """ Building MLA with NI random tasks """
    # NI = ntask
    # NS = nruns
    # (data, model,stats) = gt.MLA(NS=NS, NI=NI, NS1 = max(NS//2,1))
    # print("stats: ",stats)
    """ Building MLA with the given list of tasks """
    giventask = [[6, 8, 2, 15]]
    NI = len(giventask)
    NS = nruns
    (data, model, stats) = gt.MLA(NS=NS,
                                  NI=NI,
                                  Igiven=giventask,
                                  NS1=max(NS // 2, 1))
    # (data, model,stats) = gt.MLA(NS=NS, NI=NI, Igiven =giventask, NS1 = 10)
    print("stats: ", stats)
    """ Print all input and parameter samples """
    for tid in range(NI):
        print("tid: %d" % (tid))
        print("    mx:%s my:%s lphi:%s" %
              (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
        print("    Ps ", data.P[tid])
        print("    Os ", data.O[tid])
        print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
              min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))
コード例 #16
0
ファイル: superlu_single_MO.py プロジェクト: temp3rr0r/GPTune
def main():

	global ROOTDIR
	global nodes
	global cores
	global target
	global nprocmax
	global nprocmin

	# Parse command line arguments
	args   = parse_args()

	# Extract arguments
	ntask = args.ntask
	nodes = args.nodes
	cores = args.cores
	nprocmin_pernode = args.nprocmin_pernode	
	machine = args.machine
	optimization = args.optimization
	nruns = args.nruns
	truns = args.truns
	# JOBID = args.jobid
	TUNER_NAME = args.optimization
	os.environ['MACHINE_NAME'] = machine
	os.environ['TUNER_NAME'] = TUNER_NAME


	nprocmax = nodes*cores-1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
	nprocmin = min(nodes*nprocmin_pernode,nprocmax-1)  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space
	# matrices = ["big.rua", "g4.rua", "g20.rua"]
	# matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin","H2O.bin"]
	matrices = ["Si2.bin", "SiH4.bin", "SiNa.bin", "Na5.bin", "benzene.bin", "Si10H16.bin", "Si5H12.bin", "SiO.bin", "Ga3As3H12.bin", "GaAsH6.bin", "H2O.bin"]
	# Task parameters
	matrix    = Categoricalnorm (matrices, transform="onehot", name="matrix")
	# Input parameters
	COLPERM   = Categoricalnorm (['2', '4'], transform="onehot", name="COLPERM")
	LOOKAHEAD = Integer     (5, 20, transform="normalize", name="LOOKAHEAD")
	nprows    = Integer     (1, nprocmax, transform="normalize", name="nprows")
	nproc     = Integer     (nprocmin, nprocmax, transform="normalize", name="nproc")
	NSUP      = Integer     (30, 300, transform="normalize", name="NSUP")
	NREL      = Integer     (10, 40, transform="normalize", name="NREL")	
	runtime   = Real        (float("-Inf") , float("Inf"), name="runtime")
	memory    = Real        (float("-Inf") , float("Inf"), name="memory")
	IS = Space([matrix])
	PS = Space([COLPERM, LOOKAHEAD, nproc, nprows, NSUP, NREL])
	OS = Space([runtime, memory])
	cst1 = "NSUP >= NREL"
	cst2 = "nproc >= nprows" # intrinsically implies "p <= nproc"
	constraints = {"cst1" : cst1, "cst2" : cst2}
	models = {}

	""" Print all input and parameter samples """	
	print(IS, PS, OS, constraints, models)

	problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
	computer = Computer(nodes = nodes, cores = cores, hosts = None)  

	""" Set and validate options """	
	options = Options()
	options['model_processes'] = 1
	# options['model_threads'] = 1
	options['model_restarts'] = 1
	# options['search_multitask_processes'] = 1
	# options['model_restart_processes'] = 1
	options['distributed_memory_parallelism'] = False
	options['shared_memory_parallelism'] = False
	options['model_class '] = 'Model_LCM'
	options['verbose'] = False
	options['search_algo'] = 'nsga2' #'maco' #'moead' #'nsga2' #'nspso' 
	options['search_pop_size'] = 1000
	options['search_gen'] = 10
	options['search_more_samples'] = 4
	options.validate(computer = computer)

	if(TUNER_NAME=='GPTune'):



		""" Building MLA with the given list of tasks """	
		# giventasks = [["big.rua"], ["g4.rua"], ["g20.rua"]]	
		# giventasks = [["Si2.bin"],["SiH4.bin"]]	
		# giventasks = [["Si2.bin"],["SiH4.bin"], ["SiNa.bin"], ["Na5.bin"], ["benzene.bin"], ["Si10H16.bin"], ["Si5H12.bin"], ["SiO.bin"], ["Ga3As3H12.bin"],["GaAsH6.bin"],["H2O.bin"]]	
		giventasks = [["Si2.bin"],["SiH4.bin"], ["SiNa.bin"], ["Na5.bin"], ["benzene.bin"], ["Si10H16.bin"], ["Si5H12.bin"], ["SiO.bin"]]	

		for tmp in giventasks:
			giventask = [tmp]
			data = Data(problem)
			gt = GPTune(problem, computer = computer, data = data, options = options)

			NI = len(giventask)
			NS = nruns
			(data, model,stats) = gt.MLA(NS=NS, NI=NI, Igiven =giventask, NS1 = max(NS//2,1))
			print("stats: ",stats)

			""" Print all input and parameter samples """	
			for tid in range(NI):
				print("tid: %d"%(tid))
				print("    matrix:%s"%(data.I[tid][0]))
				print("    Ps ", data.P[tid])
				print("    Os ", data.O[tid].tolist())
				ndf, dl, dc, ndr = pg.fast_non_dominated_sorting(data.O[tid])
				front = ndf[0]
				# print('front id: ',front)
				fopts = data.O[tid][front]
				xopts = [data.P[tid][i] for i in front]
				print('    Popts ', xopts)		
				print('    Oopts ', fopts.tolist())		
コード例 #17
0
def main():

    global ROOTDIR
    global nodes
    global cores
    global target
    global nprocmax
    global nprocmin

    # Parse command line arguments

    args = parse_args()

    # Extract arguments

    # mmax = args.mmax
    # nmax = args.nmax
    ntask = args.ntask
    nodes = args.nodes
    cores = args.cores
    nprocmin_pernode = args.nprocmin_pernode
    machine = args.machine
    optimization = args.optimization
    nruns = args.nruns
    truns = args.truns
    # JOBID = args.jobid

    TUNER_NAME = args.optimization
    os.environ['MACHINE_NAME'] = machine
    os.environ['TUNER_NAME'] = TUNER_NAME

    nprocmax = nodes * cores - 1  # YL: there is one proc doing spawning, so nodes*cores should be at least 2
    nprocmin = min(
        nodes * nprocmin_pernode, nprocmax - 1
    )  # YL: ensure strictly nprocmin<nprocmax, required by the Integer space

    # Task parameters
    model2d = Integer(1, 13, transform="normalize", name="model2d")
    nunk = Integer(5000, 10000000, transform="normalize", name="nunk")
    wavelength = Real(0.00001, 0.02, name="wavelength")

    # Input parameters
    lrlevel = Categoricalnorm(['0', '100'], transform="onehot", name="lrlevel")
    xyzsort = Categoricalnorm(['0', '1', '2'],
                              transform="onehot",
                              name="xyzsort")
    nmin_leaf = Integer(5, 9, transform="normalize", name="nmin_leaf")
    nproc = Integer(nprocmin, nprocmax, transform="normalize", name="nproc")

    result1 = Real(float("-Inf"), float("Inf"), name="r1")

    IS = Space([model2d, nunk, wavelength])
    PS = Space([lrlevel, xyzsort, nmin_leaf, nproc])
    OS = Space([result1])

    constraints = {}
    models = {}
    """ Print all input and parameter samples """
    print(IS, PS, OS, constraints, models)

    problem = TuningProblem(IS, PS, OS, objectives, constraints, None)
    computer = Computer(nodes=nodes, cores=cores, hosts=None)
    """ Set and validate options """
    options = Options()
    options['model_processes'] = 1
    # options['model_threads'] = 1
    options['model_restarts'] = 1
    # options['search_multitask_processes'] = 1
    # options['model_restart_processes'] = 1
    options['distributed_memory_parallelism'] = False
    options['shared_memory_parallelism'] = False
    options['model_class '] = 'Model_LCM'  # 'Model_GPy_LCM'
    options['verbose'] = False

    # options['search_algo'] = 'nsga2' #'maco' #'moead' #'nsga2' #'nspso'
    # options['search_pop_size'] = 1000 # 1000
    # options['search_gen'] = 10

    options.validate(computer=computer)

    # """ Building MLA with the given list of tasks """
    giventask = [[7, 100000, 0.001]]
    # giventask = [[7,5000,0.02]]
    data = Data(problem)

    if (TUNER_NAME == 'GPTune'):
        gt = GPTune(problem,
                    computer=computer,
                    data=data,
                    options=options,
                    driverabspath=os.path.abspath(__file__))

        NI = len(giventask)
        NS = nruns
        (data, model, stats) = gt.MLA(NS=NS,
                                      NI=NI,
                                      Igiven=giventask,
                                      NS1=max(NS // 2, 1))
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    model2d:%d nunk:%d wavelength:%1.6e" %
                  (data.I[tid][0], data.I[tid][1], data.I[tid][2]))
            print("    Ps ", data.P[tid])

            OL = np.asarray([o[0] for o in data.O[tid]], dtype=np.float64)
            np.set_printoptions(suppress=False, precision=8)
            print("    Os ", OL)
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

            # ndf, dl, dc, ndr = pg.fast_non_dominated_sorting(data.O[tid])
            # front = ndf[0]
            # # print('front id: ',front)
            # fopts = data.O[tid][front]
            # xopts = [data.P[tid][i] for i in front]
            # print('    Popts ', xopts)
            # print('    Oopts ', fopts)

    if (TUNER_NAME == 'opentuner'):
        NI = ntask
        NS = nruns
        (data, stats) = OpenTuner(T=giventask,
                                  NS=NS,
                                  tp=problem,
                                  computer=computer,
                                  run_id="OpenTuner",
                                  niter=1,
                                  technique=None)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    matrix:%s" % (data.I[tid][0]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))

    if (TUNER_NAME == 'hpbandster'):
        NI = ntask
        NS = nruns
        (data, stats) = HpBandSter(T=giventask,
                                   NS=NS,
                                   tp=problem,
                                   computer=computer,
                                   run_id="HpBandSter",
                                   niter=1)
        print("stats: ", stats)
        """ Print all input and parameter samples """
        for tid in range(NI):
            print("tid: %d" % (tid))
            print("    matrix:%s" % (data.I[tid][0]))
            print("    Ps ", data.P[tid])
            print("    Os ", data.O[tid])
            print('    Popt ', data.P[tid][np.argmin(data.O[tid])], 'Oopt ',
                  min(data.O[tid])[0], 'nth ', np.argmin(data.O[tid]))