Skip to content
Snippets Groups Projects
Commit ad4e64ea authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann
Browse files

Scripts to study behavior of computational cost w.r.t. parameters

parent 4edaa07d
No related branches found
No related tags found
No related merge requests found
clear all;
CPUFREQ = 3.2e9;%[Hz] cpu clock of the computer
CTIME_EXP = 425; %[s] real time for N=64, P=2, J=1, DT = 1e-2, TMAX = 150
CCOST_EXP = 64*64/2*4*(2*1 + 2*1)*150/1e-2;
FACTOR = CTIME_EXP/(CCOST_EXP/CPUFREQ);
%% Default parameters
TMAX = 20; % Maximal time unit
DT = 5e-2; % Time step
N = 20; % Frequency gridpoints (Nkr = N/2)
PMAXE = 00; % Highest electron Hermite polynomial degree
JMAXE = 00; % Highest '' Laguerre ''
PMAXI = 00; % Highest ion Hermite polynomial degree
JMAXI = 00; % Highest '' Laguerre ''
%% CPUTIME VS DT
DTA = logspace(-3,-1,10);
NN_DT = []; CT_EST_DT = []; CT_REAL_DT = [];
for DT_ = DTA
DT = DT_;
parameters_cpu_time;
run;
load_results;
CCOST = 4*N*N/2*((PMAXE+1)*(JMAXE+1) + (PMAXI+1)*(JMAXI+1))*TMAX/DT;
NN_DT = [NN_DT,TMAX/DT_];
CT_EST_DT = [CT_EST_DT,CCOST/CPUFREQ];
CT_REAL_DT = [CT_REAL_DT,CPUTIME];
end
system('rm test_cputime*');
if 0
%%
figure
plot(CT_EST_DT,CT_REAL_DT,'-x'); hold on;
xlabel('$4\times N^2/2 \times(P_{e+1} J_{e+1}+ P_{i+1} J_{i+1})\times N_t/\Omega_{CPU}$');
ylabel('$\tau_\textrm{CPU}$'); grid on;
end
%% CPUTIME VS N
DT = 5e-2; % Time step
NA = [16 32 64 128 256 512];
NN_N = []; CT_EST_N = []; CT_REAL_N = [];
for N_ = NA
N = N_;
parameters_cpu_time;
run;
load_results;
CCOST = FACTOR * N*N/2*4*((PMAXE+1)*(JMAXE+1) + (PMAXI+1)*(JMAXI+1))*TMAX/DT;
NN_N = [NN_N,TMAX/DT_];
CT_EST_N = [CT_EST_N,CCOST/CPUFREQ];
CT_REAL_N = [CT_REAL_N,CPUTIME];
end
system('rm test_cputime*');
if 0
%%
figure
plot(CT_EST_N,CT_REAL_N,'-x'); hold on;
xlabel('$4\times N^2/2 \times(P_{e+1} J_{e+1}+ P_{i+1} J_{i+1})\times N_t/\Omega_{CPU}$');
ylabel('$\tau_\textrm{CPU}$'); grid on;
end
%% CPUTIME VS P
DT = 5e-2; % Time step
N = 20;
PA = 0:20;
NN_P = []; CT_EST_P = []; CT_REAL_P = [];
for P_ = PA
PMAXE = P_; PMAXI = P_;
parameters_cpu_time;
run;
load_results;
CCOST = FACTOR * N*N/2*4*((PMAXE+1)*(JMAXE+1) + (PMAXI+1)*(JMAXI+1))*TMAX/DT;
NN_P = [NN_P,TMAX/DT_];
CT_EST_P = [CT_EST_P,CCOST/CPUFREQ];
CT_REAL_P = [CT_REAL_P,CPUTIME];
end
system('rm test_cputime*');
if 0
%%
figure
plot(CT_EST_P,CT_REAL_P,'-x'); hold on;
xlabel('$4\times N^2/2 \times\sum_a P_{a+1} J_{a+1}\times N_t/\Omega_{CPU}$[s]');
ylabel('$\tau_\textrm{CPU}$[s]'); grid on;
end
%% CPUTIME VS J
DT = 5e-2; % Time step
N = 20;
PMAXI= 0; PMAXE = 0;
JA = 0:10;
NN_J = []; CT_EST_J = []; CT_REAL_J = [];
for J_ = JA
JMAXE = J_; JMAXI = J_;
parameters_cpu_time;
run;
load_results;
CCOST = FACTOR * N*N/2*4*((PMAXE+1)*(JMAXE+1) + (PMAXI+1)*(JMAXI+1))*TMAX/DT;
NN_J = [NN_J,TMAX/DT_];
CT_EST_J = [CT_EST_J,CCOST/CPUFREQ];
CT_REAL_J = [CT_REAL_J,CPUTIME];
end
system('rm test_cputime*');
if 0
%%
figure
plot(CT_EST_P,CT_REAL_P,'-x'); hold on;
xlabel('$4\times N^2/2 \times\sum_a P_{a+1} J_{a+1}\times N_t/\Omega_{CPU}$[s]');
ylabel('$\tau_\textrm{CPU}$[s]'); grid on;
end
%% Overall comparison
figure
loglog(CT_EST_DT,CT_REAL_DT,'-x','DisplayName','$\Delta t$'); hold on;
plot(CT_EST_N, CT_REAL_N, '-x','DisplayName','$N$'); hold on;
plot(CT_EST_P, CT_REAL_P, '-x','DisplayName','$P$'); hold on;
plot(CT_EST_J, CT_REAL_J, '-x','DisplayName','$J$'); hold on;
xlabel('$N^{2}(\sum_a P_{a+1} J_{a+1})^{1}N_s^{1} \Omega_{cpu}^{-1}$[s]');
ylabel('$\tau_\textrm{CPU}$'); grid on; legend('show');
%%
% CTIME = FACTOR * CCOST/CPUFREQ;
% HOURS = floor(CTIME/3600);
% MINUTES = floor((CTIME-3600*HOURS)/60);
% SECONDS = floor(CTIME-3600*HOURS-60*MINUTES);
%
% disp(['Computational cost ~',sprintf('%.1e',CCOST),' op.']);
%
% TIMESTRING = 'Computational time ~';
% if HOURS > 0
% TIMESTRING = [TIMESTRING,num2str(HOURS),'h '];
% end
% if MINUTES > 0
% TIMESTRING = [TIMESTRING,num2str(MINUTES),'min '];
% end
% if (HOURS + MINUTES == 0) && (SECONDS > 0)
% TIMESTRING = [TIMESTRING,num2str(SECONDS),'s '];
% end
% disp(TIMESTRING);
% clear all;
addpath(genpath('../matlab')) % ... add
default_plots_options
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Set Up parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PHYSICAL PARAMETERS
NU = 1e-2; % Collision frequency
TAU = 1.0; % e/i temperature ratio
ETAB = 0.0; % Magnetic gradient
ETAN = 1.0; % Density gradient
ETAT = 0.0; % Temperature gradient
MU = 1e-8; % Hyper diffusivity coefficient
LAMBDAD = 0.0;
NOISE0 = 5.0e-5;
%% GRID PARAMETERS
% N = 32; % Frequency gridpoints (Nkr = N/2)
L = 10; % Size of the squared frequency domain
KREQ0 = 0; % put kr = 0
% PMAXE = 02; % Highest electron Hermite polynomial degree
% JMAXE = 00; % Highest '' Laguerre ''
% PMAXI = 02; % Highest ion Hermite polynomial degree
% JMAXI = 00; % Highest '' Laguerre ''
KPAR = 0.0; % Parellel wave vector component
%% TIME PARAMETERS
% TMAX = 10; % Maximal time unit
% DT = 1e-2; % Time step
SPS2D = 5; % Sampling per time unit for 2D arrays
SPS5D = 0.5; % Sampling per time unit for 5D arrays
RESTART = 0; % To restart from last checkpoint
JOB2LOAD= 00;
%% OPTIONS
SIMID = 'test_cputime'; % Name of the simulation
NON_LIN = 1 *(1-KREQ0); % activate non-linearity (is cancelled if KREQ0 = 1)
CO = -2; % Collision operator (0 : L.Bernstein, -1 : Full Coulomb, -2 : Dougherty)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% unused
KR0KH = 0; A0KH = 0; % Background phi mode to drive Ray-Tay inst.
NO_E = 0; % Remove electrons dynamic
% DK = 0; % Drift kinetic model (put every kernel_n to 0 except n=0 to 1)
setup
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment