QUDA v0.4.0
A library for QCD on GPUs
quda/tests/qio_util.h
Go to the documentation of this file.
00001 #ifndef QIO_TEST_H
00002 #define QIO_TEST_H
00003 
00004 #include <qmp.h>
00005 #include <qio.h>
00006 #define mynode QMP_get_node_number
00007 
00008 extern QIO_Layout layout;
00009 extern int lattice_dim;
00010 extern int lattice_size[4];
00011 
00012 #include <layout_hyper.h>
00013 
00014 #define NCLR 3
00015 
00016 typedef struct
00017 {
00018   float re;
00019   float im;
00020 } complex;
00021 
00022 typedef struct { complex e[NCLR][NCLR]; } suN_matrix;
00023 
00024 /* get and put */
00025 void vput_R(char *buf, size_t index, int count, void *qfin);
00026 void vget_R(char *buf, size_t index, int count, void *qfin);
00027 void vput_M(char *buf, size_t index, int count, void *qfin);
00028 void vget_M(char *buf, size_t index, int count, void *qfin);
00029 void vput_r(char *buf, size_t index, int count, void *qfin);
00030 void vget_r(char *buf, size_t index, int count, void *qfin);
00031 
00032 // templatized version of vput_M to allow for precision conversion
00033 template <typename oFloat, typename iFloat, int len>
00034 void vputM(char *s1, size_t index, int count, void *s2)
00035 {
00036   oFloat **field = (oFloat **)s2;
00037   iFloat *src = (iFloat *)s1;
00038   
00039   //For the site specified by "index", move an array of "count" data
00040   //from the read buffer to an array of fields
00041 
00042   for (int i=0;i<count;i++)
00043     {
00044       oFloat *dest = field[i] + len*index;
00045       for (int j=0; j<len; j++) dest[j] = src[i*len+j];
00046     }
00047 }
00048 
00049 // templatized version of vget_M to allow for precision conversion
00050 template <typename oFloat, typename iFloat, int len>
00051 void vgetM(char *s1, size_t index, int count, void *s2)
00052 {
00053   iFloat **field = (iFloat **)s2;
00054   oFloat *dest = (oFloat *)s1;
00055 
00056 /* For the site specified by "index", move an array of "count" data
00057    from the array of fields to the write buffer */
00058   for (int i=0; i<count; i++, dest+=18)
00059     {
00060       iFloat *src = field[i] + len*index;
00061       for (int j=0; j<len; j++) dest[j] = src[j];
00062     }
00063 }
00064 
00065 
00066 int vcreate_R(float *field_out[],int count);
00067 int vcreate_M(suN_matrix *field[] , int count);
00068 void vdestroy_R(float *field[], int count);
00069 void vdestroy_M(suN_matrix *field[], int count);
00070 void vset_R(float *field[],int count);
00071 void vset_M(suN_matrix *field[], int count);
00072 float vcompare_R(float *fielda[], float *fieldb[], int count);
00073 float vcompare_M(suN_matrix *fielda[], suN_matrix *fieldb[], int count);
00074 float vcompare_r(float arraya[], float arrayb[], int count);
00075 
00076 int qio_test(int output_volfmt, int output_serpar, int ildgstyle, 
00077              int input_volfmt, int input_serpar, int argc, char *argv[]);
00078 
00079 int qio_host_test(QIO_Filesystem *fs, int argc, char *argv[]);
00080 
00081 #endif /* QIO_TEST_H */
00082 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines