def core3(program, dict, testing_frame, cnt): # get global variables from testing framework g_lpos = frame.get_lpos(testing_frame) g_upos = frame.get_upos(testing_frame) g_num_pos = frame.get_num_pos(testing_frame) g_p_Observ = frame.get_p_Observ(testing_frame) g_output = frame.get_output(testing_frame) g_samples = frame.get_samples(testing_frame) g_branch = frame.get_branch(testing_frame) g_space = frame.get_space(testing_frame) # transform from global variables t_isNrrd = frame.transform_isNrrd(testing_frame) t_nrrdbranch = frame.transform_nrrdpath(testing_frame) t_runtimepath = frame.transform_runtimepath(testing_frame) fields = program.fields coeffs = program.coeffs dimF = program.dim # testing positions positions = get_positions(dimF, g_lpos, g_upos, g_num_pos) # samples #create synthetic field data with diderot PARAMS = sortField(fields, g_samples, coeffs, t_nrrdbranch, g_space) print "**************** write program" name = program.name name_ty = fields[0].fldty.name (isCompile, isRun, _) = prog_writeDiderot(g_p_Observ, program, fields, positions, g_output, t_runtimepath, t_isNrrd) if (isRun == None): if (isCompile == None): counter.inc_compile(cnt) rst_compile(name, name_ty, program.name, g_branch, positions, PARAMS) return 1 else: counter.inc_run(cnt) rst_execute(name, name_ty, program.name, g_branch, positions, PARAMS) return 2 else: print "*****************************read observed data" observed_data = base_observed(program.oty, g_output) #if(check(app, observed_data)): print "*****************************prog eval" correct_data = prog_eval(program, positions, dict) print "***************************** compare" rtn = compare(program.oty, program.name, observed_data, correct_data) analyze(program.name, name_ty, program.name, cnt, rtn, observed_data, correct_data, positions, PARAMS, g_branch)
def core_test(core_fields, app, coeffs, dimF, names, testing_frame, cnt, bpd=6, spd=10, pde=2): backup_lab = "d" + str(time.time()) print( "############################################inside central############################################" ) # making a test program counter.inc_cumulative(cnt) # get global variables from testing framework g_lpos = frame.get_lpos(testing_frame) g_upos = frame.get_upos(testing_frame) g_num_pos = frame.get_num_pos(testing_frame) g_p_Observ = frame.get_p_Observ(testing_frame) g_output = frame.get_output(testing_frame) g_samples = frame.get_samples(testing_frame) g_branch = frame.get_branch(testing_frame) g_space = frame.get_space(testing_frame) g_element = frame.get_element(testing_frame) g_length = frame.get_length(testing_frame) g_ucoeff = frame.g_ucoeff(testing_frame) g_coeff_style = frame.get_coeff_style(testing_frame) # transform from global variables t_isNrrd = frame.transform_isNrrd(testing_frame) t_nrrdbranch = frame.transform_nrrdpath(testing_frame) t_runtimepath = frame.transform_runtimepath(testing_frame) #print "*******************************************" fnames = apply.get_all_FieldTys(app) x = "_" + fnames + " |" + names #print (x) writetys(x) name_describe = app.name # testing positions # note here should set positions based on space l_lpos = 0.0 l_rpos = 1.0 positions = get_positions(dimF, l_lpos, l_rpos, g_num_pos) #a = eval(newapp,positions) #print(a) #exit(0) # samples #create synthetic field data with diderot (PARAMS, all50, all51, all52, all53, all54, all55) = sortField(core_fields, g_samples, coeffs, t_nrrdbranch, g_space) #create diderot program with operator endall = time.time() startall = endall cleanup(g_output, g_p_Observ) (isCompile, isRun, startall, fp) = writeTestPrograms(g_p_Observ, app, positions, g_output, t_runtimepath, t_isNrrd, startall, test_new, core_fields, t=backup_lab, tt=(bpd, spd, pde)) if (isRun == None): if (isCompile == None): counter.inc_compile(cnt) rst_compile(names, x, name_describe, g_branch, positions, PARAMS) #raise Exception("stop") return else: if (fp == 1): counter.inc_fp(cnt) rst_fp(names, x, name_describe, g_branch, positions, PARAMS) return else: counter.inc_run(cnt) rst_execute(names, x, name_describe, g_branch, positions, PARAMS) return else: #print "read observed data" observed_data = observed(app, g_output) print("observed", observed_data) if (check(app, observed_data)): if (test_new): correct_data = 0 #expects zero everywhere rtn = compare_zero(app.oty, app.name, observed_data) analyze(names, fnames, name_describe, cnt, rtn, observed_data, correct_data, positions, PARAMS, g_branch, t=backup_lab, pde_data=(bpd, spd, pde, core_fields)) else: correct_data = eval(app, positions) print("correct_data", correct_data) rtn = compare(app.oty, app.name, observed_data, correct_data) analyze(names, fnames, name_describe, cnt, rtn, observed_data, correct_data, positions, PARAMS, g_branch) return else: # NA fnames = apply.gvet_all_FieldTys(app) x = "_" + fnames + " |" + names name_describe = app.name g_branch = frame.get_branch(testing_frame) counter.inc_NA(cnt) #rst_NA(names, x, name_describe, g_branch) return
def fem_core(app, coeffs, dimF, names, testing_frame, cnt): endall = time.time() startall = time.time() # get global variables from testing framework g_lpos = frame.get_lpos(testing_frame) g_upos = frame.get_upos(testing_frame) g_num_pos = frame.get_num_pos(testing_frame) g_p_Observ = frame.get_p_Observ(testing_frame) g_output = frame.get_output(testing_frame) g_samples = frame.get_samples(testing_frame) g_branch = frame.get_branch(testing_frame) g_space = frame.get_space(testing_frame) g_element = frame.get_element(testing_frame) g_length = frame.get_length(testing_frame) g_ucoeff = frame.g_ucoeff(testing_frame) g_coeff_style = frame.get_coeff_style(testing_frame) # transform from global variables t_isNrrd = frame.transform_isNrrd(testing_frame) t_nrrdbranch = frame.transform_nrrdpath(testing_frame) t_runtimepath = frame.transform_runtimepath(testing_frame) fem_core_fieldsOrig = apply.get_all_Fields(app) fem_core_fields = [] # limit fem_core fields by the ones we can rep. if (not (fty.is_Field(app.oty))): return for e in fem_core_fieldsOrig: ty = e.fldty #print "ty name:",ty.name,ty.space dim = ty.dim shapen = len(ty.shape) if (dim == 1): return elif (shapen > 2): return fem_core_fields.append( field.addSpace(e, g_element, g_coeff_style, g_length)) for e in fem_core_fields: ty = e.fldty #print "ty name:",ty.name,ty.space counter.inc_cumulative(cnt) fnames = apply.get_all_FieldTys(app) x = "_" + fnames + " |" + names print(x) writetys(x) #print "*******************************************" # testing positions # note here should set positions based on space l_lpos = 0.0 l_rpos = 1.0 positions = get_positions(dimF, l_lpos, l_rpos, g_num_pos) writetys(x) name_describe = app.name # samples #create synthetic field data with diderot ##PARAMS,all50,all51,all52,all53,all54,all55) = sortField(fem_core_fields, g_samples, coeffs, t_nrrdbranch, g_space) PARAMS = "" #create diderot program with operator cleanup(g_output, g_p_Observ) (isCompile, isRun, startall) = writeTestPrograms(g_p_Observ, app, positions, g_output, t_runtimepath, t_isNrrd, startall, fem_core_fields) if (isRun == None): writeTime("hold", "0") writeTime("hold", "0") writeTime("hold", "0") if (isCompile == None): counter.inc_compile(cnt) rst_compile(names, x, name_describe, g_branch, positions, PARAMS) return else: counter.inc_run(cnt) rst_execute(names, x, name_describe, g_branch, positions, PARAMS) return else: observed_data = observed(app, g_output) if (check(app, observed_data)): correct_data = eval(app, positions) rtn = compare(app.oty, app.name, observed_data, correct_data) analyze(names, fnames, name_describe, cnt, rtn, observed_data, correct_data, positions, PARAMS, g_branch) return else: counter.inc_NA(cnt) writeTime("hold", "0") writeTime("hold", "0") writeTime("hold", "0") return
def cfe_core(app, coeffs, dimF, names, testing_frame, cnt): endall = time.time() startall = time.time() # get global variables from testing framework g_lpos = frame.get_lpos(testing_frame) g_upos = frame.get_upos(testing_frame) g_num_pos = frame.get_num_pos(testing_frame) g_p_Observ = frame.get_p_Observ(testing_frame) g_output = frame.get_output(testing_frame) g_samples = frame.get_samples(testing_frame) g_branch = frame.get_branch(testing_frame) # transform from global variables t_isNrrd = frame.transform_isNrrd(testing_frame) t_nrrdbranch = frame.transform_nrrdpath(testing_frame) t_runtimepath = frame.transform_runtimepath(testing_frame) fnames = apply.get_all_FieldTys(app) x = "_" + fnames + " |" + names writetys(x) name_describe = app.name print(name_describe + x) # testing positions positions = get_positions(dimF, g_lpos, g_upos, g_num_pos) #create synthetic field data with diderot flds = apply.get_all_Fields(app) # field operations is used if (app.opr.fieldop or app.lhs.opr.fieldop): return 2 if (fty.is_Tensor(app.oty)): return 2 for ff in flds: if (fty.is_Matrix(ff.fldty) or fty.is_Ten3(ff.fldty)): return 2 # limit to field output but can not support differentiation (isCompile, isRun, startall) = cfe_writeDiderot(g_p_Observ, app, positions, g_output, t_runtimepath, t_isNrrd, startall) PARAMS = "" if (isRun == None): if (isCompile == None): counter.inc_compile(cnt) rst_compile(names, x, name_describe, g_branch, positions, PARAMS) #raise Fail("does not compile") return 1 else: counter.inc_run(cnt) rst_execute(names, x, name_describe, g_branch, positions, PARAMS) #raise Fail("does not run") return 2 else: observed_data = observed(app, g_output) #print("observed:",observed_data) if (check(app, observed_data)): correct_data = eval(app, positions) #print("correct:",correct_data) ex_otype = fty.get_tensorType(app.oty) rtn = compare(app.oty, app.name, observed_data, correct_data) analyze(names, fnames, name_describe, cnt, rtn, observed_data, correct_data, positions, PARAMS, g_branch) return 3 else: return None
def cte_core(app, coeffs, dimF, names, testing_frame, cnt): endall = time.time() startall = time.time() # get global variables from testing framework g_lpos = frame.get_lpos(testing_frame) g_upos = frame.get_upos(testing_frame) g_num_pos = frame.get_num_pos(testing_frame) g_p_Observ = frame.get_p_Observ(testing_frame) g_output = frame.get_output(testing_frame) g_samples = frame.get_samples(testing_frame) g_branch = frame.get_branch(testing_frame) g_space = frame.get_space(testing_frame) # transform from global variables t_isNrrd = frame.transform_isNrrd(testing_frame) t_nrrdbranch = frame.transform_nrrdpath(testing_frame) t_runtimepath = frame.transform_runtimepath(testing_frame) fnames = apply.get_all_FieldTys(app) x = "_" + fnames + " |" + names writetys(x) name_describe = app.name # testing positions positions = get_positions(dimF, g_lpos, g_upos, g_num_pos) #create synthetic field data with diderot flds = apply.get_all_Fields(app) (PARAMS, all50, all51, all52, all53, all54, all55) = sortField(flds, g_samples, coeffs, t_nrrdbranch, g_space) #create diderot program with operator print(name_describe + x) (isCompile, isRun, startall) = cte_writeDiderot(g_p_Observ, app, positions, g_output, t_runtimepath, t_isNrrd, startall) print(" \n DATm: just called write diderot") if (isRun == None): if (isCompile == None): counter.inc_compile(cnt) rst_compile(names, x, name_describe, g_branch, positions, PARAMS) return 1 else: counter.inc_run(cnt) rst_execute(names, x, name_describe, g_branch, positions, PARAMS) return 2 else: print(" \n DATm: did not run") observed_data = observed(app, g_output) print(" \n DATm: observed", observed_data) if (check(app, observed_data)): print("nDATm: checked") correct_data = eval(app, positions) print("nDATm: correct:", correct_data) ex_otype = fty.get_tensorType(app.oty) rtn = compare(app.oty, app.name, observed_data, correct_data) analyze(names, fnames, name_describe, cnt, rtn, observed_data, correct_data, positions, PARAMS, g_branch) return 3 else: return None