IPCC  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CLanczosLaunching Class Reference

This class includes functions for matrix debugging. More...

#include "LanczosLaunching.h"

Collaboration diagram for CLanczosLaunching:
Collaboration graph

Classes

struct  LANCZOS_PARAM
 Structure for Lanczos parameters. More...
 

Public Types

typedef struct
CLanczosLaunching::LANCZOS_PARAM
LPLANCZOS_PARAM
 

Public Member Functions

 CLanczosLaunching ()
 
 ~CLanczosLaunching ()
 

Static Public Member Functions

static
CLanczosMethod::LPEIGENVALUE_RESULT 
LaunchingLanczos (CMatrixOperation::CCSR *pA, bool bShowMsg, LPLANCZOS_PARAM lpParam, bool bMPI)
 Lanczos API entry function. More...
 

Detailed Description

This class includes functions for matrix debugging.

Date
10/July/2014

Definition at line 17 of file LanczosLaunching.h.

Member Typedef Documentation

Constructor & Destructor Documentation

CLanczosLaunching::CLanczosLaunching ( )

Definition at line 25 of file LanczosLaunching.cpp.

26 {
27 }
CLanczosLaunching::~CLanczosLaunching ( )

Definition at line 29 of file LanczosLaunching.cpp.

30 {
31 }

Member Function Documentation

CLanczosMethod::LPEIGENVALUE_RESULT CLanczosLaunching::LaunchingLanczos ( CMatrixOperation::CCSR pA,
bool  bShowMsg,
LPLANCZOS_PARAM  lpParam,
bool  bMPI 
)
static

Lanczos API entry function.

Parameters
pACSR matrix for eigenvalue solving
bShowMsgFlag for display message
lpParamSeveral parameters for Lanczos method setting
bMPIApplying MPI environment or not

< Remove output directory first

< Launching lanczos method

Definition at line 39 of file LanczosLaunching.cpp.

References CMatrixOperation::AllocateLocalCSR(), CLanczosLaunching::LANCZOS_PARAM::bCalculateEigenVectors, CLanczosLaunching::LANCZOS_PARAM::bCalculateWaveFunction, CLanczosLaunching::LANCZOS_PARAM::bDoSelectiveReorthogonalization, CLanczosLaunching::LANCZOS_PARAM::bSaveResultToFile, CMatrixOperation::BuildLocalCSR(), CALCULATION_SUCCESS, CLanczosMethod::DoLanczosMethod(), CLanczosLaunching::LANCZOS_PARAM::fConvergeceCriteria, CLanczosLaunching::LANCZOS_PARAM::fevMax, CLanczosLaunching::LANCZOS_PARAM::fevMin, CMatrixOperation::FreeLocalCSR(), CMPIManager::GetCurrentRank(), CMatrixOperation::CCSR::GetNoneZeroCount(), CMPIManager::GetTotalNodeCount(), CMPIManager::InitCommunicationBufferMetric(), CMPIManager::InitLevel(), CMPIManager::IsMultiLevelMPI(), CMPIManager::IsRootRank(), CLanczosLaunching::LANCZOS_PARAM::load_in_MIC, CMatrixOperation::CCSR::m_vectColumn, CMatrixOperation::CCSR::m_vectRow, CMatrixOperation::CCSR::m_vectValueImaginaryBuffer, CMatrixOperation::CCSR::m_vectValueRealBuffer, CLanczosMethod::MergeDegeneratedEigenvalues(), CLanczosLaunching::LANCZOS_PARAM::nCheckEigenvalueInterval, CLanczosLaunching::LANCZOS_PARAM::nFindingDegeneratedEVCount, CLanczosLaunching::LANCZOS_PARAM::nFindingEigenValueCount, CLanczosLaunching::LANCZOS_PARAM::nLanczosIterationCount, CLanczosLaunching::LANCZOS_PARAM::nMPILevel, phi_tid, CLanczosMethod::RecalcuWaveFunction(), CLanczosMethod::SaveLanczosResult(), CLanczosMethod::SetLBIndex(), CMPIManager::SetMPIEnviroment(), CUtility::SetShow(), SHOW_SIMPLE_MSG, CLanczosMethod::ShowLanczosResult(), CLanczosMethod::ShowLanczosWorkingTime(), CUtility::ShowMsg(), CTimeMeasurement::TotalMeasurementEnd(), CTimeMeasurement::TotalMeasurementStart(), and CMatrixOperation::UpdateLocalCSR().

