当前位置: 首页>>代码示例>>Python>>正文


Python FORA.splitPausedComputation方法代码示例

本文整理汇总了Python中ufora.native.FORA.splitPausedComputation方法的典型用法代码示例。如果您正苦于以下问题:Python FORA.splitPausedComputation方法的具体用法?Python FORA.splitPausedComputation怎么用?Python FORA.splitPausedComputation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ufora.native.FORA的用法示例。


在下文中一共展示了FORA.splitPausedComputation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: randomSplitComputationTest

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
    def randomSplitComputationTest(self, text):
        if (isinstance(text, str)):
            funImplVal = FORA.extractImplValContainer(FORA.eval(text))
        else:
            funImplVal = text

        unsplitVal = callAndGetResult(funImplVal)

        splitAtLeastOne = False
        i = 0
        while (i < 3000):
            i += 1

            try:
                pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplVal, i)
            except NotInterruptedException as e:
                break


            splitComputation = ForaNative.splitPausedComputation(pausedComputation)

            unsplitVal2 = finishPausedComputation(pausedComputation)
            self.assertEqual(unsplitVal, unsplitVal2)

            if (splitComputation):
                splitAtLeastOne = True

                applyComputationVal = finishPausedComputation(splitComputation.applyComputation)
                splitComputationVal = finishPausedComputation(splitComputation.splitComputation)

                resumedComputation = ForaNative.joinSplitPausedComputation(
                    splitComputation,
                    applyComputationVal,
                    splitComputationVal
                    )

                finalSplitVal = finishPausedComputation(resumedComputation)

                self.assertEqual(unsplitVal, finalSplitVal)

        if (not splitAtLeastOne):
            logging.warn("didn't split any versions of `%s`\nafter i = %s tries" % (text, i))
开发者ID:Sandy4321,项目名称:ufora,代码行数:44,代码来源:ControlFlowGraphSplitter_test.py

示例2: test_cannotSplitThingsWithMutables

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
    def test_cannotSplitThingsWithMutables(self):
        text = """fun() {
            let s = fun(a,b,f) {
                if (b <= a)
                    return nothing
                if (b <= a + 1)
                    return f(a)

                let mid = Int64((a+b)/2)

                return s(a,mid,f) + s(mid,b,f)
                }
            let m = MutableVector.create(10,10);
            s(0,1000,fun(x){m[0] * x})
            }"""

        funImplval = FORA.extractImplValContainer(FORA.eval(text))

        i = 0
        while (i < 30000):
            i += 1000

            try:
                pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplval, i)
            except NotInterruptedException as e:
                break


            allAreCST = True
            for val in pausedComputation.frames[0].values:
                if not val.isCST():
                    allAreCST = False
                    break

            if not allAreCST:
                splitComputation = ForaNative.splitPausedComputation(pausedComputation)

                self.assertTrue(not splitComputation, splitComputation)
开发者ID:Sandy4321,项目名称:ufora,代码行数:40,代码来源:ControlFlowGraphSplitter_test.py

示例3: test_splitComputation_2

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
    def test_splitComputation_2(self):
        text = """fun() {
            let s = fun(a,b,f) {
                if (b <= a)
                    return nothing
                if (b <= a + 1)
                    return f(a)

                let mid = Int64((a+b)/2)

                return s(a,mid,f) + s(mid,b,f)
                }

            s(0,1000,fun(x){x})
            }"""

        funImplval = FORA.extractImplValContainer(FORA.eval(text))

        pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplval, 35)

        splitComputation = ForaNative.splitPausedComputation(pausedComputation)
        self.assertIsNotNone(splitComputation)

        unsplitValue = finishPausedComputation(pausedComputation)

        applyComputationVal = finishPausedComputation(splitComputation.applyComputation)
        splitComputationVal = finishPausedComputation(splitComputation.splitComputation)

        resumedComputation = ForaNative.joinSplitPausedComputation(
                splitComputation,
                applyComputationVal,
                splitComputationVal
                )

        finalSplitVal = finishPausedComputation(resumedComputation)

        self.assertEqual(unsplitValue, finalSplitVal)
开发者ID:Sandy4321,项目名称:ufora,代码行数:39,代码来源:ControlFlowGraphSplitter_test.py

示例4: test_splitComputation_1

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
    def test_splitComputation_1(self):
        text = """fun() {
            let s = fun(a,b,f) {
                if (b <= a)
                    return nothing
                if (b <= a + 1)
                    return f(a)

                let mid = Int64((a+b)/2)

                return s(a,mid,f) + s(mid,b,f)
                }
            let m = [0];
            s(0,1000,fun(x){m[0] * x})
            }"""

        funImplval = FORA.extractImplValContainer(FORA.eval(text))

        # minimum value to split seems to be 40
        pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplval, 40)

        splitComputation = ForaNative.splitPausedComputation(pausedComputation)

        self.assertTrue(splitComputation is not None)
开发者ID:Sandy4321,项目名称:ufora,代码行数:26,代码来源:ControlFlowGraphSplitter_test.py


注:本文中的ufora.native.FORA.splitPausedComputation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。