Пример #1
0
def test_task_groups_barrier(file_name):

    with TaskGroup('bigGroup2', True):
        # Inside a big group, more groups are created
        for i in range(NUM_GROUPS):
            with (TaskGroup('group' + str(i + 4), True)):
                for j in range(NUM_TASKS):
                    write_one(file_name)

    # Creation of group
    with TaskGroup('individualGroup2', True):
        for i in range(NUM_TASKS):
            write_two(file_name)
Пример #2
0
def test_task_groups():
    num_tasks = 3
    num_groups = 3
    results = []
    with TaskGroup("bigGroup", True):
        # Inside a big group, more groups are created
        for i in range(num_groups):
            with(TaskGroup("group" + str(i), False)):
                for j in range(num_tasks):
                    results.append(increment(i))

    # Barrier for groups
    for i in range(num_groups):
        compss_barrier_group("group" + str(i))
Пример #3
0
 def test_mpi(self):
     group_name = "mpi"
     try:
         with TaskGroup(group_name):
             cancel_mpi()
             exception_task()
     except COMPSsException as e:
         print("Captured compss exception" + str(e))
Пример #4
0
def test_exceptions_barrier_error(file_name):
    group_name = 'exceptionGroup3'
    # Creation of group
    with TaskGroup(group_name, False):
        for i in range(NUM_TASKS):
            write_three(file_name)

    # The barrier is not implicit and the exception is thrown
    compss_barrier_group(group_name)
Пример #5
0
def test_exceptions(file_name):
    try:
        # Creation of group
        with TaskGroup('exceptionGroup1'):
            for i in range(NUM_TASKS):
                write_three(file_name)
    except COMPSsException:
        print("COMPSsException caught")
        write_two(file_name)
    write_one(file_name)
Пример #6
0
 def testReturnFailTrue_exit1(self):
     group_name = "binary"
     fail = False
     try:
         with TaskGroup(group_name, implicit_barrier=True):
             string_param = "This is a string. 1"
             exit_value = checkStringParam1(string_param)
             exit_value = compss_wait_on(exit_value)
         fail = True
     except Exception as e:
         print("Captured compss exception" + str(e))
     if fail:
         raise Exception
Пример #7
0
def test_exceptions_barrier(file_name):
    group_name = 'exceptionGroup2'
    # Creation of group
    with TaskGroup(group_name, False):
        for i in range(NUM_TASKS):
            write_three(file_name)
    try:
        # The barrier is not implicit and the exception is thrown
        compss_barrier_group(group_name)
    except COMPSsException:
        print("COMPSsException caught")
        write_two(file_name)
    write_one(file_name)
Пример #8
0
def test_cancellation(file_name):
    try:
        # Creation of group
        with TaskGroup('failedGroup'):
            long_task(file_name)
            long_task(file_name)
            executed_task(file_name)
            throw_exception(file_name)
            cancelled_task(file_name)
            cancelled_task(file_name)
    except COMPSsException:
        print("COMPSsException caught")
        write_two(file_name)
    write_two(file_name)
Пример #9
0
    def test_7_scale_down_and_notify(self):
        # Launch task and decrease resources
        num_resources = 1
        group_name = "decrease"
        with TaskGroup(group_name):
            waiter_task()
            time.sleep(1)
            compss_free_resources(num_resources, group_name)

        # The implicit barrier of the group will wait until my_task is cancelled by the resources notification

        # Resource mechanisms are already checked by other methods (the runtime here can destroy machines
        # because a core element is created so we don't really know how many resources there will be.

        # Result script must check that task was cancelled
        print("Result script must check that task was cancelled")
Пример #10
0
def test_cancellation_no_implicit_barrier(file_name):
    # Creation of group
    with TaskGroup('failedGroup2', False):
        long_task(file_name)
        long_task(file_name)
        executed_task(file_name)
        throw_exception(file_name)
        cancelled_task(file_name)
        cancelled_task(file_name)
    try:
        # The barrier is not implicit and the exception is thrown
        compss_barrier_group('failedGroup2')
    except COMPSsException:
        print("COMPSsException caught")
        write_two(file_name)
    write_two(file_name)
Пример #11
0
def test_dummy_api():
    from pycompss.api.dummy.api import compss_start
    from pycompss.api.dummy.api import compss_stop
    from pycompss.api.dummy.api import compss_file_exists
    from pycompss.api.dummy.api import compss_open
    from pycompss.api.dummy.api import compss_delete_file
    from pycompss.api.dummy.api import compss_wait_on_file
    from pycompss.api.dummy.api import compss_wait_on_directory
    from pycompss.api.dummy.api import compss_delete_object
    from pycompss.api.dummy.api import compss_barrier
    from pycompss.api.dummy.api import compss_barrier_group
    from pycompss.api.dummy.api import compss_wait_on
    from pycompss.api.dummy.api import compss_get_number_of_resources
    from pycompss.api.dummy.api import compss_request_resources
    from pycompss.api.dummy.api import compss_free_resources
    from pycompss.api.dummy.api import TaskGroup

    file_name = "simulated_file.txt"
    file_names = ["simulated_file1.txt", "simulated_file2.txt"]
    directory_name = "simulated_directory"
    directory_names = ["simulated_directory1", "simulated_directory2"]
    group_name = "simulated_group"
    obj = [1, 2, 3]
    num_resources = 1

    with open(file_name, "w") as f:
        f.write("some content")
    os.mkdir(directory_name)

    for f_name in file_names:
        with open(f_name, "w") as f:
            f.write("some content")
    for d_name in directory_names:
        os.mkdir(d_name)

    compss_start(log_level="off", interactive=False)
    compss_stop(code=0)
    compss_file_exists(file_name)
    compss_file_exists(*file_names)
    compss_open(file_name, mode="r")
    compss_delete_file(file_name)
    compss_delete_file(*file_names)
    compss_wait_on_file(file_name)
    compss_wait_on_file(*file_names)
    compss_wait_on_directory(directory_name)
    compss_wait_on_directory(*directory_names)
    compss_delete_object(obj)
    compss_delete_object(*obj)
    compss_barrier(no_more_tasks=False)
    compss_barrier_group(group_name)
    compss_wait_on(obj)
    compss_wait_on(*obj)
    compss_get_number_of_resources()
    compss_request_resources(num_resources, group_name)
    compss_free_resources(num_resources, group_name)

    with TaskGroup(group_name, implicit_barrier=True):
        # Empty task group check
        pass

    os.remove(file_name)
    os.rmdir(directory_name)

    for f_name in file_names:
        os.remove(f_name)
    for d_name in directory_names:
        os.rmdir(d_name)