51 #include <lapacke_utils.h> 57 #include "starsh-spatial.h" 61 #include "auxcompute_z.h" 62 #include "auxdescutil.h" 68 #define CBLAS_SADDR(_val) (_val) 77 #define PROGRESS(str) \ 79 int myrank = MORSE_My_Mpi_Rank();\ 81 tm_info = localtime(&timer); \ 82 strftime(datebuf, 26, "%Y-%m-%d %H:%M:%S",tm_info); \ 83 fprintf(stderr, "%d:%s\t%d\t%s\t%s\n", myrank, datebuf, __LINE__, __func__, str);\ 106 FILE* fp = fopen(file,
"w");
108 fprintf(stderr,
"File %s cannot be opened to write\n", file);
112 fprintf(fp,
"%d %d\n", m, n);
113 for(i = 0; i < m; i++){
114 for(j = 0; j < n; j++){
115 fprintf(fp,
"%d\t", (
int)arr[ld*j+i] );
122 double timediff(
struct timeval begin,
struct timeval end){
123 double elapsed = (end.tv_sec - begin.tv_sec) +
124 ((end.tv_usec - begin.tv_usec)/1000000.0);
134 if(MORSE_My_Mpi_Rank() != 0)
143 MORSE_user_tag_size(31,27);
200 int nrows_AUV = MTMB;
225 double fixedacc = pow(10, -1.0*iparam[
IPARAM_ACC]);
238 int initial_maxrank, final_maxrank;
239 double initial_avgrank, final_avgrank;
242 hicma_problem.
ndim = 2;
246 hicma_problem.
noise = 1.0;
258 hicma_problem.
theta = theta;
259 hicma_problem.
noise = 0.0;
260 hicma_problem.
noise = 1.e-2;
261 hicma_problem.
kernel_type = STARSH_SPATIAL_MATERN2_SIMD;
269 hicma_problem.
beta = 0.1;
273 hicma_problem.
nu = 0.5;
275 hicma_problem.
noise = 1.e-4;
276 hicma_problem.
noise = 5.e-4;
277 hicma_problem.
noise = 1.e-2;
285 hicma_problem.
diag = M;
290 PROGRESS(
"generating coordinates started");
291 struct timeval tvalBefore, tvalAfter;
292 gettimeofday (&tvalBefore, NULL);
293 HICMA_zgenerate_problem(probtype, sym, ddecay, M, MB, MT, NT, &hicma_problem);
294 gettimeofday (&tvalAfter, NULL);
295 if(MORSE_My_Mpi_Rank()==0){
296 printf(
"Tproblem:%g\n",
297 (tvalAfter.tv_sec - tvalBefore.tv_sec)
298 +(tvalAfter.tv_usec - tvalBefore.tv_usec)/1000000.0
303 PROGRESS(
"generating coordinates ended");
307 int compress_diag = 0;
310 gettimeofday (&tvalBefore, NULL);
311 HICMA_zgytlr_Tile(MorseLower, descAUV, descAD, descArk, 0, maxrank, fixedacc, compress_diag, descDense);
312 gettimeofday (&tvalAfter, NULL);
313 if(MORSE_My_Mpi_Rank()==0){
314 printf(
"Tcompress:%g\n",
315 (tvalAfter.tv_sec - tvalBefore.tv_sec)
316 +(tvalAfter.tv_usec - tvalBefore.tv_usec)/1000000.0
328 if(MORSE_My_Mpi_Rank()==0){
330 sprintf(rankfile,
"%s-1", rankfile);
331 fwrite_array(descArk->m, descArk->n, descArk->m, Ark_initial, rankfile);
334 zget_stat(MorseLower, Ark_initial, MT, NT, MT, &hicma_statrk_initial);
335 printf(
"initial_ranks:");
336 zprint_stat(hicma_statrk_initial);
343 fprintf(stderr,
"%s %d Fixed rank: %d\n", __FILE__, __LINE__,
global_fixed_rank);
347 fprintf(stderr,
"%s %d %d\t|N:%d is less than actual maxrank:%d\n", __FILE__, __LINE__, MORSE_My_Mpi_Rank(), N, initial_maxrank);
353 PROGRESS(
"pasting original dense descAD into Adense and Adense2 started");
356 double one = 1.0, zero = 0.0, minusone = -1.0, diagVal = M;
357 double* swork = NULL;
360 swork = calloc(2*M,
sizeof(
double));
362 double* orgAdense = calloc(LDA*M,
sizeof(
double));
363 for(j = 0; j < M; j++){
364 for(i = 0; i < M; i++){
365 orgAdense[j*LDA+i] = Adense[j*LDA+i];
368 int info = LAPACKE_dpotrf_work(
373 fprintf(stderr,
"%s\t|%d\t|Error in LAPACK potrf. info:%d, This errors means " 374 "that the matrix generated is not positive definite\n", __FILE__, __LINE__, info);
376 for(j = 0; j < M; j++){
377 for(i = 0; i < j; i++){
378 orgAdense[j*LDA+i] = zero;
386 if(
main_print_mat ){printf(
"L of Adense\n");printmat(orgAdense,M,M,LDA,MB, MB);}
387 double normOrgAdense = 0.0;
394 PROGRESS(
"pasting original dense descAD into Adense and Adense2 finished");
397 HICMA_zpotrf_Tile(MorseLower, descAUV, descAD, descArk, fixedrank, maxrank, fixedacc );
403 HICMA_zuncompress(MorseLower, descAUV, descDense, descArk);
404 HICMA_zdiag_vec2mat(descAD, descDense);
412 if(MORSE_My_Mpi_Rank()==0){
413 sprintf(rankfile,
"%s-2", rankfile);
414 fwrite_array(descArk->m, descArk->n, descArk->m, Ark_final, rankfile);
416 zget_stat(MorseLower, Ark_final, MT, NT, MT, &hicma_statrk_final);
417 printf(
"final_ranks:");
418 zprint_stat(hicma_statrk_final);
427 check_dense = check_app = 0;
431 if( MORSE_My_Mpi_Rank()==0){
433 if(
main_print_mat){printf(
"Adense2\n");printmat(Adense2,M,M,LDA,MB, MB);}
436 for(j = 0; j < M; j++){
437 for(i = 0; i < j; i++){
438 Adense2[j*LDA+i] = zero;
443 HICMA_znormest(M, M, Adense2, &normA, swork);
453 double normAhicma = 0.0;
455 for(j = 0; j < M; j++){
456 for(i = 0; i < j; i++){
457 Ahicma[j*LDA+i] = zero;
460 double* orgAhicma = calloc(LDA*M,
sizeof(
double));
461 for(j = 0; j < M; j++){
462 for(i = 0; i < M; i++){
463 orgAhicma[j*LDA+i] = Ahicma[j*LDA+i];
466 HICMA_znormest(M, M, orgAhicma, &normAhicma, swork);
469 if(set_diag){
size_t j;
for(j = 0; j < M; j++){ Ahicma[j*LDA+j] = diagVal; } }
470 if(
main_print_mat){printf(
"Ahicma\n");printmat(Ahicma,M,M,LDA, MB, MB);}
473 PROGRESS(
"copy descAd into AhicmaT started");
477 for(j = 0; j < M; j++){
478 for(i = 0; i < j; i++){
479 Adense[j*LDA+i] = zero;
484 if(
main_print_mat){printf(
"Ahicma-upperzero\n");printmat(Ahicma,M,M,LDA, MB, MB);}
486 LAPACKE_dge_trans(LAPACK_COL_MAJOR, M, M, Ahicma, LDA, AhicmaT, LDA);
487 if(
main_print_mat){printf(
"AhicmaT\n");printmat(AhicmaT,M,M,LDA, MB, MB);}
489 cblas_dtrmm (CblasColMajor, CblasLeft, CblasLower, CblasNoTrans, CblasNonUnit, M, M, one, Ahicma, LDA, AhicmaT, LDA);
490 if(
main_print_mat){printf(
"Ahicma*AhicmaT\n");printmat(AhicmaT,M,M,LDA, MB, MB);}
493 for(j = 0; j < M; j++){
494 for(i = 0; i < j; i++){
495 AhicmaT[j*LDA+i] = zero;
503 cblas_daxpy(nelm, minusone, AhicmaT, 1, Adense, 1);
504 if(
main_print_mat){printf(
"Adense-(Ahicma*AhicmaT)\n");printmat(Adense,M,M,LDA, MB, MB);}
506 double normDenseAppDiff;
507 PROGRESS(
"Norm of difference started");
508 HICMA_znormest(M, M, Adense, &normDenseAppDiff, swork);
509 double accuracyDenseAppDiff = normDenseAppDiff/normA;
520 PROGRESS(
"checking accuracy is finished");
#define PASTE_CODE_ALLOCATE_MATRIX_TILE(_desc_, _cond_, _type_, _type2_, _lda_, _m_, _n_)
int global_always_fixed_rank
#define HICMA_STARSH_PROB_EDSIN
#define PASTE_TILE_TO_LAPACK(_desc_, _name_, _cond_, _type_, _lda_, _n_)
#define HICMA_STARSH_PROB_GEOSTAT
#define PASTE_CODE_FREE_MATRIX(_desc_)
#define HICMA_STARSH_PROB_RND
void fwrite_array(int m, int n, int ld, double *arr, char *file)
int RunTest(int *iparam, double *dparam, morse_time_t *t_, char *rankfile)
STARSH_blrf * starsh_format
int store_only_diagonal_tiles
int global_omit_computation
int HICMA_zgytlr_Tile(MORSE_enum uplo, MORSE_desc_t *AUV, MORSE_desc_t *AD, MORSE_desc_t *Ark, unsigned long long int seed, int maxrank, double tol, int compress_diag, MORSE_desc_t *Dense)
#define HICMA_STARSH_PROB_SS
int HICMA_zpotrf_Tile(MORSE_enum uplo, MORSE_desc_t *AUV, MORSE_desc_t *AD, MORSE_desc_t *Ark, int rk, int maxrk, double acc)
double timediff(struct timeval begin, struct timeval end)
#define PASTE_CODE_IPARAM_LOCALS(iparam)