... | @@ -79,75 +79,32 @@ This script |
... | @@ -79,75 +79,32 @@ This script |
|
# see which functions is first
|
|
# see which functions is first
|
|
first_routine = functions_called_once_per_step[0]
|
|
first_routine = functions_called_once_per_step[0]
|
|
```
|
|
```
|
|
|
|
5. For all cpu finds the shortes timestep, then look on average which one has been the fastest
|
|
|
|
``` python
|
|
time_steps = time[(function_ids == first_routine) & (cpu_ids == nemo_proc[0])].shape[0]
|
|
for proc in nemo_proc:
|
|
print("Actual n_proc", nemo_proc_number, "with ", time_steps, "time steps")
|
|
|
|
|
|
|
|
# Find the index of the fastest step
|
|
|
|
time_step = np.ones([nemo_proc_number, time_steps])
|
|
|
|
|
|
|
|
ts_min_index = np.zeros(nemo_proc_number, dtype='int')
|
|
|
|
ts_max_index = np.zeros(nemo_proc_number, dtype='int')
|
|
|
|
|
|
|
|
ts_time = np.zeros([nemo_proc_number, time_steps])
|
|
|
|
start = clock_time.time()
|
|
|
|
for proc in nemo_proc:
|
|
|
|
index = proc - nemo_proc[0]
|
|
index = proc - nemo_proc[0]
|
|
ts_time[index] = time[(cpu_ids == proc) & (function_ids == first_routine)]
|
|
ts_time[index] = time[(cpu_ids == proc) & (function_ids == first_routine)]
|
|
|
|
|
|
# compute the duration of each ts
|
|
# Compute the duration of each ts
|
|
ts_duration = np.diff(ts_time[index])
|
|
ts_duration = np.diff(ts_time[index])
|
|
|
|
|
|
# find the index of the minimum ts for each proc
|
|
# Index of the minimum ts for each proc
|
|
ts_min_index[index] = np.argmin(ts_duration)
|
|
ts_min_index[index] = np.argmin(ts_duration)
|
|
|
|
|
|
# find the index of the maximum ts for each proc
|
|
|
|
ts_max_index[index] = np.argmax(ts_duration[1:-1]) + 1
|
|
|
|
|
|
|
|
# Evaluate the most common index for best ts
|
|
# Evaluate the most common index for best ts
|
|
counts = np.bincount(ts_min_index)
|
|
counts = np.bincount(ts_min_index)
|
|
best_ts_index = np.argmax(counts)
|
|
best_ts_index = np.argmax(counts)
|
|
|
|
|
|
counts = np.bincount(ts_max_index)
|
|
```
|
|
worst_ts_index = np.argmax(counts)
|
|
6. Once the index of the best time-step has been found find time begin/end times to pass to Extrae cutter
|
|
|
|
```python
|
|
print("for finding the index of the slowest / fastest step: ", worst_ts_index, "/", best_ts_index)
|
|
best_ts_start = min(ts_time[:, best_ts_index])
|
|
end = clock_time.time()
|
|
best_ts_end = max(ts_time[:, best_ts_index + 1])
|
|
print(end - start)
|
|
```
|
|
|
|
|
|
# Find the start and the end of the best step
|
|
|
|
best_ts_start = min(ts_time[:, best_ts_index])
|
|
|
|
best_ts_end = max(ts_time[:, best_ts_index + 1])
|
|
|
|
|
|
|
|
# Find the start and the end of the best step
|
|
|
|
worst_ts_start = min(ts_time[:, worst_ts_index])
|
|
|
|
worst_ts_end = max(ts_time[:, worst_ts_index + 1])
|
|
|
|
|
|
|
|
print("Worst / best time step's duration: ", worst_ts_end - worst_ts_start, best_ts_end - best_ts_start)
|
|
|
|
|
|
|
|
# Open the xml template
|
|
|
|
tree = ET.parse(template_path)
|
|
|
|
|
|
|
|
cutter = tree.find('cutter')
|
|
|
|
for tasks in tree.iter('tasks'):
|
|
|
|
tasks.text = str(nemo_proc_min) + "-" + str(nemo_proc_max)
|
|
|
|
for minimum_time in tree.iter('minimum_time'):
|
|
|
|
minimum_time.text = str(best_ts_start - 1000)
|
|
|
|
for maximum_time in tree.iter('maximum_time'):
|
|
|
|
maximum_time.text = str(best_ts_end + 1000)
|
|
|
|
|
|
|
|
# Create paramedir cutter file
|
|
|
|
tree.write('best_time_cutter.xml')
|
|
|
|
for minimum_time in tree.iter('minimum_time'):
|
|
|
|
minimum_time.text = str(worst_ts_start - 1000)
|
|
|
|
for maximum_time in tree.iter('maximum_time'):
|
|
|
|
maximum_time.text = str(worst_ts_end + 1000)
|
|
|
|
|
|
|
|
# Create paramedir cutter file
|
|
|
|
tree.write('worst_time_cutter.xml')
|
|
|
|
|
|
|
|
return unique_function_ids.tolist()
|
|
|
|
|
|
|
|
|
|
|
|
[... to be continued] |
|
### Cutter template
|
|
|
|
In the template folder an extrae xml template is stored: the value obtained with the traceCutter are inserted there and the trace is cut:
|
|
|
|
```bash
|
|
|
|
echo "start paramedir cutter"
|
|
|
|
time paramedir -c best_time_cutter.xml ${trace_file} -o ${trace_base_name}.best_cut.prv
|
|
|
|
``` |