Skip to content

Commit

Permalink
params out of device code
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcogarofalo committed Apr 13, 2021
1 parent 12abc04 commit fadddb5
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 38 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ you can add option

```
-DCMAKE_CXX_FLAGS=-DTIMER
-DCMAKE_CXX_FLAGS=-DDEBUG
-DFFTW=ON
-DCUFFT=ON
```
in the building scritp to have more extra info on the timer

Expand Down
42 changes: 36 additions & 6 deletions Rplot/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,27 @@ shinyServer(function(input, output) {
g <- as.double(input$g)
rep<-as.integer(input$rep)
#dir <- "/home/marco/analysis/phi4/tuning_masses/out"
dir <- "Data"
dir <- input$Directory

file=sprintf("%s/G2t_T%d_L%d_msq0%.6f_msq1%.6f_l0%.6f_l1%.6f_mu%.6f_g%.6f_rep%d_output", dir, T, L, msq0, msq1, l0, l1, mu, g, rep)
return(file)
})
file_checks<-reactive({
T<-as.integer(input$T)
L<-as.integer(input$L)
msq0<-as.double(input$msq0)
msq1<-as.double(input$msq1)
l0<-as.double(input$l0)
l1<-as.double(input$l1)
mu<-as.double(input$mu)
g <- as.double(input$g)
rep<-as.integer(input$rep)
#dir <- "/home/marco/analysis/phi4/tuning_masses/out"
dir <- input$Directory

file=sprintf("%s/checks_T%d_L%d_msq0%.6f_msq1%.6f_l0%.6f_l1%.6f_mu%.6f_g%.6f_rep%d_output", dir, T, L, msq0, msq1, l0, l1, mu, g, rep)
return(file)
})
file_meff<-reactive({
T<-as.integer(input$T)
L<-as.integer(input$L)
Expand All @@ -124,7 +140,7 @@ shinyServer(function(input, output) {
g <- as.double(input$g)
rep<-as.integer(input$rep)
#dir <- "/home/marco/analysis/phi4/tuning_masses/out"
dir <- "Data"
dir <- input$Directory

file=sprintf("%s/G2t_T%d_L%d_msq0%.6f_msq1%.6f_l0%.6f_l1%.6f_mu%.6f_g%.6f_rep%d_meff_correlators", dir, T, L, msq0, msq1, l0, l1, mu, g, rep)
return(file)
Expand All @@ -140,7 +156,7 @@ shinyServer(function(input, output) {
g <- as.double(input$g)
rep<-as.integer(input$rep)
#dir <- "/home/marco/analysis/phi4/tuning_masses/out"
dir <- "Data"
dir <- input$Directory

file=sprintf("%s/G2t_T%d_L%d_msq0%.6f_msq1%.6f_l0%.6f_l1%.6f_mu%.6f_g%.6f_rep%d_raw_correlators"
, dir, T, L, msq0, msq1, l0, l1, mu, g, rep)
Expand All @@ -157,7 +173,7 @@ shinyServer(function(input, output) {
g <- as.double(input$g)
rep<-as.integer(input$rep)
#dir <- "/home/marco/analysis/phi4/tuning_masses/out"
dir <- "Data"
dir <- input$Directory

file=sprintf("%s/G2t_T%d_L%d_msq0%.6f_msq1%.6f_l0%.6f_l1%.6f_mu%.6f_g%.6f_rep%d_shifted_correlators"
, dir, T, L, msq0, msq1, l0, l1, mu, g, rep)
Expand All @@ -174,7 +190,7 @@ shinyServer(function(input, output) {
g <- as.double(input$g)
rep<-as.integer(input$rep)
#dir <- "/home/marco/analysis/phi4/tuning_masses/out"
dir <- "Data"
dir <- input$Directory

file=sprintf("%s/G2t_T%d_L%d_msq0%.6f_msq1%.6f_l0%.6f_l1%.6f_mu%.6f_g%.6f_rep%d_log_meff_shifted"
, dir, T, L, msq0, msq1, l0, l1, mu, g, rep)
Expand All @@ -193,13 +209,27 @@ shinyServer(function(input, output) {
multiple = TRUE
)
})

output$obs_checks <- renderUI({
file<-file_checks()
mt<-read_df(file)
obs<-get_all_corr(mt)
pickerInput(
inputId = "manyChecks",
label = "Obs_checks",
choices =obs[,"corr"],
options = list( `actions-box` = TRUE, size = 10 ,`selected-text-format` = "count > 3" ),
multiple = TRUE
)
})

gg_many<-reactive({
gg<- ggplot()
#print(input$manyObs)
#gg<-add_plot(file(), input$manyObs, input$T, input$logscale,gg,1 )
gg<-add_plot_new(file(), input$manyObs, input$T, input$logscale,gg )
if (file.exists(file_checks())){
gg<-add_plot_new(file_checks(), input$manyChecks, input$T, input$logscale,gg )
}
gg<-add_plot(file_meff(), input$log_meff_corr, input$T, input$logscale,gg,3,prefix="log_meff" )
gg<-add_plot(file_raw(), input$raw_corr, input$T, input$logscale,gg ,3,prefix="raw")
gg<-add_plot(file_shift(), input$shifted_corr, input$T, input$logscale,gg,3,prefix="shift" )
Expand Down
17 changes: 11 additions & 6 deletions Rplot/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ shinyUI(fluidPage(
selectInput("T", label = "T",
choices =as.integer( c(16,24,32, 48,64,96,128)), selected = 128),
selectInput("msq0", label = "\\( m_0^2\\)",
choices = c(0.1,-4.9,-4.92,-4.95,-4.925,-4.98,-4.99,-5.0), selected = -4.925),
choices = c(0.1,-0.2,-4.9,-4.92,-4.95,-4.925,-4.98,-4.99,-5.0), selected = -4.925),
selectInput("msq1", label = "\\( m_1^2\\)",
choices =c(0.1,-4.9,-4.89,-4.85,-4.845,-4.825,-4.65), selected = -4.85),
choices =c(0.1,-0.4,-4.9,-4.89,-4.85,-4.845,-4.825,-4.65), selected = -4.85),
selectInput("l0", label = "\\(\\lambda_0\\)",
choices =c(0.05,2.5), selected = 2.5),
choices =c(0.05,2.5,10,25), selected = 2.5),
selectInput("l1", label = "\\(\\lambda_1\\)",
choices =c(0.05,2.5), selected = 2.5),
choices =c(0.05,2.5,10,25), selected = 2.5),
selectInput("mu", label = "\\(\\mu\\)",
choices =c(0.1, 5), selected = 5),
choices =c(0.1, 5,20,50), selected = 5),
selectInput("g", label = "g",
choices =c(0.0), selected = 0),
selectInput("rep", label = "rep",
Expand All @@ -52,7 +52,10 @@ shinyUI(fluidPage(
# "C4_BH","E2_01", "meff(E2_01)"),
# selected = "C4_BH"),
selectInput("logscale", label = "logscale",
choices =c("no","yes"), selected = "no")
choices =c("no","yes"), selected = "no"),
selectInput("Directory", label = "Directory",
choices =c( "Data","/home/marco/analysis/phi4/checks/out"), selected = "Data"),


),

Expand All @@ -73,6 +76,8 @@ shinyUI(fluidPage(
# selected = c("meff0","C4_BH")
# ),
uiOutput("obs_list"),
uiOutput("obs_checks"),

pickerInput(
inputId = "log_meff_corr",
label = "log_meff_corr",
Expand Down
2 changes: 2 additions & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

add_target_with_lib(main main.cpp)
add_target_with_lib(contraction contraction.cpp)
add_target_with_lib(conf_bin2asci conf_bin2asci.cpp)

add_executable(binning_contraction binning_contraction.cpp)
add_executable(merging_replicas merging_replicas.cpp)

62 changes: 36 additions & 26 deletions modules/DFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ void compute_FT(const Viewphi phi, cluster::IO_params params , int iconf, Viewp
int iz=x /(L1*L2);
int iy=(x- iz*L1*L2)/L1;
#ifdef DEBUG
if (x!= ix+ iy*params.data.L[1]+iz*params.data.L[1]*params.data.L[2]){
printf("error %ld = %d + %d *%d+ %d*%d*%d\n",x,ix,iy,params.data.L[1],iz,params.data.L[1],params.data.L[2]);
// exit(1);
if (x!= ix+ iy*L1+iz*L1*L2){
printf("error %ld = %d + %d *%d+ %d*%d*%d\n",x,ix,iy,L1,iz,L1,L2);
// exit(1);
}
#endif
double wr=6.28318530718 *( px*ix/(double (L1)) + py*iy/(double (L2)) +pz*iz/(double (L3)) );
Expand All @@ -110,10 +110,12 @@ void test_FT(cluster::IO_params params){
size_t Vs=V/params.data.L[0];
Viewphi phi("phi",2,V);
printf("checking FT of constant field:\n");
double kappa0=params.data.kappa0;
double kappa1=params.data.kappa1;

Kokkos::parallel_for( "init_const_phi", V, KOKKOS_LAMBDA( size_t x) {
phi(0,x)= sqrt(2.*params.data.kappa0);// the FT routines convert in to phisical phi
phi(1,x)= sqrt(2.*params.data.kappa1);
phi(0,x)= sqrt(2.*kappa0);// the FT routines convert in to phisical phi
phi(1,x)= sqrt(2.*kappa1);
});
Viewphi::HostMirror h_phip_test("h_phip_test",2,params.data.L[0]*Vp);
compute_FT(phi, params , 0, h_phip_test);
Expand Down Expand Up @@ -141,8 +143,8 @@ void test_FT(cluster::IO_params params){
printf("checking FT of delta_x,0 field:\n");
Kokkos::parallel_for( "init_phi", V, KOKKOS_LAMBDA( size_t x) {
if(x==0){
phi(0,x)=Vs* sqrt(2.*params.data.kappa0);// the FT routines convert in to phisical phi
phi(1,x)=Vs* sqrt(2.*params.data.kappa1);
phi(0,x)=Vs* sqrt(2.*kappa0);// the FT routines convert in to phisical phi
phi(1,x)=Vs* sqrt(2.*kappa1);
}
else{
phi(0,x)= 0;// the FT routines convert in to phisical phi
Expand Down Expand Up @@ -182,13 +184,16 @@ void test_FT_vs_FFTW(cluster::IO_params params){
size_t V=params.data.V;
size_t Vs=V/params.data.L[0];
int T=params.data.L[0];
double kappa0=params.data.kappa0;
double kappa1=params.data.kappa1;

Viewphi phi("phi",2,V);
printf("checking FT vs FFTW\n");
//kokkos
Viewphi::HostMirror h_phi = Kokkos::create_mirror_view( phi );
Kokkos::parallel_for( "init_phi", V, KOKKOS_LAMBDA( size_t x) {
phi(0,x)=x* sqrt(2.*params.data.kappa0);// the FT routines convert in to phisical phi
phi(1,x)=x* sqrt(2.*params.data.kappa1);
phi(0,x)=x* sqrt(2.*kappa0);// the FT routines convert in to phisical phi
phi(1,x)=x* sqrt(2.*kappa1);
});
// Deep copy device views to host views.
Kokkos::deep_copy( h_phi, phi );
Expand Down Expand Up @@ -255,6 +260,10 @@ void test_FT_vs_FFTW(cluster::IO_params params){
void compute_cuFFT(const Viewphi phi, cluster::IO_params params , int iconf, Viewphi::HostMirror &h_phip){
int T=params.data.L[0];
size_t Vs=params.data.V/T;
double kappa0=params.data.kappa0;
double kappa1=params.data.kappa1;


Viewphi Kphi("Kphip",2,params.data.L[0]*Vp);
cufftHandle plan;
cufftReal *idata;
Expand Down Expand Up @@ -290,23 +299,24 @@ void compute_cuFFT(const Viewphi phi, cluster::IO_params params , int iconf, Vi
}

Kokkos::parallel_for( "cuFFT_to_Kokkos", Vp, KOKKOS_LAMBDA( size_t pp) {
int reim=pp%2;
int p=(pp-reim)/2;
const int px=p%Lp;
const int pz=p /(Lp*Lp);
const int py= (p- pz*Lp*Lp)/Lp;
int pcuff=(px+py*(L[1]/2 +1)+pz* (L[1]/2+1)*(L[2]));
int ip=t+pp*T;
if(reim==0)
Kphi(comp,ip)=odata[pcuff].x/(Vs*sqrt(2*params.data.kappa0));
else if(reim==1)
Kphi(comp,ip)=-odata[pcuff].y/(Vs*sqrt(2*params.data.kappa0));
#ifdef DEBUG
if(p!= px+py*Lp+pz*Lp*Lp)
printf( "index problem if cuFFT p=%d != (%d,%d,%d)\n",p,px,py,pz);
if(pp!= reim+p*2)
printf( "index problem if cuFFT pp=%d != %d+%d*2\n",pp,reim,p);
#endif
int reim=pp%2;
int p=(pp-reim)/2;
const int px=p%Lp;
const int pz=p /(Lp*Lp);
const int py= (p- pz*Lp*Lp)/Lp;
int pcuff=(px+py*(L[1]/2 +1)+pz* (L[1]/2+1)*(L[2]));
int ip=t+pp*T;
double normFT[2]={Vs*sqrt(2*kappa0),Vs*sqrt(2*kappa1)};
if(reim==0)
Kphi(comp,ip)=odata[pcuff].x/normFT[comp];
else if(reim==1)
Kphi(comp,ip)=-odata[pcuff].y/normFT[comp];
#ifdef DEBUG
if(p!= px+py*Lp+pz*Lp*Lp)
printf( "index problem if cuFFT p=%d != (%d,%d,%d)\n",p,px,py,pz);
if(pp!= reim+p*2)
printf( "index problem if cuFFT pp=%d != %d+%d*2\n",pp,reim,p);
#endif
});


Expand Down

0 comments on commit fadddb5

Please sign in to comment.