40 {
41  CMatrixOperation::CCSR *pHamiltonian = pA;
42  CMatrixOperation::CCSR *plocalH = NULL;
43  CMatrixOperation::CCSR *plocalHm1 = NULL;
44  CMatrixOperation::CCSR *plocalHp1 = NULL;
45  unsigned int nRtnCode = CALCULATION_SUCCESS;
46  unsigned int nRepeatCount = 1;
48  CLanczosMethod lanczos;
49  char szMsg[1024];
50  double *pKValue[3] = {NULL, NULL, NULL};
51  int nLBIndex = 0;
52 
53  if (bShowMsg)
54  CUtility::SetShow(true);
55 
56  int rank;
57  int world_size;
58 
59  if (bMPI)
60  {
61  MPI_Comm_size(MPI_COMM_WORLD, &world_size);
62  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
63 
64  CMPIManager::SetMPIEnviroment(rank, world_size);
65  if (!CMPIManager::InitLevel(lpParam->nMPILevel, lpParam->nFindingDegeneratedEVCount))
66  {
67  SHOW_SIMPLE_MSG("Adjusting MPI level and node count first!\n");
68  return lpResult;
69  }
71  lanczos.SetLBIndex(nLBIndex);
72  }
73 
74 
76  {
77 #ifdef _WIN32
78  system("rmdir /s /q result");
79 #else //WIN32
80  system("rm -rf result");
81 #endif //WIN32
82 
83 #pragma omp parallel
84 {
85  if(omp_get_num_threads() > 1)
86  {
87  if(omp_get_thread_num() == 0)
88  {
89  sprintf(szMsg, "-Run with MPI (%d cores) and OpenMP (%d threads)\n", CMPIManager::GetTotalNodeCount(), omp_get_num_threads());
90  CUtility::ShowMsg(szMsg);
91  }
92  }
93  else
94  {
95  sprintf(szMsg, "-Run with MPI only (%d cores)\n", CMPIManager::GetTotalNodeCount());
96  CUtility::ShowMsg(szMsg);
97  }
98 }
99  }
100 
102  CMatrixOperation::AllocateLocalCSR(&plocalH, &plocalHm1, &plocalHp1, nLBIndex);
103 
104 
105 #ifndef DISABLE_MPI_ROUTINE
107 // FIXME test code
108 #ifndef _WIN32
109  char host_name[256];
110  gethostname(host_name, 256);
111  //printf("[%s] MPI rank: %d | phi tid: %d\n", host_name, CMPIManager::GetCurrentRank(), phi_tid);
112 #endif //_WIN32
113 #else
114  phi_tid = 0;
115 #endif
116 
117  double *local_real = NULL;
118  double *local_imaginary = NULL;
119  unsigned int *local_row = NULL;
120  unsigned int *local_col = NULL;
121  unsigned int local_size = 0;
122  unsigned int local_row_size = 0;
123  unsigned int local_col_size = 0;
124 
125  double *left_real = NULL;
126  double *left_imaginary = NULL;
127  unsigned int *left_row = NULL;
128  unsigned int *left_col = NULL;
129  unsigned int left_size = 0;
130  unsigned int left_row_size = 0;
131  unsigned int left_col_size = 0;
132 
133  double *right_real = NULL;
134  double *right_imaginary = NULL;
135  unsigned int *right_row = NULL;
136  unsigned int *right_col = NULL;
137  unsigned int right_size = 0;
138  unsigned int right_row_size = 0;
139  unsigned int right_col_size = 0;
140 
141 #ifdef USE_XEONPHI
143  {
144  CMatrixOperation::BuildLocalCSR(pHamiltonian, plocalH, plocalHm1, plocalHp1);
145  SHOW_SIMPLE_MSG("-Local matrices built\n");
146 
147  local_real = plocalH->m_vectValueRealBuffer.data();
148  local_imaginary = plocalH->m_vectValueImaginaryBuffer.data();
149  local_row = plocalH->m_vectRow.data();
150  local_col = plocalH->m_vectColumn.data();
151  local_size = plocalH->GetNoneZeroCount();
152  local_row_size = plocalH->m_vectRow.size();
153  local_col_size = plocalH->m_vectColumn.size();
154 #pragma offload_transfer target(mic:phi_tid) \
155  nocopy(local_real[0:local_size] : ALLOC) \
156  nocopy(local_imaginary[0:local_size] : ALLOC) \
157  nocopy(local_row[0:local_row_size] : ALLOC) \
158  nocopy(local_col[0:local_col_size] : ALLOC)
159 
160  left_real = plocalHm1->m_vectValueRealBuffer.data();
161  left_imaginary = plocalHm1->m_vectValueImaginaryBuffer.data();
162  left_row = plocalHm1->m_vectRow.data();
163  left_col = plocalHm1->m_vectColumn.data();
164  left_size = plocalHm1->GetNoneZeroCount();
165  left_row_size = plocalHm1->m_vectRow.size();
166  left_col_size = plocalHm1->m_vectColumn.size();
167 #pragma offload_transfer target(mic:phi_tid) \
168  nocopy(left_real[0:left_size] : ALLOC) \
169  nocopy(left_imaginary[0:left_size] : ALLOC) \
170  nocopy(left_row[0:left_row_size] : ALLOC) \
171  nocopy(left_col[0:left_col_size] : ALLOC)
172 
173 // FIXME jinpil: error occurred without the following statement
174 // error message: "offload error: unexpected variable type"
175 // any statements with side effects can also avoid the error, e.g. MPI_Barrier(MPI_COMM_WORLD)
176  SHOW_SIMPLE_MSG("-Xeon Phi: mem alloc\n");
177 // the following statement cannot avoid the error
178 // compiler bug?
179 // int dummy = 0;
180 // -----
181 
182  right_real = plocalHp1->m_vectValueRealBuffer.data();
183  right_imaginary = plocalHp1->m_vectValueImaginaryBuffer.data();
184  right_row = plocalHp1->m_vectRow.data();
185  right_col = plocalHp1->m_vectColumn.data();
186  right_size = plocalHp1->GetNoneZeroCount();
187  right_row_size = plocalHp1->m_vectRow.size();
188  right_col_size = plocalHp1->m_vectColumn.size();
189 #pragma offload_transfer target(mic:phi_tid) \
190  nocopy(right_real[0:right_size] : ALLOC) \
191  nocopy(right_imaginary[0:right_size] : ALLOC) \
192  nocopy(right_row[0:right_row_size] : ALLOC) \
193  nocopy(right_col[0:right_col_size] : ALLOC)
194  }
195  else
196  {
197  local_real = pHamiltonian->m_vectValueRealBuffer.data();
198  local_imaginary = pHamiltonian->m_vectValueImaginaryBuffer.data();
199  local_row = pHamiltonian->m_vectRow.data();
200  local_col = pHamiltonian->m_vectColumn.data();
201  local_size = pHamiltonian->GetNoneZeroCount();
202  local_row_size = pHamiltonian->m_vectRow.size();
203  local_col_size = pHamiltonian->m_vectColumn.size();
204 #pragma offload_transfer target(mic:phi_tid) \
205  nocopy(local_real[0:local_size] : ALLOC) \
206  nocopy(local_imaginary[0:local_size] : ALLOC) \
207  nocopy(local_row[0:local_row_size] : ALLOC) \
208  nocopy(local_col[0:local_col_size] : ALLOC)
209  }
210 
211 #endif // USE_XEONPHI
212 
214  {
215  CMatrixOperation::UpdateLocalCSR(pHamiltonian, plocalH, plocalHm1, plocalHp1);
216  SHOW_SIMPLE_MSG("-Local matrices updated\n");
217 
218 #ifdef USE_XEONPHI
219 
220 #pragma offload_transfer target(mic:phi_tid) \
221  in(local_real[0:local_size] : REUSE) \
222  in(local_imaginary[0:local_size] : REUSE) \
223  in(local_row[0:local_row_size] : REUSE) \
224  in(local_col[0:local_col_size] : REUSE)
225 
226 #pragma offload_transfer target(mic:phi_tid) \
227  in(left_real[0:left_size] : REUSE) \
228  in(left_imaginary[0:left_size] : REUSE) \
229  in(left_row[0:left_row_size] : REUSE) \
230  in(left_col[0:left_col_size] : REUSE)
231 
232 #pragma offload_transfer target(mic:phi_tid) \
233  in(right_real[0:right_size] : REUSE) \
234  in(right_imaginary[0:right_size] : REUSE) \
235  in(right_row[0:right_row_size] : REUSE) \
236  in(right_col[0:right_col_size] : REUSE)
237 
238 #endif // USE_XEONPHI
239  }
240  else
241  {
242 
243 #ifdef USE_XEONPHI
244 
245 #pragma offload_transfer target(mic:phi_tid) \
246  in(local_real[0:local_size] : REUSE) \
247  in(local_imaginary[0:local_size] : REUSE) \
248  in(local_row[0:local_row_size] : REUSE) \
249  in(local_col[0:local_col_size] : REUSE)
250 
251 #endif // USE_XEONPHI
252  }
253 
256  lpResult = lanczos.DoLanczosMethod(pHamiltonian,
257  lpParam->nLanczosIterationCount,
258  lpParam->nCheckEigenvalueInterval,
259  lpParam->nFindingEigenValueCount,
260  lpParam->fevMin,
261  lpParam->fevMax,
262  lpParam->fConvergeceCriteria,
263  lpParam->bDoSelectiveReorthogonalization,
264  lpParam->bCalculateEigenVectors,
265  lpParam->bCalculateWaveFunction,
266  lpParam->load_in_MIC,
267  plocalH, // ADDED
268  plocalHm1, // ADDED
269  plocalHp1);// ADDED
270 
272  {
273  lanczos.MergeDegeneratedEigenvalues(lpResult, lpParam->nFindingDegeneratedEVCount, pHamiltonian, plocalH, plocalHm1, plocalHp1);
274  if( lpParam->bCalculateWaveFunction )
275  lanczos.RecalcuWaveFunction(lpResult);
276  }
277 
278  if( lpParam->bSaveResultToFile )
279  {
281  CUtility::ShowMsg("\n-Save result into file\n");
282 
283  CLanczosMethod::SaveLanczosResult(lpResult, lpParam->bCalculateEigenVectors, lpParam->bCalculateWaveFunction, NULL, 0);
284  }
285 
287 
288  CLanczosMethod::ShowLanczosResult(lpResult, lpParam->bCalculateEigenVectors, lpParam->bCalculateWaveFunction, NULL, 0);
290 
292  SHOW_SIMPLE_MSG("\n-Finished Lanczos eigenvalue solver.\n\n");
293 
295  {
296  CMatrixOperation::FreeLocalCSR(plocalH, plocalHm1, plocalHp1);
297 
298 #ifdef USE_XEONPHI
299 
300 #pragma offload_transfer target(mic:phi_tid) \
301  nocopy(local_real : FREE) \
302  nocopy(local_imaginary : FREE) \
303  nocopy(local_row : FREE) \
304  nocopy(local_col : FREE)
305 
306 #pragma offload_transfer target(mic:phi_tid) \
307  nocopy(left_real : FREE) \
308  nocopy(left_imaginary : FREE) \
309  nocopy(left_row : FREE) \
310  nocopy(left_col : FREE)
311 
312 #pragma offload_transfer target(mic:phi_tid) \
313  nocopy(right_real : FREE) \
314  nocopy(right_imaginary : FREE) \
315  nocopy(right_row : FREE) \
316  nocopy(right_col : FREE)
317 
318 #endif // USE_XEONPHI
319 
320  }
321  else
322  {
323 
324 #ifdef USE_XEONPHI
325 
326 #pragma offload_transfer target(mic:phi_tid) \
327  nocopy(local_real : FREE) \
328  nocopy(local_imaginary : FREE) \
329  nocopy(local_row : FREE) \
330  nocopy(local_col : FREE)
331 
332 #endif
333  }
334 
335  return lpResult;
336 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
LPEIGENVALUE_RESULT DoLanczosMethod(CMatrixOperation::CCSR *pAMatrix, unsigned int nIterationCount, unsigned int nEigenValueCheckInterval, unsigned int nEigenValueCount, double fEigenvalueMin, double fEignevalueMax, double fConvergenceTolerance, bool bReorthogonalization, bool bCalcuEigVector, bool bWaveFunction, double load_in_MIC, CMatrixOperation::CCSR *pmylocalblock=NULL, CMatrixOperation::CCSR *leftlocalblock=NULL, CMatrixOperation::CCSR *rightlocalblock=NULL)
Doing lanczos method.
static void ShowLanczosResult(CLanczosMethod::LPEIGENVALUE_RESULT lpResult, bool bCalculateEigenVectors, bool bCalculateWaveFunction, double *pKValue, int nRepeatCount)
Showing calculating result into screen.
int phi_tid
Definition: TBMS_Solver.cpp:30
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
static void UpdateLocalCSR(CMatrixOperation::CCSR *source, CMatrixOperation::CCSR *mine, CMatrixOperation::CCSR *left, CMatrixOperation::CCSR *right)
static void AllocateLocalCSR(CMatrixOperation::CCSR **mine, CMatrixOperation::CCSR **left, CMatrixOperation::CCSR **right, int nLBIndex)
static void BuildLocalCSR(CMatrixOperation::CCSR *source, CMatrixOperation::CCSR *mine, CMatrixOperation::CCSR *left, CMatrixOperation::CCSR *right)
static void TotalMeasurementStart()
Measurement start for total taken time.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
static void SetMPIEnviroment(int nRank, int nTotalNode)
Set MPI Enviroment.
Definition: MPIManager.cpp:141
#define CALCULATION_SUCCESS
Return code at main loop, every steps completed.
Definition: Global.h:70
static void SaveLanczosResult(CLanczosMethod::LPEIGENVALUE_RESULT lpResult, bool bCalcuEigenvalue, bool bWaveFunction, double *pKValue, int nRepeatCount)
Saving Lanczos computation result into file.
static int GetTotalNodeCount()
Definition: MPIManager.h:42
static void TotalMeasurementEnd()
Measurement end for total taken time.
static int GetCurrentRank()
Definition: MPIManager.h:40
static int InitCommunicationBufferMetric()
Initializing MPI Communication buffer for MVMul.
Definition: MPIManager.cpp:655
static bool IsMultiLevelMPI()
Get MPI_Comm.
Definition: MPIManager.h:65
void RecalcuWaveFunction(CLanczosMethod::LPEIGENVALUE_RESULT lpResult)
Recalculating wavefunction after merging degenerated eigenvalues.
void MergeDegeneratedEigenvalues(CLanczosMethod::LPEIGENVALUE_RESULT lpResult, unsigned int nFindingDegeneratedEVCount, CMatrixOperation::CCSR *pA, CMatrixOperation::CCSR *pLocalBlock, CMatrixOperation::CCSR *pLeftBlock, CMatrixOperation::CCSR *pRightBlock)
Merging eigenvalue into mater group.
static bool InitLevel(int nMPILevel, int nFindingDegeneratedEVCount)
Init MPI Level, most low level is for multi node cacluation for Lanczos.
Definition: MPIManager.cpp:53
Structure for engienvalue computing.
Definition: LanczosMethod.h:28
static void FreeLocalCSR(CMatrixOperation::CCSR *mine, CMatrixOperation::CCSR *left, CMatrixOperation::CCSR *right)
static void SetShow(bool bShow)
Definition: Utility.h:29
Data and operation representation of CSR(Compressed Sparse Row)
void SetLBIndex(int nLBIndex)
Definition: LanczosMethod.h:55
static void ShowMsg(char *pszBuffer)
Show message.
Definition: Utility.cpp:34
This class for doing Lanczos method.
Definition: LanczosMethod.h:18
uint_vector_t m_vectColumn
A member variable for saving column information.
static void ShowLanczosWorkingTime()
Showing operation time into screen.
uint_vector_t m_vectRow
A member variable for saving row information.
#define SHOW_SIMPLE_MSG(message)
Definition: Global.h:40

Here is the call graph for this function:


The documentation for this class was generated from the following files: