From b86e13bf9018015fae268e5f15694a17e08fc6ac Mon Sep 17 00:00:00 2001 From: Kelsey Shan Date: Tue, 24 Sep 2024 22:25:54 -0700 Subject: [PATCH 1/2] Create ParallelizabilityInfoGeneratorCustom.py --- .../ParallelizabilityInfoGeneratorCustom.py | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 pash_annotations/annotation_generation/annotation_generators/ParallelizabilityInfoGeneratorCustom.py diff --git a/pash_annotations/annotation_generation/annotation_generators/ParallelizabilityInfoGeneratorCustom.py b/pash_annotations/annotation_generation/annotation_generators/ParallelizabilityInfoGeneratorCustom.py new file mode 100644 index 0000000..0dcbde3 --- /dev/null +++ b/pash_annotations/annotation_generation/annotation_generators/ParallelizabilityInfoGeneratorCustom.py @@ -0,0 +1,74 @@ +from pash_annotations.annotation_generation.annotation_generators.ParallelizabilityInfoGenerator_Interface import ParallelizabilityInfoGeneratorInterface +from pash_annotations.annotation_generation.datatypes.parallelizability.Parallelizer import \ + AdditionalInfoSplitterToMapper, make_parallelizer_round_robin, make_parallelizer_consec_chunks +from pash_annotations.annotation_generation.datatypes.parallelizability.MapperSpec import make_mapper_spec_custom +from pash_annotations.annotation_generation.datatypes.parallelizability.AggregatorSpec import \ + make_aggregator_spec_custom_2_ary_from_string_representation + + +class ParallelizabilityInfoGeneratorGrep(ParallelizabilityInfoGeneratorInterface): + + #base case with grep parallelizability info + def generate_info(self) -> None: + mapper_spec = None + aggregator_spec = None + add_info_from_splitter = None + + if (mapper_spec is None or mapper_spec.is_implemented) and \ + (aggregator_spec is None or aggregator_spec.is_implemented): + parallelizer_cc = make_parallelizer_consec_chunks(mapper_spec=mapper_spec, + aggregator_spec=aggregator_spec, + info_splitter_mapper=add_info_from_splitter) + self.append_to_parallelizer_list(parallelizer_cc) + parallelizer_rr = make_parallelizer_round_robin(mapper_spec=mapper_spec, + aggregator_spec=aggregator_spec, + info_splitter_mapper=add_info_from_splitter) + self.append_to_parallelizer_list(parallelizer_rr) + + + +"""" +from pash_annotations.annotation_generation.annotation_generators.ParallelizabilityInfoGenerator_Interface import ParallelizabilityInfoGeneratorInterface +from pash_annotations.annotation_generation.datatypes.parallelizability.AggregatorSpec import \ + make_aggregator_spec_custom_2_ary_from_string_representation +from pash_annotations.annotation_generation.datatypes.parallelizability.MapperSpec import \ + make_mapper_spec_custom_from_string_representation +from pash_annotations.annotation_generation.datatypes.parallelizability.Parallelizer import make_parallelizer_round_robin, \ + make_parallelizer_consec_chunks +from pash_annotations.annotation_generation.datatypes.parallelizability.Parallelizer import Parallelizer +from pash_annotations.annotation_generation.datatypes.parallelizability.AggregatorSpec import \ + make_aggregator_spec_custom_n_ary_from_string_representation + +class ParallelizabilityInfoGeneratorCustom(ParallelizabilityInfoGeneratorInterface): + # info to provide: parallelizer_list, round_robin_comp_with_cat, is_commutative (for optimisations) + # parallelizabilityinfo has to-do to remove round_robin_comp_with_cat? + + def generate_info(self, parallelizer_list:Parallelizer, round_robin_comp_with_cat:bool, is_commutative:bool, aggregator_spec:str) -> None: + if is_commutative: + self.parallelizability_info.set_commutative() + #mapper spec? + #mapper_spec = make_mapper_spec_custom_from_string_representation("alt_bigrams_aux", is_implemented=True) + + if (mapper_spec is None or mapper_spec.is_implemented) and \ + (aggregator_spec is None or aggregator_spec.is_implemented): + parallelizer_cc = make_parallelizer_consec_chunks(mapper_spec=mapper_spec, + aggregator_spec=aggregator_spec, + info_splitter_mapper=add_info_from_splitter) + self.append_to_parallelizer_list(parallelizer_cc) + parallelizer_rr = make_parallelizer_round_robin(mapper_spec=mapper_spec, + aggregator_spec=aggregator_spec, + info_splitter_mapper=add_info_from_splitter) + self.append_to_parallelizer_list(parallelizer_rr) + if round_robin_comp_with_cat: + aggregator_spec_custom_rr = make_aggregator_spec_custom_2_ary_from_string_representation(aggregator_spec, + is_implemented=False) + parallelizer_rr = make_parallelizer_round_robin(mapper_spec=None, + aggregator_spec=aggregator_spec_custom_rr, + info_splitter_mapper=None) + self.append_to_parallelizer_list(parallelizer_rr) + + #how should the parallelizability info generator handle aggregators, i.e taking in file + agg_spec_custom_cc = make_aggregator_spec_custom_n_ary_from_string_representation(aggregator_spec) + parallelizer_cc = make_parallelizer_consec_chunks(aggregator_spec = agg_spec_custom_cc) + self.parallelizability_info.append_to_parallelizer_list(parallelizer_cc) +""" \ No newline at end of file From c51c8618faba0c1d91760f82db8034d1a199e122 Mon Sep 17 00:00:00 2001 From: Kelsey Shan Date: Tue, 24 Sep 2024 22:30:41 -0700 Subject: [PATCH 2/2] Create InputOutputInfoGeneratorCustom.py --- .../InputOutputInfoGeneratorCustom.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pash_annotations/annotation_generation/annotation_generators/InputOutputInfoGeneratorCustom.py diff --git a/pash_annotations/annotation_generation/annotation_generators/InputOutputInfoGeneratorCustom.py b/pash_annotations/annotation_generation/annotation_generators/InputOutputInfoGeneratorCustom.py new file mode 100644 index 0000000..16f8034 --- /dev/null +++ b/pash_annotations/annotation_generation/annotation_generators/InputOutputInfoGeneratorCustom.py @@ -0,0 +1,22 @@ +from pash_annotations.annotation_generation.annotation_generators.InputOutputInfoGenerator_Interface import InputOutputInfoGeneratorInterface +from pash_annotations.datatypes.BasicDatatypes import Operand + + +class InputOutputInfoGeneratorGrep(InputOutputInfoGeneratorInterface): + + def generate_info(self) -> None: + #no flags case + self.set_implicit_use_of_stdout() + """ + if self.does_flag_option_list_contain_at_least_one_of(["-e", "-f"]): + if self.get_operand_list_length() == 0: + self.set_implicit_use_of_stdin() + else: + self.all_operands_are_streaming_inputs() # this is true also if empty + """ + #else: + self.set_first_operand_as_config_arg_type_string() + if self.get_operand_list_length() == 1: + self.set_implicit_use_of_stdin() + else: + self.all_but_first_operand_is_streaming_input()