Commit 0d053778 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline

Lima: add BufferThread, Stats and CPUAffinity, including eiger_stats.mac

parent 6a82dbd3
Subproject commit e9797c9c8bb84d44dee4658617a6214d86e58944
Subproject commit 97bacad038fd19f72ec115a3ab99317d7b9a1c66
def gen_eiger_stats(fname, nb_rep, nb_frames) '{
local n i j nb_names arr_names[] out_s nb_vals val_arr[] cmd
local lima_name dev_name ccd_u exp_time frame_rate lat_time
local pixel_depth bad_frames
lima_name = "eiger500k"
ccd_u = LIMA_DEV[lima_name]["unit"]
dev_name = LIMA_DEV[lima_name]["config"]
pixel_depth = _limapar_get(lima_name, "pixel_depth")
frame_rate = _limapar_get(lima_name, "max_frame_rate") * 1000
lat_time = _limapar_get(lima_name, "latency_time")
exp_time = 1 / frame_rate - lat_time
if (nb_frames == 0)
nb_frames = ((pixel_depth == 4) ? 30000 : \
((pixel_depth == 8) ? 15000 : \
((pixel_depth == 16) ? 7600 : 3000)))
_limapar_set(lima_name, "saving_mode", "MANUAL")
for (n = 0; n < nb_rep; n++) {
ccdtake exp_time nb_frames
bad_frames = _limapar_get(lima_name, "nb_bad_frames")
if (bad_frames > 0) {
printf("Bad frames: %d - Skipping!\n", bad_frames)
continue
}
nb_names = split("cb_period cb_exec recv_exec", arr_names)
out_s = ""
for (i = 0; i < nb_names; i++) {
cmd = sprintf("stats_%s", arr_names[i])
nb_vals = tango_get(dev_name, cmd, val_arr)
for (j = 0; j < nb_vals; j++) {
out_s = sprintf("%s%s%d", out_s, \
length(out_s) ? " " : "", \
val_arr[j])
}
}
on(fname)
print out_s
close(fname)
}
}'
def eiger_tune_cpu_affinity() '{
local n i j cpu_set nb_cpu_set arr_cpu_set[] out_s nb_vals val_arr[]
local lima_name dev_name ccd_u exp_time frame_rate lat_time
local pixel_depth old_pixel_depth nb_rep acc cb_exec_ave[]
local min_val min_cpu_set
lima_name = "eiger500k"
ccd_u = LIMA_DEV[lima_name]["unit"]
dev_name = LIMA_DEV[lima_name]["config"]
old_pixel_depth = _limapar_get(lima_name, "pixel_depth")
pixel_depth = 4
nb_rep = 10
printf("Tuning Eiger CPU Affinity\n")
_limapar_set(lima_name, "pixel_depth", pixel_depth)
frame_rate = _limapar_get(lima_name, "max_frame_rate") * 1000
lat_time = _limapar_get(lima_name, "latency_time")
exp_time = 1 / frame_rate - lat_time
nb_frames = 1000
_limapar_set(lima_name, "saving_mode", "MANUAL")
_limapar_set(lima_name, "acq_expo_time", exp_time)
nb_cpu_set = split("0xfff 0x03f 0xfc0", arr_cpu_set)
ccdtake exp_time nb_frames
for (i = 0; i < nb_cpu_set; i++) {
cpu_set = arr_cpu_set[i]
cpu_affinity[0] = pixel_depth
cpu_affinity[1] = cpu_set
cpu_affinity[2] = cpu_set
cpu_affinity[3] = 0xfff
tango_put(dev_name, "pixel_depth_cpu_affinity_map", \
cpu_affinity)
ccdtake exp_time nb_frames
acc = 0
for (n = 0; n < nb_rep; n++) {
ccdtake exp_time nb_frames
bad_frames = _limapar_get(lima_name, "nb_bad_frames")
if (bad_frames > 0) {
printf("\nBad frames: %d - Skipping!\n", \
bad_frames)
n--
continue
}
nb_vals = tango_get(dev_name, "stats_cb_exec", val_arr)
acc += val_arr[2]
}
cb_exec_ave[i] = acc / nb_rep
printf("\nCPU Affinity: 0x%03x, CB exec: %d\n", cpu_set, \
cb_exec_ave[i])
}
min_val = cb_exec_ave[0]
cpu_set = arr_cpu_set[0]
for (i = 1; i < nb_cpu_set; i++) {
if (cb_exec_ave[i] < min_val) {
min_val = cb_exec_ave[i]
cpu_set = arr_cpu_set[i]
}
}
printf("Setting CPU Affinity: 0x%03x\n", cpu_set)
cpu_affinity[0] = pixel_depth
cpu_affinity[1] = cpu_set
cpu_affinity[2] = cpu_set
cpu_affinity[3] = 0xfff
tango_put(dev_name, "pixel_depth_cpu_affinity_map", cpu_affinity)
_limapar_set(lima_name, "pixel_depth", old_pixel_depth)
}'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment