QUDA v0.4.0
A library for QCD on GPUs
quda/tests/su3_test.cpp
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 
00005 #include <test_util.h>
00006 #include <wilson_dslash_reference.h>
00007 
00008 #include <gauge_qio.h>
00009 
00010 #ifdef QMP_COMMS
00011 #include <qmp.h>
00012 #endif
00013 
00014 QudaGaugeParam param;
00015 void *gauge[4], *new_gauge[4];
00016 
00017 extern int device;
00018 extern int xdim;
00019 extern int ydim;
00020 extern int zdim;
00021 extern int tdim;
00022 extern int gridsize_from_cmdline[];
00023 extern QudaReconstructType link_recon;
00024 extern QudaPrecision prec;
00025 extern char latfile[];
00026 
00027 #define MAX(a,b) ((a)>(b)?(a):(b))
00028 
00029 void init() {
00030 
00031   param = newQudaGaugeParam();
00032 
00033   param.cpu_prec = QUDA_DOUBLE_PRECISION;
00034   param.cuda_prec = prec;
00035   param.reconstruct = link_recon;
00036   param.cuda_prec_sloppy = prec;
00037   param.reconstruct_sloppy = link_recon;
00038   
00039   param.type = QUDA_WILSON_LINKS;
00040   param.gauge_order = QUDA_QDP_GAUGE_ORDER;
00041 
00042   param.X[0] = xdim;
00043   param.X[1] = ydim;
00044   param.X[2] = zdim;
00045   param.X[3] = tdim;
00046   setDims(param.X);
00047 
00048   param.anisotropy = 1.0;
00049   param.t_boundary = QUDA_PERIODIC_T;
00050   param.gauge_fix = QUDA_GAUGE_FIXED_NO;
00051 #ifdef MULTI_GPU
00052   int x_face_size = param.X[1]*param.X[2]*param.X[3]/2;
00053   int y_face_size = param.X[0]*param.X[2]*param.X[3]/2;
00054   int z_face_size = param.X[0]*param.X[1]*param.X[3]/2;
00055   int t_face_size = param.X[0]*param.X[1]*param.X[2]/2;
00056   int pad_size = MAX(x_face_size, y_face_size);
00057   pad_size = MAX(pad_size, z_face_size);
00058   pad_size = MAX(pad_size, t_face_size);
00059   param.ga_pad = pad_size;    
00060 #else
00061   param.ga_pad = 0;    
00062 #endif
00063 
00064   // construct gauge fields
00065   for (int dir = 0; dir < 4; dir++) {
00066     gauge[dir] = malloc(V*gaugeSiteSize*param.cpu_prec);
00067     new_gauge[dir] = malloc(V*gaugeSiteSize*param.cpu_prec);
00068   }
00069 
00070   initQuda(device);
00071 }
00072 
00073 void end() {
00074   endQuda();
00075 
00076   // release memory
00077   for (int dir = 0; dir < 4; dir++) {
00078     free(gauge[dir]);
00079     free(new_gauge[dir]);
00080   }
00081 }
00082 
00083 extern void usage(char**);
00084 
00085 void SU3Test(int argc, char **argv) {
00086 
00087   for (int i =1;i < argc; i++){    
00088     if(process_command_line_option(argc, argv, &i) == 0){
00089       continue;
00090     }  
00091     
00092     fprintf(stderr, "ERROR: Invalid option:%s\n", argv[i]);
00093     usage(argv);
00094   }
00095 
00096   init();
00097 
00098   if (strcmp(latfile,"")) {  // load in the command line supplied gauge field
00099     read_gauge_field(latfile, gauge, param.cpu_prec, param.X, argc, argv);
00100     construct_gauge_field((void**)gauge, 2, param.cpu_prec, &param);
00101   } else { // generate a random SU(3) field
00102     printf("Randomizing fields...");
00103     construct_gauge_field((void**)gauge, 1, param.cpu_prec, &param);
00104     printf("done.\n");
00105   }
00106 
00107   loadGaugeQuda(gauge, &param);
00108   saveGaugeQuda(new_gauge, &param);
00109 
00110   check_gauge(gauge, new_gauge, 1e-3, param.cpu_prec);
00111 
00112   end();
00113 }
00114 
00115 int main(int argc, char **argv) {
00116 
00117   initCommsQuda(argc, argv, gridsize_from_cmdline, 4);
00118 
00119   SU3Test(argc, argv);
00120 
00121   endCommsQuda();
00122 
00123   return 0;
00124 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines