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)
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)
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))
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)
def test_task_groups(file_name): 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): write_one(file_name) # Barrier for groups for i in range(NUM_GROUPS): compss_barrier_group('group' + str(i)) # Creation of group with TaskGroup('individualGroup', True): for i in range(NUM_TASKS): write_two(file_name)
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)