|
23 | 23 |
|
24 | 24 | from typing import List |
25 | 25 |
|
| 26 | +from log.log import Log |
| 27 | + |
26 | 28 |
|
27 | 29 | class WrapperDirector: |
28 | 30 | """ |
@@ -720,7 +722,7 @@ def build_job_thread(self): |
720 | 722 | return textwrap.dedent(""" """) |
721 | 723 | # horizontal and hybrids |
722 | 724 | def build_nodes_list(self): |
723 | | - return self.get_nodes() + self.build_cores_list() |
| 725 | + return self.build_cores_list() |
724 | 726 |
|
725 | 727 | def get_nodes(self): |
726 | 728 | return textwrap.dedent(f""" |
@@ -907,9 +909,9 @@ def build_srun_launcher(self, jobs_list, footer=True): |
907 | 909 | return srun_launcher |
908 | 910 |
|
909 | 911 | def build_main(self): |
910 | | - nodelist = self.build_nodes_list() |
| 912 | + #nodelist = self.build_nodes_list() |
911 | 913 | srun_launcher = self.build_srun_launcher("scripts") |
912 | | - return nodelist + srun_launcher |
| 914 | + return srun_launcher |
913 | 915 |
|
914 | 916 | class SrunVerticalHorizontalWrapperBuilder(SrunWrapperBuilder): |
915 | 917 | def build_imports(self): |
@@ -953,21 +955,42 @@ def build_imports(self): |
953 | 955 | job_mask = job_mask + thr_mask |
954 | 956 | srun_mask_values.append(str(hex(job_mask))) |
955 | 957 | if job_id > 0: |
956 | | - core[0]=core[0] << int(n_threads) |
| 958 | + core[0]=core[0] << int(n_threads) |
957 | 959 | else: |
958 | | - core[0]=job_mask+0x1 |
| 960 | + core[0]=job_mask+0x1 |
959 | 961 |
|
960 | 962 | mask_array = "( " |
961 | 963 | for mask in srun_mask_values: |
962 | 964 | mask_array += str("\"" + mask + "\"") + " " |
963 | 965 | mask_array += ")" |
964 | 966 | scripts_bash += textwrap.dedent(""" |
| 967 | + # Enable debugging and exit on error |
| 968 | + set -xe |
965 | 969 | declare -a job_mask_array={0} |
966 | 970 | """).format(mask_array, '\n'.ljust(13)) |
967 | | - |
| 971 | + # masks = self.mask_cpu() |
| 972 | + # Log.info(f"Mask values: {masks}") |
| 973 | + # print(masks) |
968 | 974 | return scripts_bash |
969 | 975 |
|
970 | | - |
| 976 | + # def mask_cpu(self): |
| 977 | + # |
| 978 | + # def mask(total_cores, processes, rank): |
| 979 | +# process_mask = 2 ** (int(total_cores / processes)) - 1 |
| 980 | +# shifter = total_cores - (len(bin(process_mask)) - 2) * (rank + 1) |
| 981 | +# return hex(process_mask << shifter) |
| 982 | + # |
| 983 | + # cores = int(self.threads_number) |
| 984 | + # processes = int(self.num_procs_value) |
| 985 | + # ranks = list(range(processes)) |
| 986 | + # masks = [] |
| 987 | + # |
| 988 | + # while (len(ranks) > 0): |
| 989 | + # i = 0 |
| 990 | + # print(mask(cores, processes, ranks[i]), end="") |
| 991 | + # masks.append(mask(cores, processes, ranks[i])) |
| 992 | + # del ranks[i] |
| 993 | + # return masks |
971 | 994 |
|
972 | 995 | def build_srun_launcher(self, jobs_list, footer=True): |
973 | 996 | srun_launcher = textwrap.dedent(""" |
@@ -1008,7 +1031,7 @@ def build_srun_launcher(self, jobs_list, footer=True): |
1008 | 1031 | break |
1009 | 1032 | fi |
1010 | 1033 | if [ $job_index -eq 0 ] || [ -f "$completed_path" ]; then # If first horizontal wrapper or last wrapper is completed |
1011 | | - srun -N1 --ntasks=1 --cpus-per-task={1} --cpu-bind=verbose,mask_cpu:job_mask_array[$job_index] --distribution=block:block $template > $out 2> $err & |
| 1034 | + srun -N1 --ntasks=1 --cpus-per-task={1} --cpu-bind=verbose,mask_cpu:${{job_mask_array[$job_index]}} --distribution=block:block $template > $out 2> $err & |
1012 | 1035 | job_index=$(($job_index+1)) |
1013 | 1036 | else |
1014 | 1037 | break |
@@ -1041,6 +1064,6 @@ def build_srun_launcher(self, jobs_list, footer=True): |
1041 | 1064 | return srun_launcher |
1042 | 1065 |
|
1043 | 1066 | def build_main(self): |
1044 | | - nodelist = self.build_nodes_list() |
| 1067 | + #nodelist = self.build_nodes_list() |
1045 | 1068 | srun_launcher = self.build_srun_launcher("scripts_list") |
1046 | | - return nodelist + srun_launcher |
| 1069 | + return srun_launcher |
0 commit comments