few changes in WDM stuff
cleaned up the base system... but its not yet a good minimal example...
This commit is contained in:
@@ -12,6 +12,7 @@ arguments
|
||||
options.rand_key = 1;
|
||||
options.num_realiz = 1;
|
||||
options.fwm_mitigation_technique = "co";
|
||||
options.chirpalpha = 0;
|
||||
end
|
||||
|
||||
%% Add the imdd_simulation framework to the path
|
||||
@@ -59,7 +60,9 @@ else
|
||||
end
|
||||
if ~exist(output_root,'dir'), mkdir(output_root); end
|
||||
|
||||
fname = sprintf('WDM_%s_%s_%s_%dkm_%dch_%dghz_%s.mat', char(t), host, jobid, options.fiber_length_km(end), options.num_channels, options.channel_spacing.*1e-9, options.fwm_mitigation_technique);
|
||||
fname = sprintf('WDM_%s_%s_%s_%dkm_%dch_%dghz_%s_alpha%0.1f', char(t), host, jobid, options.fiber_length_km(end), options.num_channels, options.channel_spacing.*1e-9, options.fwm_mitigation_technique, options.chirpalpha);
|
||||
fname = strrep(fname,'.','_');
|
||||
fname = [fname,'.mat'];
|
||||
|
||||
% Worker memory logs directory
|
||||
memlog_dir = fullfile(output_root, 'memlogs');
|
||||
@@ -116,12 +119,12 @@ upsample_pow = 2^nextpow2(upsample_required);
|
||||
s.f_opt = fdac*kover*upsample_pow;
|
||||
s.f_opt_nyq = s.f_opt/2;
|
||||
|
||||
s.rop = -12:0.75:-0.75;
|
||||
% s.rop = -12:1:0;
|
||||
s.rop = -10:0.5:0;
|
||||
|
||||
%% ---------- Intermediate evaluation points (distance dimension) ----------
|
||||
segment_length = 1; % km (must match fiber loop below)
|
||||
|
||||
eval_dist_km = [0];
|
||||
eval_dist_km = [2,4,6,8,10];
|
||||
eval_dist_km = eval_dist_km(eval_dist_km <= link_length);
|
||||
|
||||
if link_length > 0
|
||||
@@ -208,7 +211,9 @@ for realiz = 1:s.num_realiz
|
||||
% E/O Conversion
|
||||
Eml_out = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",El_sig.fs, ...
|
||||
"lambda",s.wavelengthplan(l),"bias",vbias,"u_pi",u_pi, ...
|
||||
"linewidth",laser_linewidth,"randomkey",s.random_key+l+realiz,"alpha",0.8).process(El_sig);
|
||||
"linewidth",laser_linewidth,"randomkey",s.random_key+l+realiz,"alpha",options.chirpalpha).process(El_sig);
|
||||
|
||||
s.alpha = options.chirpalpha;
|
||||
|
||||
% El_sig not needed after EML
|
||||
clear El_sig
|
||||
@@ -244,7 +249,7 @@ for realiz = 1:s.num_realiz
|
||||
nSegments = round(nSegments);
|
||||
|
||||
zdw = 1310;
|
||||
randomize_D = true;
|
||||
randomize_D = false;
|
||||
|
||||
% Guard for 0 km: avoid calling getDispersionVector(0,...) if it doesn't support it
|
||||
if nSegments > 0
|
||||
@@ -256,7 +261,6 @@ for realiz = 1:s.num_realiz
|
||||
eval_ptr = 1;
|
||||
% =================== Queue throttle (prevents OOM) ===================
|
||||
% Limit how many futures can be outstanding (running + queued + finished-not-yet-fetched).
|
||||
% Start conservatively; you can raise to 4*NumWorkers if stable.
|
||||
maxInFlight = max(2, p.NumWorkers);
|
||||
% =====================================================================
|
||||
|
||||
@@ -300,6 +304,10 @@ for realiz = 1:s.num_realiz
|
||||
end
|
||||
% -----------------------------------------------------
|
||||
|
||||
save_results_per_realization( ...
|
||||
s, eval_dist_km, ...
|
||||
output_ffe, output_dfe, output_vnle, output_mlse, output_dbt, ...
|
||||
output_root, fname);
|
||||
|
||||
for seg = 1:nSegments
|
||||
|
||||
@@ -318,7 +326,6 @@ for realiz = 1:s.num_realiz
|
||||
|
||||
cnt = 0;
|
||||
total = length(s.rop)*N;
|
||||
fprintf('total of %d jobs to enqueue at 0 km\n', total);
|
||||
|
||||
for ri = 1:length(s.rop)
|
||||
for l = 1:N
|
||||
@@ -338,8 +345,8 @@ for realiz = 1:s.num_realiz
|
||||
len_tr, mu_dc, mu_ffe, mu_dfe, dfe_order, duob_mode, ...
|
||||
memlog_dir);
|
||||
|
||||
fprintf('Enqueued job %d/%d for realiz %d/%d, l=%d/%d, ri=%d/%d at 0 km (inflight=%d/%d)\n', ...
|
||||
cnt, total, realiz, s.num_realiz, l, N, ri, length(s.rop), numel(F), maxInFlight);
|
||||
fprintf('Seg: %d - Enqueued job %d/%d for realiz %d/%d, l=%d/%d, ri=%d/%d (inflight=%d/%d)\n', ...
|
||||
seg, cnt, total, realiz, s.num_realiz, l, N, ri, length(s.rop), numel(F), maxInFlight);
|
||||
|
||||
meta(end+1) = struct('l',l,'ri',ri,'realiz',realiz,'eval_ptr',eval_ptr);
|
||||
end
|
||||
@@ -356,24 +363,38 @@ for realiz = 1:s.num_realiz
|
||||
|
||||
end
|
||||
|
||||
while ~isempty(F)
|
||||
drainIterMax = 10; % 10 * 60s = 10 minutes
|
||||
for drainIter = 1:drainIterMax
|
||||
|
||||
if isempty(F)
|
||||
break;
|
||||
end
|
||||
|
||||
% Status line: how many futures are in which states?
|
||||
st = {F.State};
|
||||
nUnavail = sum(strcmp(st,'unavailable'));
|
||||
nFinished = sum(strcmp(st,'finished'));
|
||||
nRunning = sum(strcmp(st,'running'));
|
||||
nQueued = sum(strcmp(st,'queued'));
|
||||
nFailed = sum(strcmp(st,'failed'));
|
||||
fprintf('[drain %d/%d] F=%d | finished=%d running=%d queued=%d failed=%d unavailable=%d\n', ...
|
||||
drainIter, drainIterMax, numel(F), nFinished, nRunning, nQueued, nFailed, nUnavail);
|
||||
|
||||
% Try to fetch at least one result (blocking)
|
||||
[F, meta, output_ffe, output_dfe, output_vnle, output_mlse, output_dbt] = ...
|
||||
collect_done(F, meta, output_ffe, output_dfe, output_vnle, output_mlse, output_dbt, true);
|
||||
|
||||
% If still not empty, wait a bit before the next drain attempt
|
||||
if ~isempty(F)
|
||||
pause(60);
|
||||
end
|
||||
end
|
||||
|
||||
%% Save results (per realization)
|
||||
res = struct();
|
||||
res.settings = s;
|
||||
res.eval_dist_km = eval_dist_km;
|
||||
res.ffe = output_ffe;
|
||||
res.dfe = output_dfe;
|
||||
res.vnle = output_vnle;
|
||||
res.mlse = output_mlse;
|
||||
res.dbt = output_dbt;
|
||||
|
||||
save(fullfile(output_root, fname), 'res', '-v7.3');
|
||||
fprintf('Saved results to: %s\n', fullfile(output_root, fname));
|
||||
disp(datetime('now','TimeZone','local','Format','yyyyMs.Mdd_HHmmss'));
|
||||
save_results_per_realization( ...
|
||||
s, eval_dist_km, ...
|
||||
output_ffe, output_dfe, output_vnle, output_mlse, output_dbt, ...
|
||||
output_root, fname);
|
||||
|
||||
% Per-realization large arrays that are no longer needed
|
||||
clear Opt_sig_wdm_fib Symbols Tx_bits Dvec
|
||||
@@ -524,6 +545,16 @@ end
|
||||
|
||||
first = true;
|
||||
while ~isempty(F)
|
||||
|
||||
idxUn = strcmp({F.State}, 'unavailable');
|
||||
if any(idxUn)
|
||||
warning('collect_done: dropping %d unavailable futures.', sum(idxUn));
|
||||
F(idxUn) = [];
|
||||
meta(idxUn) = [];
|
||||
if isempty(F), break; end
|
||||
end
|
||||
|
||||
|
||||
if first
|
||||
timeout = timeout_first;
|
||||
first = false;
|
||||
@@ -555,6 +586,31 @@ end
|
||||
end
|
||||
|
||||
|
||||
function save_results_per_realization( ...
|
||||
s, eval_dist_km, ...
|
||||
output_ffe, output_dfe, output_vnle, output_mlse, output_dbt, ...
|
||||
output_root, fname)
|
||||
|
||||
% Assemble result struct
|
||||
res = struct();
|
||||
res.settings = s;
|
||||
res.eval_dist_km = eval_dist_km;
|
||||
res.ffe = output_ffe;
|
||||
res.dfe = output_dfe;
|
||||
res.vnle = output_vnle;
|
||||
res.mlse = output_mlse;
|
||||
res.dbt = output_dbt;
|
||||
|
||||
% Save (HDF5-based for large data)
|
||||
save(fullfile(output_root, fname), 'res', '-v7.3');
|
||||
|
||||
fprintf('Saved results to: %s\n', fullfile(output_root, fname));
|
||||
disp(datetime('now','TimeZone','local','Format','yyyyMs.Mdd_HHmmss'));
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
%% ========================= Memory logging helpers =========================
|
||||
|
||||
function logfile = make_worker_logfile(memlog_dir)
|
||||
|
||||
Reference in New Issue
Block a user