Faster DP_fiber with GPU processing... Run test\gpu_cpu_comparison.m to see difference on your setup
This commit is contained in:
@@ -22,37 +22,37 @@ n_plates_left = n_plates - n_plates_done;
|
||||
|
||||
% compute last plate size ( if it fits, it should be 0)
|
||||
if missing_dz > aStepSize
|
||||
|
||||
|
||||
last_plate = aStepSize;
|
||||
missing_dz = missing_dz-aStepSize;
|
||||
plate_sizes = last_plate;
|
||||
plate_numbers = n_plates;
|
||||
|
||||
|
||||
else
|
||||
|
||||
|
||||
last_plate = aStepSize - missing_dz - (n_plates_left-1)*corr_length;
|
||||
|
||||
|
||||
if missing_dz == 0
|
||||
missing_dz = [];
|
||||
end
|
||||
|
||||
|
||||
%build vector of plate lengths with missing plate part from prev.
|
||||
%iterartion , then some normal plates and finally a fraction of a plate
|
||||
%to fit into the step length
|
||||
plate_sizes = [missing_dz corr_length*ones(1,n_plates_left-1) last_plate];
|
||||
|
||||
|
||||
if n_plates_done == 0
|
||||
plate_numbers =[(n_plates_done+1):(n_plates-1) n_plates];
|
||||
else
|
||||
plate_numbers = [n_plates_done (n_plates_done+1):(n_plates-1) n_plates]; % not wrking yet
|
||||
end
|
||||
|
||||
%remember for next step
|
||||
|
||||
%remember for next step
|
||||
missing_dz = corr_length - last_plate;
|
||||
|
||||
|
||||
end
|
||||
|
||||
plate_steps = repmat(n_step,1,length(plate_sizes));
|
||||
plate_steps = repmat(n_step,1,length(plate_sizes)); %#ok<NASGU>
|
||||
|
||||
%
|
||||
%figure;stem(plate_sizes);
|
||||
@@ -66,50 +66,39 @@ test_plate_numbers = [test_plate_numbers, plate_numbers];
|
||||
opt_x=fft(opt_x);
|
||||
opt_y=fft(opt_y);
|
||||
|
||||
% db1 = gpuArray(brf.db1);
|
||||
% db0 = gpuArray(brf.db0);
|
||||
% common_beta_x = gpuArray(common_beta_x);
|
||||
% common_beta_y = gpuArray(common_beta_y);
|
||||
|
||||
db1 = (brf.db1);
|
||||
db0 = (brf.db0);
|
||||
common_beta_x = (common_beta_x);
|
||||
common_beta_y = (common_beta_y);
|
||||
% Note: db1, db0, common_beta_x, common_beta_y are already on GPU when
|
||||
% useGPU=true (transferred in CNLSE_plain)
|
||||
db1 = brf.db1;
|
||||
db0 = brf.db0;
|
||||
|
||||
% process every waveplate with given sizes in plate_sizes
|
||||
for n=1:length(plate_sizes)
|
||||
dz = plate_sizes(n);
|
||||
|
||||
% figure(87);subplot(2,1,1);plot(real(x(900:1150)));subplot(2,1,2);plot(real(y(900:1150)));
|
||||
% MOV1=[MOV1 getframe(87)];
|
||||
|
||||
|
||||
% extract rotation matrix from pre calculated matrices
|
||||
matR = brf.matR{plate_numbers(n)};
|
||||
|
||||
|
||||
% transform to eigenvalue of of fiber segment
|
||||
tOpt.X = conj(matR(1,1))*opt_x + conj(matR(2,1))*opt_y;
|
||||
tOpt.Y = conj(matR(1,2))*opt_x + conj(matR(2,2))*opt_y;
|
||||
|
||||
|
||||
% calculate statistical delta beta for pmd
|
||||
delta_beta = 0.5*(db1+db0(n))/corr_length;
|
||||
% build transfer function with delta beta
|
||||
%common.beta = beta1+beta2*omega^2
|
||||
|
||||
|
||||
%accumulate delta beta for log...
|
||||
brf.simdgd = brf.simdgd + (db1(length(db1)/2+1)+db0(n))/corr_length;
|
||||
|
||||
|
||||
h.X = exp(-1j*(common_beta_x-delta_beta)*dz);
|
||||
h.Y = exp(-1j*(common_beta_y+delta_beta)*dz);
|
||||
% delta_beta has to be added to the transfer function
|
||||
|
||||
|
||||
% process with transfer function
|
||||
tOpt.X = h.X.*tOpt.X ;
|
||||
tOpt.Y = h.Y.*tOpt.Y ;
|
||||
|
||||
|
||||
% rotate back
|
||||
opt_x = matR(1,1)*tOpt.X + matR(1,2)*tOpt.Y;
|
||||
opt_y = matR(2,1)*tOpt.X + matR(2,2)*tOpt.Y;
|
||||
|
||||
|
||||
end
|
||||
|
||||
lin_z_test = lin_z_test + sum(plate_sizes,2);
|
||||
@@ -117,9 +106,8 @@ lin_z_test = lin_z_test + sum(plate_sizes,2);
|
||||
%update the number of processed plates so far
|
||||
n_plates_done = n_plates_done + n_plates_left;
|
||||
|
||||
% attanuate the signal each linear state with alpha
|
||||
% ( 0.2dB = 4.6052e-05 )
|
||||
rOpt_x=ifft(exp(-alpha_lin_x*aStepSize/2).*opt_x); % /2 not sure why (have to find it in formulas)
|
||||
rOpt_y=ifft(exp(-alpha_lin_y*aStepSize/2).*opt_y); % but not relevant for now
|
||||
% attenuate the signal each linear step with alpha
|
||||
rOpt_x=ifft(exp(-alpha_lin_x*aStepSize/2).*opt_x);
|
||||
rOpt_y=ifft(exp(-alpha_lin_y*aStepSize/2).*opt_y);
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user