def __init__(self, numRandVals, numRelaxations, maxForRelax, maxForRand, testAxiomsPath, seed): object.__init__(self) self.callbackScheduler = CallbackScheduler.singletonForTesting() self.callbackSchedulerFactory = self.callbackScheduler.getFactory() self.numRandVals = numRandVals self.numRelaxations = numRelaxations self.maxForRelax = maxForRelax self.maxForRand = maxForRand self.seed = seed self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.typed_fora_compiler = self.runtime.getTypedForaCompiler() if testAxiomsPath is not None: pathToUse = testAxiomsPath else: pathToUse = UNIT_TEST_AXIOMS_PATH self.axiom_signatures_to_test = self.loadAxiomSignaturesFromFile(pathToUse) self.axiom_groups = [] for i in range(self.axioms.axiomCount): self.axiom_groups.append(self.axioms.getAxiomGroupByIndex(i)) self.symbol_strings = self.loadSymbolStrings() numpy.random.seed(seed)
def setUp(self): self.callbackScheduler = CallbackScheduler.singletonForTesting() self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.compiler = self.runtime.getTypedForaCompiler() self.builtinsAsJOV = FORANative.JudgmentOnValue.Constant( FORA.builtin().implVal_)
def test_extractPausedComputationDuringVectorLoad(self): self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager=vdm, allowInterpreterTracing=False) context.evaluate( FORA.extractImplValContainer(FORA.eval("fun() { [1,2,3].paged }")), FORANative.ImplValContainer(FORANative.makeSymbol("Call"))) pagedVec = context.getFinishedResult().asResult.result context.placeInEvaluationState( FORANative.ImplValContainer( (pagedVec, FORANative.ImplValContainer(FORANative.makeSymbol("GetItem")), FORANative.ImplValContainer(0)))) vdm.unloadAllPossible() context.resume() self.assertTrue(context.isVectorLoad()) computation = context.extractPausedComputation() self.assertEqual(len(computation.frames), 1)
def test_extractPausedComputationDuringVectorLoad(self): self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager = vdm, allowInterpreterTracing = False ) context.evaluate( FORA.extractImplValContainer(FORA.eval("fun() { [1,2,3].paged }")), FORANative.ImplValContainer(FORANative.makeSymbol("Call")) ) pagedVec = context.getFinishedResult().asResult.result context.placeInEvaluationState( FORANative.ImplValContainer( (pagedVec, FORANative.ImplValContainer(FORANative.makeSymbol("GetItem")), FORANative.ImplValContainer(0)) ) ) vdm.unloadAllPossible() context.resume() self.assertTrue(context.isVectorLoad()) computation = context.extractPausedComputation() self.assertEqual(len(computation.frames),1)
def test_resumePausedComputationWithResult(self): self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager=vdm, allowInterpreterTracing=False, allowInternalSplitting=False) text = """ let f = fun(v, ix) { if (ix > 0) { let (v2,res) = f(v,ix-1); return (v2, res + v2[0]) } `TriggerInterruptForTesting() return (v, 0) }; f([1], 10) """ evaluate( context, FORA.extractImplValContainer(FORA.eval("fun() { " + text + " }")), FORANative.ImplValContainer(FORANative.makeSymbol("Call"))) assert context.isInterrupted() pausedComp = context.extractPausedComputation() framesToUse = pausedComp.asThread.computation.frames[0:5] pausedComp2 = FORANative.PausedComputationTree( FORANative.PausedComputation( framesToUse, FORA.extractImplValContainer( FORA.eval("([2], 0)", keepAsForaValue=True)), False)) context.resumePausedComputation(pausedComp2) context.copyValuesOutOfVectorPages() context.pageLargeVectorHandles(0) context.resetInterruptState() context.compute() self.assertTrue(context.isFinished()) result = context.getFinishedResult() self.assertTrue(result.asResult.result[1].pyval == 6)
def test_resumePausedComputationWithResult(self): self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager = vdm, allowInterpreterTracing = False ) text = """ let f = fun(v, ix) { if (ix > 0) { let (v2,res) = f(v,ix-1); return (v2, res + v2[0]) } `TriggerInterruptForTesting() return (v, 0) }; f([1], 10) """ context.evaluate( FORA.extractImplValContainer(FORA.eval("fun() { " + text + " }")), FORANative.ImplValContainer(FORANative.makeSymbol("Call")) ) assert context.isInterrupted() pausedComp = context.extractPausedComputation() framesToUse = pausedComp.frames[0:5] pausedComp2 = FORANative.PausedComputation( framesToUse, FORA.extractImplValContainer(FORA.eval("([2], 0)", keepAsForaValue=True)), False ) context.resumePausedComputation(pausedComp2) context.copyValuesOutOfVectorPages() context.pageLargeVectorHandles(0) context.resetInterruptState() context.resume() self.assertTrue( context.isFinished() ) result = context.getFinishedResult() self.assertTrue(result.asResult.result[1].pyval == 6)
def testMatchStructureCantMatchTooSmallTuple(self): runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() jov = FORANative.parseStringToJOV("((1,2,3),`StructureMatch,((nothing, false), (nothing, false), (nothing, false), (nothing, false)))") axiom = axioms.getAxiomByJOVT(runtime.getTypedForaCompiler(), jov.asTuple.jov) self.assertTrue(list(axiom.asNative.resultSignature.resultPart().vals) == [FORANative.parseStringToJOV("nothing")])
def testAxiomLookups(self): axioms = Runtime.getMainRuntime().getAxioms() jmtsToTest = [axiom.signature() for axiom in axioms] for tupJmt in jmtsToTest: self.assertEqual( axioms.axiomSearchLinear(tupJmt), axioms.axiomSearchTree(tupJmt), "Didn't produce same results for %s" % str(tupJmt))
def runSimpleEvaluation(self, inputType, outputType): mainRuntime = Runtime.getMainRuntime() foraCompiler = mainRuntime.getTypedForaCompiler() while foraCompiler.anyCompilingOrPending(): time.sleep(.01) aParticularStringValue = ForaNative.ImplValContainer(aBigString) callable = self.generateSimpleCallable(inputType, outputType) jumpTarget = foraCompiler.compile(callable) import gc gc.collect() for passIndex in range(PASS_COUNT): #type values are memoized, so we can't assume that the value has a refcount # of exactly one totalStringCount = ForaNative.totalStringCount() totalImplvalCount = ForaNative.totalImplvalCount() anExecutionContext = ExecutionContext.ExecutionContext( dataManager = VectorDataManager.constructVDM(self.callbackScheduler) ) anExecutionContext.evaluateFunctionPointer(jumpTarget, aParticularStringValue) self.assertTrue(anExecutionContext.isFinished()) res = anExecutionContext.getFinishedResult() self.assertTrue(not res.isException()) self.assertEqual(res.asResult.result, aParticularStringValue) anExecutionContext.teardown() res = None #verify final refcounts self.assertEqual( aParticularStringValue.getStringObjectRefcount(), 1, "refcounts weren't maintained in %s->%s. %s != 1" % ( inputType, outputType, aParticularStringValue.getStringObjectRefcount() ) ) self.assertEqual( (totalStringCount, totalImplvalCount), (ForaNative.totalStringCount(), ForaNative.totalImplvalCount()), "refcounts weren't maintained in " + str(inputType) + "->" + str(outputType) )
def main(argv): t0 = time.time() Runtime.initialize(Setup.defaultSetup()) runtime = Runtime.getMainRuntime() handler = runtime.getInterpreterTraceHandler() handler.replayTracesFromFile(argv[1]) print "took ", time.time() - t0
def triggerCompilation(self, *args): runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() compiler = runtime.getTypedForaCompiler() instructionGraph = runtime.getInstructionGraph() reasoner = ForaNative.SimpleForwardReasoner(compiler, instructionGraph, axioms) frame = reasoner.reasonAboutComputationDefinition(self.cumulusComputationDefinition) logging.critical("Result was %s", frame.exits())
def testAxiomLookups(self): axioms = Runtime.getMainRuntime().getAxioms() jmtsToTest = [axiom.signature() for axiom in axioms] for tupJmt in jmtsToTest: self.assertEqual( axioms.axiomSearchLinear(tupJmt), axioms.axiomSearchTree(tupJmt), "Didn't produce same results for %s" % str(tupJmt) )
def setUp(self): self.callbackScheduler = CallbackScheduler.singletonForTesting() self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.compiler = self.runtime.getTypedForaCompiler() self.builtinsAsJOV = FORANative.JudgmentOnValue.Constant(FORA.builtin().implVal_) pyforaPath = os.path.join(os.path.split(pyfora.__file__)[0], "fora/purePython") self.purePythonAsJOV = FORANative.JudgmentOnValue.Constant(FORA.importModule(pyforaPath).implVal_) self.instructionGraph = self.runtime.getInstructionGraph() self.reasoner = FORANative.SimpleForwardReasoner(self.compiler, self.instructionGraph, self.axioms)
def reasonAboutForaCode(module, testName): if reasoner[0] is None: runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() compiler = runtime.getTypedForaCompiler() reasoner[0] = ForaNative.SimpleForwardReasoner(compiler, axioms, False) moduleJOV = ForaNative.JudgmentOnValue.Constant(module.implVal_) frame = reasoner[0].reason(makeJovt(moduleJOV, symbolJov("Member"), symbolJov(testName))) dumpReasonerSummary(reasoner[0], frame) return True
def triggerCompilation(self, *args): runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() compiler = runtime.getTypedForaCompiler() instructionGraph = runtime.getInstructionGraph() reasoner = ForaNative.SimpleForwardReasoner(compiler, instructionGraph, axioms) frame = reasoner.reasonAboutComputationDefinition( self.cumulusComputationDefinition) logging.critical("Result was %s", frame.exits())
def runSimpleEvaluation(self, inputType, outputType): mainRuntime = Runtime.getMainRuntime() foraCompiler = mainRuntime.getTypedForaCompiler() while foraCompiler.anyCompilingOrPending(): time.sleep(.01) aParticularStringValue = ForaNative.ImplValContainer(aBigString) callable = self.generateSimpleCallable(inputType, outputType) jumpTarget = foraCompiler.compile(callable) import gc gc.collect() for passIndex in range(PASS_COUNT): #type values are memoized, so we can't assume that the value has a refcount # of exactly one totalStringCount = ForaNative.totalStringCount() totalImplvalCount = ForaNative.totalImplvalCount() anExecutionContext = ExecutionContext.ExecutionContext( dataManager=VectorDataManager.constructVDM( self.callbackScheduler)) anExecutionContext.evaluateFunctionPointer(jumpTarget, aParticularStringValue) self.assertTrue(anExecutionContext.isFinished()) res = anExecutionContext.getFinishedResult() self.assertTrue(not res.isException()) self.assertEqual(res.asResult.result, aParticularStringValue) anExecutionContext.teardown() res = None #verify final refcounts self.assertEqual( aParticularStringValue.getStringObjectRefcount(), 1, "refcounts weren't maintained in %s->%s. %s != 1" % (inputType, outputType, aParticularStringValue.getStringObjectRefcount())) self.assertEqual((totalStringCount, totalImplvalCount), (ForaNative.totalStringCount(), ForaNative.totalImplvalCount()), "refcounts weren't maintained in " + str(inputType) + "->" + str(outputType))
def testMatchStructureCantMatchTooSmallTuple(self): runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() jov = FORANative.parseStringToJOV( "((1,2,3),`StructureMatch,((nothing, false), (nothing, false), (nothing, false), (nothing, false)))" ) axiom = axioms.getAxiomByJOVT(runtime.getTypedForaCompiler(), jov.asTuple.jov) self.assertTrue( list(axiom.asNative.resultSignature.resultPart().vals) == [FORANative.parseStringToJOV("nothing")])
def reasonAboutForaCode(module, testName): if reasoner[0] is None: runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() compiler = runtime.getTypedForaCompiler() reasoner[0] = ForaNative.SimpleForwardReasoner(compiler, axioms, False) moduleJOV = ForaNative.JudgmentOnValue.Constant(module.implVal_) frame = reasoner[0].reason( makeJovt(moduleJOV, symbolJov("Member"), symbolJov(testName))) dumpReasonerSummary(reasoner[0], frame) return True
def setUp(self): self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.native_runtime = self.runtime.getTypedForaCompiler() symbol_strings_set = Set() self.symbol_strings = [] for i in range(self.axioms.axiomCount): sig = str(self.axioms.getAxiomGroupByIndex(i).signature()) for j in [l.strip(' ') for l in sig.strip("()").split(',')]: if re.search('^`', j): if j not in symbol_strings_set: symbol_strings_set.add(j) self.symbol_strings.append(j.strip('`'))
def test_extractStacktrace(self): text = """fun() { let x = 0; let v = [1,2,3] while (x < 100000) { x = x + 1 } (x,v) }""" self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager = vdm, allowInterpreterTracing = False ) context.interruptAfterCycleCount(1000) context.evaluate( FORA.extractImplValContainer(FORA.eval(text)), FORANative.symbol_Call ) trace = context.extractStacktrace(True) self.assertTrue(len(trace) == 1) stacktrace = trace[0][0] frameData = trace[0][1] codeLocation = FORANative.getCodeLocation(stacktrace.getIDs()[0]) self.assertTrue(codeLocation is not None) self.assertTrue(frameData.wasCompiled is False) self.assertTrue(len(frameData.inScopeValues) == 2) self.assertTrue([str(x) for x in frameData.inScopeValues.keys] == ['x', 'v']) values = [frameData.inScopeValues[x] for x in frameData.inScopeValues.keys] self.assertTrue(values[0].isInt64()) self.assertTrue(values[1].isVector()) context.teardown()
def reasonAboutForaCode(module, moduleName, testName): if reasoner[0] is None: runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() compiler[0] = runtime.getTypedForaCompiler() instructionGraph = runtime.getInstructionGraph() reasoner[0] = ForaNative.SimpleForwardReasoner(compiler[0], instructionGraph, axioms) moduleJOV = ForaNative.JudgmentOnValue.Constant(module.implVal_) t0 = time.time() frame = reasoner[0].reasonAboutApply(makeJovt(moduleJOV, symbolJov("Member"), symbolJov(testName))) print "reasoning ", moduleName + "." + testName, " took ", time.time() - t0 dumpReasonerSummary(moduleName, testName, reasoner[0], frame) return True
def test_extractStacktrace(self): text = """fun() { let x = 0; let v = [1,2,3] while (x < 100000) { x = x + 1 } (x,v) }""" self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager=vdm, allowInterpreterTracing=False) context.interruptAfterCycleCount(1000) context.evaluate(FORA.extractImplValContainer(FORA.eval(text)), FORANative.symbol_Call) trace = context.extractStacktrace(True) self.assertTrue(len(trace) == 1) stacktrace = trace[0][0] frameData = trace[0][1] codeLocation = FORANative.getCodeLocation(stacktrace.getIDs()[0]) self.assertTrue(codeLocation is not None) self.assertTrue(frameData.wasCompiled is False) self.assertTrue(len(frameData.inScopeValues) == 2) self.assertTrue([str(x) for x in frameData.inScopeValues.keys] == ['x', 'v']) values = [ frameData.inScopeValues[x] for x in frameData.inScopeValues.keys ] self.assertTrue(values[0].isInt64()) self.assertTrue(values[1].isVector()) context.teardown()
def setUp(self): self.callbackScheduler = CallbackScheduler.singletonForTesting() self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.native_runtime = self.runtime.getTypedForaCompiler() self.vals_to_test = self.loadValuesFromFile(os.path.join(os.path.split(__file__)[0], "AxiomJOA_test.txt")) self.evaluator = LocalEvaluator.LocalEvaluator( lambda vdm: CumulusNative.SimpleOfflineCache(self.callbackScheduler, 1000000000), 10000000, maxPageSizeInBytes = 100000 ) self.oldEvaluator = Evaluator.swapEvaluator(self.evaluator) self.knownModulesAsConstantJOVs = dict() self.knownModulesAsConstantJOVs["builtin"] = \ FORANative.JudgmentOnValue.Constant(FORA.builtin().implVal_)
def setUp(self): self.callbackScheduler = CallbackScheduler.singletonForTesting() self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.native_runtime = self.runtime.getTypedForaCompiler() self.vals_to_test = self.loadValuesFromFile( os.path.join(os.path.split(__file__)[0], "AxiomJOA_test.txt")) self.evaluator = LocalEvaluator.LocalEvaluator( lambda vdm: CumulusNative.SimpleOfflineCache( self.callbackScheduler, 1000000000), 10000000, maxPageSizeInBytes=100000) self.oldEvaluator = Evaluator.swapEvaluator(self.evaluator) self.knownModulesAsConstantJOVs = dict() self.knownModulesAsConstantJOVs["builtin"] = \ FORANative.JudgmentOnValue.Constant(FORA.builtin().implVal_)
def runSimpleEvaluation(self, callable, arguments, validator): mainRuntime = Runtime.getMainRuntime() foraCompiler = mainRuntime.getTypedForaCompiler() jumpTarget = foraCompiler.compile(callable) while foraCompiler.anyCompilingOrPending(): time.sleep(.01) gc.collect() for passIndex in range(PASS_COUNT): totalStringCount = ForaNative.totalStringCount() totalImplvalCount = ForaNative.totalImplvalCount() anExecutionContext = ExecutionContext.ExecutionContext( dataManager = VectorDataManager.constructVDM(self.callbackScheduler) ) anExecutionContext.evaluateFunctionPointer(jumpTarget, *arguments) self.assertTrue(anExecutionContext.isFinished()) res = anExecutionContext.getFinishedResult() self.assertTrue(validator(res.asResult.result), "invalid result in " + str(callable) + " with " + str(arguments) + ". got " + str(res) ) res = None anExecutionContext.teardown() curRefs = (ForaNative.totalStringCount(), ForaNative.totalImplvalCount()) self.assertEqual( (totalStringCount, totalImplvalCount), curRefs, "refcounts weren't maintained in " + str(callable) + " with " + str(arguments) + ". %s != %s" % ( (totalStringCount, totalImplvalCount), curRefs ) )
def test_extractPausedComputation(self): text = """fun() { let x = 0; while (x < 100000) x = x + 1 x }""" self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager = vdm, allowInterpreterTracing = False ) context.interruptAfterCycleCount(1010) context.evaluate( FORA.extractImplValContainer(FORA.eval(text)), FORANative.symbol_Call ) computation = context.extractPausedComputation() self.assertEqual(len(computation.frames), 2) self.assertEqual(computation.frames[1].values[0].pyval, 335) context2 = ExecutionContext.ExecutionContext( dataManager = vdm, allowInterpreterTracing = False ) context2.resumePausedComputation(computation) context2.resume() self.assertEqual(context2.getFinishedResult().asResult.result.pyval, 100000) context.teardown() context2.teardown()
def reasonAboutForaCode(module, moduleName, testName): if reasoner[0] is None: runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() compiler[0] = runtime.getTypedForaCompiler() instructionGraph = runtime.getInstructionGraph() reasoner[0] = ForaNative.SimpleForwardReasoner(compiler[0], instructionGraph, axioms) moduleJOV = ForaNative.JudgmentOnValue.Constant(module.implVal_) t0 = time.time() frame = reasoner[0].reasonAboutApply( makeJovt(moduleJOV, symbolJov("Member"), symbolJov(testName))) print "reasoning ", moduleName + "." + testName, " took ", time.time() - t0 dumpReasonerSummary(moduleName, testName, reasoner[0], frame) return True
def test_extractPausedComputation(self): text = """fun() { let x = 0; while (x < 100000) x = x + 1 x }""" self.runtime = Runtime.getMainRuntime() #self.dynamicOptimizer = self.runtime.dynamicOptimizer vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes) context = ExecutionContext.ExecutionContext( dataManager=vdm, allowInterpreterTracing=False) context.interruptAfterCycleCount(1010) context.evaluate(FORA.extractImplValContainer(FORA.eval(text)), FORANative.symbol_Call) computation = context.extractPausedComputation() self.assertEqual(len(computation.frames), 2) self.assertEqual(computation.frames[1].values[0].pyval, 335) context2 = ExecutionContext.ExecutionContext( dataManager=vdm, allowInterpreterTracing=False) context2.resumePausedComputation(computation) context2.resume() self.assertEqual(context2.getFinishedResult().asResult.result.pyval, 100000) context.teardown() context2.teardown()
def setUp(self): self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.native_runtime = self.runtime.getTypedForaCompiler() self.vdm = FORANative.VectorDataManager(CallbackScheduler.singletonForTesting(), 10000000)
def setUp(self): self.callbackScheduler = CallbackScheduler.singletonForTesting() self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.compiler = self.runtime.getTypedForaCompiler() self.builtinsAsJOV = FORANative.JudgmentOnValue.Constant(FORA.builtin().implVal_)
def main(argv): fora.init_local() runtime = Runtime.getMainRuntime() handler = runtime.getInterpreterTraceHandler() handler.replayTracesFromFile(argv[1])
def setUp(self): self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.compiler = self.runtime.getTypedForaCompiler()
# See the License for the specific language governing permissions and # limitations under the License. """ rebuildAxiomSearchFunction Generate appropriate axiom build functions after we've built the project successfully. """ import os import ufora import ufora.config.Setup as Setup import ufora.FORA.python.Runtime as Runtime Runtime.initialize(Setup.defaultSetup()) axioms = Runtime.getMainRuntime().getAxioms() implvalCode, jovtCode = axioms.getCppWrapperCode() uforaDir = os.path.split(os.path.abspath(ufora.__file__))[0] with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py" print >> f, implvalCode with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch2.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py" print >> f, jovtCode
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Run this script to generate a file of axiom signatures which can be fed into Axioms_consistency_test.py. This generates all axioms, but by default comments them all out. Uncomment the ones you want to test. """ import ufora.native import ufora.FORA.python.Runtime as Runtime import ufora.native.FORA as FORANative import os dir = os.path.dirname(__file__) AXIOMS_TO_TEST_FILENAME = os.path.join(dir, "AXIOMS_TO_TEST.txt") runtime = Runtime.getMainRuntime() axioms = runtime.getAxioms() readme_string = '"""\nThis file lists all the axioms we would like to check for consistency in\nAxioms_consistency_test.py. It supports basic python-like commenting\n"""\n\n' with open(AXIOMS_TO_TEST_FILENAME, "w") as f: f.write(readme_string) f.write('"""\n') for i in range(axioms.axiomCount): f.write("%s\n" %axioms.getAxiomGroupByIndex(i).signature()) f.write('"""')
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ rebuildAxiomSearchFunction Generate appropriate axiom build functions after we've built the project successfully. """ import os import ufora import ufora.config.Setup as Setup import ufora.FORA.python.Runtime as Runtime Runtime.initialize(Setup.defaultSetup()) axioms = Runtime.getMainRuntime().getAxioms() implvalCode, jovtCode = axioms.getCppWrapperCode() uforaDir = os.path.split(os.path.abspath(ufora.__file__))[0] with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py" print >> f, implvalCode with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch2.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py" print >> f, jovtCode
def setUp(self): self.runtime = Runtime.getMainRuntime() self.axioms = self.runtime.getAxioms() self.native_runtime = self.runtime.getTypedForaCompiler() self.vdm = FORANative.VectorDataManager( CallbackScheduler.singletonForTesting(), 10000000)