00001
00002
00003
00004
00005
00006
00007
00008 #ifndef GPU_JASTROWELECTRONELECTRON
00009 #define GPU_JASTROWELECTRONELECTRON
00010
00011 #ifdef QMC_GPU
00012
00013 #include <iostream>
00014 #include <stdlib.h>
00015 #include <assert.h>
00016 #include <math.h>
00017 #include <vector>
00018 #include <string>
00019 #include "GPUGlobals.h"
00020 #include "GPUQMCFramebuffer.h"
00021 #include "Array1D.h"
00022 #include "Array2D.h"
00023 #include "Stopwatch.h"
00024 #include "QMCJastrowElectronElectron.h"
00025
00026 class GPUQMCJastrowElectronElectron : public QMCJastrowElectronElectron, GPUGlobals
00027 {
00028 public:
00029
00030 GPUQMCJastrowElectronElectron();
00031
00032 GPUQMCJastrowElectronElectron(QMCJastrowElectronElectron jee, int max_calcs);
00033
00034 void operator=(const GPUQMCJastrowElectronElectron &rhs);
00035
00036 GLuint runCalculation(GLuint aElectronsTexID, GLuint bElectronsTexID, int num);
00037
00038 void unloadResults();
00039
00049 double getLnJastrow(int which);
00050
00061 Array2D<double> * getGradientLnJastrow(int which);
00062
00073 double getLaplacianLnJastrow(int which);
00074
00075 int getNumIterations();
00076
00077 ~GPUQMCJastrowElectronElectron();
00078
00079 private:
00080
00081 void setUpInputs();
00082
00083 string generatePolynomialShader(int which);
00084
00085 string generateTranslationShader(int which);
00086
00087 string generateReductionShader();
00088
00089 string generateGradientReductionShader(int which);
00090
00091 void translateElectronPositions(GLuint aElectronsTexID, GLuint bElectronsTexID);
00092
00093 void sumAllJastrowValues();
00094
00095 void sumGradJastrowValues();
00096
00097 void unloadData(GPUQMCFramebuffer & fb, int w, int h);
00098
00099 string coeffToCgString(Array1D<double> & input, string name);
00100
00101 void loadShaders();
00102
00111 void drawPrimative(GLfloat maxs, GLfloat maxt, GLfloat sShift, GLfloat tShift);
00112
00113 void drawTriangles(GLfloat maxs, GLfloat maxt, int nCols, int nRows);
00114
00115 static const int aa = 0;
00116 static const int bb = 1;
00117 static const int ab = 2;
00118
00123 int nRows, nCols;
00124
00129 int allocatedRows, allocatedCols;
00130
00135 int numE, numA, numB, numLarger;
00136
00140 int elecW, elecH;
00141
00142 Array1D<double> array_sum;
00143 Array1D< Array2D<double> > array_grad_sum;
00144 Array1D<double> array_lap_sum;
00145
00146 GLfloat * cpuData;
00147
00148 static vector<CGprogram> mapElectronsCG;
00149 static CGparameter mixedInputCGP;
00150 static vector<CGparameter> inputCGP;
00151
00152 static vector<CGprogram> polynomialCG;
00153 static vector<CGparameter> polyInputCGP;
00154
00155 static CGprogram sumReductionCG;
00156 static vector<CGparameter> sumReductionCGP;
00157
00158 static vector<CGprogram> gradientReductionCG;
00159 static vector<CGparameter> gradientReductionCGP;
00160
00161 GPUQMCFramebuffer * r1r2FB;
00162 GPUQMCFramebuffer * polynomialFB;
00163 GPUQMCFramebuffer * finalUandLapUFB;
00164 GPUQMCFramebuffer * finalGradUFB;
00165 };
00166 #endif
00167 #endif