Commit 67ad5002 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline

Merge branch 'slsdetector' into 'master'

parents 70aecdc2 5ca5bd03
Subproject commit f6308ebb5c1588e53ff4de610a3fed950e5f2983
Subproject commit 89aa4b6962294dc220cb3c14755c019c8298c853
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)
}'
def test_macro '{
while(1) {
local napi, cbp, cbe, bf, fr, nbi, et;
local lcd, lsd, ln, i;
napi = 1;
fr = ($# > 0) ? $1 : 22.0e3
nbi = ($# > 1) ? $2 : 30000
et = 1 / fr - _limapar_get("eiger500k", "latency_time")
for (i = 1; i <= list_n(LIMA_DEV); i++) {
ln = list_item(LIMA_DEV, i);
lcd = list_getpar(LIMA_DEV, ln, "control");
lsd = list_getpar(LIMA_DEV, ln, "config");
if (list_getpar(LIMA_DEV, ln, "unit") == CCD_U)
break;
}
if (i > list_n(LIMA_DEV)) {
printf("Error: could not find LIMA dev for CCD %d\n", \
CCD_U);
exit;
}
bench ccdtake et nbi;
if (napi) {
tango_io(lsd, "getStats", "-1:cb_period", \
eiger_cb_period_stats);
tango_io(lsd, "getStats", "-1:cb_exec", \
eiger_cb_exec_stats);
bf = tango_io(lsd, "getNbBadFrames", -1)
} else {
tango_get(lsd, "stats_cb_period", \
eiger_cb_period_stats);
tango_get(lsd, "stats_cb_exec", \
eiger_cb_exec_stats);
bf = tango_get(lsd, "nb_bad_frames")
};
printf("\n%6d %6d %8.2f %8.2f\n", \
tango_get(lcd, "last_image_acquired") + 1, bf, \
eiger_cb_period_stats[2], eiger_cb_exec_stats[2]);
double array port_stats[4][5];
if (napi) {
for (i = 0; i < 4; i++)
tango_io(lsd, "getStats", \
sprintf("%d:cb_period", i), \
port_stats[i]);
p port_stats[:][2];
for (i = 0; i < 4; i++)
tango_io(lsd, "getStats", \
sprintf("%d:cb_exec", i), \
port_stats[i]);
p port_stats[:][2];
};
sleep(1)
}
}'
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