-
Notifications
You must be signed in to change notification settings - Fork 5
/
ccsd.h
152 lines (119 loc) · 3.77 KB
/
ccsd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
*@BEGIN LICENSE
*
* GPU-accelerated density-fitted coupled-cluster, a plugin to:
*
* PSI4: an ab initio quantum chemistry software package
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*@END LICENSE
*/
#ifndef PLUGIN_CCSD_H
#define PLUGIN_CCSD_H
#include<psi4/libpsi4util/PsiOutStream.h>
#include<pthread.h>
#include<sys/types.h>
#include<psi4/psi4-dec.h>
#include<psi4/libiwl/iwl.h>
#include<psi4/libpsio/psio.hpp>
#include<psi4/libpsio/psio.h>
#include<psi4/libmints/wavefunction.h>
#include<psi4/psifiles.h>
#include<sys/times.h>
#include"gpuhelper.h"
// cuda libraries
#include<cuda.h>
#include<cublas.h>
#include<cuda_runtime.h>
// header for DFCoupledCluster
#include"dfcc_fnocc.h"
typedef struct {
int id;
} parm;
namespace psi{ namespace fnocc{
// GPU DFCC class
class GPUDFCoupledCluster : public DFCoupledCluster{
public:
GPUDFCoupledCluster(std::shared_ptr<psi::Wavefunction>wfn,Options&options);
~GPUDFCoupledCluster();
virtual bool same_a_b_orbs() const { return true; }
virtual bool same_a_b_dens() const { return true; }
double compute_energy();
void common_init();
void pthreadCCResidual(int id);
protected:
/// t1-transformed 3-index integrals
void T1Integrals();
/// t1-transformed 3-index integrals (from SCF) for Fock build
void T1Fock();
/// cc diagrams:
virtual void CCResidual();
//virtual void saveCCResidual();
/// extra storage for gpu (ac|bd) function: 1/2o(o+1)v(v+1)
double * tempr, ** tempr2;
void useVabcd1();
void workinguseVabcd1();
/// triples
PsiReturnType triples();
/// (ac|bd) diagram - this will be the first target to gpuify
void brokenVabcd1();
void tiledVabcd1();
void slowVabcd1();
void saveVabcd1();
void workingVabcd1();
void cpuVabcd1();
void nearlythereVabcd1();
virtual void Vabcd1();
void FinishVabcd1();
void UpdateT2();
/// initialize cuda
void CudaInit();
/// initialize cuda
void CudaFinalize();
/// define tiling based on available gpu memory
void DefineTiling();
/// allocate memory for gpu
void AllocateGPUMemory();
/// allocate memory for cpu
virtual void AllocateMemory();
pthread_t base_thread;
/// gpu buffers
double ** gpubuffer;
//double * gput2;
//double * gpuv;
//double * gpur2;
//double * gputemp;
//double * gput1;
//double * gpur1;
/// GPU-specific variables ... some are obsolete
int num_gpus;
std::vector<int> gpus_used;
double left, wasted;
long int ovtilesize, novtiles, lastovtile, lastov2tile, ov2tilesize, nov2tiles;
long int tilesize, ntiles, lasttile;
long int ncputhreads,ngputhreads, nblocks, num;
bool gpudone;
bool cpudone;
long int last_a;
std::shared_ptr<GPUHelper> helper_;
//__global__ void GPUKernel_Iqdb(int a,int v,int nQ,double * in,double * out);
};
/// GPU kernels
//__global__ void GPUKernel_Iqdb(int a,int v,int nQ,double * in,double * out);
//__global__ void GPUKernel_Vm(int a,int v,double * in,double * out);
//__device__ int GPUKernel_Position(int i,int j);
}}
#endif