SpM Handbook 1.2.4
Loading...
Searching...
No Matches
s_spm_genmat.c
Go to the documentation of this file.
1/**
2 *
3 * @file s_spm_genmat.c
4 *
5 * SParse Matrix package matrix generators.
6 *
7 * @copyright 2016-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8 * Univ. Bordeaux. All rights reserved.
9 *
10 * @version 1.2.4
11 * @author Mathieu Faverge
12 * @author Tony Delarue
13 * @author Alycia Lisito
14 * @date 2024-06-25
15 *
16 * @generated from /builds/2mk6rsew/0/fpruvost/spm/src/z_spm_genmat.c, normal z -> s, Fri Nov 29 11:34:30 2024
17 **/
18#include "common.h"
19#include <cblas.h>
20#include <lapacke.h>
21
22#ifndef DOXYGEN_SHOULD_SKIP_THIS
23#define Rnd64_A 6364136223846793005ULL
24#define Rnd64_C 1ULL
25#define RndF_Mul 5.4210108624275222e-20f
26#define RndD_Mul 5.4210108624275222e-20
27#endif /* DOXYGEN_SHOULD_SKIP_THIS */
28
29/**
30 *******************************************************************************
31 *
32 * @ingroup spm_dev_rhs
33 *
34 * @brief Random generator from the HPL library
35 *
36 *******************************************************************************
37 *
38 * @param[in] n
39 * Number of elements to jump over in the generator cycle.
40 *
41 * @param[in] seed
42 *
43 *******************************************************************************
44 *
45 * @retval a random integer value
46 *
47 *******************************************************************************/
48static inline unsigned long long int
49Rnd64_jump( unsigned long long int n,
50 unsigned long long int seed )
51{
52 unsigned long long int a_k, c_k, ran;
53 int i;
54
55 a_k = Rnd64_A;
56 c_k = Rnd64_C;
57
58 ran = seed;
59 for (i = 0; n; n >>= 1, ++i) {
60 if (n & 1) {
61 ran = a_k * ran + c_k;
62 }
63 c_k *= (a_k + 1);
64 a_k *= a_k;
65 }
66
67 return ran;
68}
69
70#ifndef DOXYGEN_SHOULD_SKIP_THIS
71#if defined(PRECISION_z) || defined(PRECISION_c)
72#define NBELEM 2
73#else
74#define NBELEM 1
75#endif
76#endif /* DOXYGEN_SHOULD_SKIP_THIS */
77
78/**
79 *******************************************************************************
80 *
81 * @ingroup spm_dev_rhs
82 *
83 * @brief Generate a value of the RHS
84 *
85 *******************************************************************************
86 *
87 * @param[in] scale
88 * Scaling factor for each randomized value.
89 *
90 * @param[inout] val
91 * The value that will be updated
92 *
93 * @param[inout] ran
94 * The current random value.
95 *
96 ******************************************************************************/
97static inline void
98s_updateRndVal( float scale,
99 float *val,
100 unsigned long long int *ran )
101{
102 *val = (0.5f - (*ran) * RndF_Mul);
103 *ran = Rnd64_A * (*ran) + Rnd64_C;
104#if defined(PRECISION_z) || defined(PRECISION_c)
105 *val += I * (0.5f - (*ran) * RndF_Mul);
106 *ran = Rnd64_A * (*ran) + Rnd64_C;
107#endif
108 *val *= scale;
109}
110
111/**
112 *******************************************************************************
113 *
114 * @ingroup spm_dev_rhs
115 *
116 * @brief Generate a set of vectors of random values in shared memory.
117 *
118 *******************************************************************************
119 *
120 * @param[in] spm
121 * The sparse matrix associated to the right hand side.
122 *
123 * @param[in] scale
124 * Scaling factor for each value of the vector.
125 *
126 * @param[in] n
127 * The number of columns in A. n >= 0.
128 *
129 * @param[inout] A
130 * On entry, the lda-by-n matrix to be initialized.
131 * On exit, the matrix initialized.
132 *
133 * @param[in] lda
134 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
135 *
136 * @param[in] shift
137 * The initial shift in the random sequence.
138 *
139 * @param[in] seed
140 * The seed used for random generation. Must be the same for
141 * all tiles initialized with this routine.
142 *
143 *******************************************************************************
144 *
145 * @retval SPM_SUCCESS to match prototype of equivalent function
146 *
147 ******************************************************************************/
148int
150 float scale,
151 spm_int_t n,
152 float *A,
153 spm_int_t lda,
154 int shift,
155 unsigned long long int seed )
156{
157 float *tmp = A;
158 int64_t i, j, m = spm->nexp;
159 unsigned long long int ran, jump = shift;
160
161 /*
162 * Global version : the RHS is contiguous. The jump can follow the vector.
163 */
164 for (j=0; j<n; ++j) {
165 ran = Rnd64_jump( NBELEM*jump, seed );
166 for (i = 0; i < m; ++i) {
167 s_updateRndVal( scale, tmp, &ran );
168 tmp++;
169 }
170 jump += spm->gNexp;
171 tmp += lda - spm->nexp;
172 }
173
174 return SPM_SUCCESS;
175}
176
177/**
178 *******************************************************************************
179 *
180 * @brief Generate a set of vectors of random values in
181 * distributed memory for CSX format.
182 *
183 *******************************************************************************
184 *
185 * @param[in] spm
186 * The sparse matrix associated to the right hand side.
187 *
188 * @param[in] alpha
189 * Scaling factor for each value of the vector.
190 *
191 * @param[in] n
192 * The number of columns in A. n >= 0.
193 *
194 * @param[inout] A
195 * On entry, the lda-by-n matrix to be initialized.
196 * On exit, the matrix initialized.
197 *
198 * @param[in] lda
199 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
200 *
201 * @param[in] shift
202 * The initial shift in the random sequence.
203 *
204 * @param[in] seed
205 * The seed used for random generation. Must be the same for
206 * all tiles initialized with this routine.
207 *
208 *******************************************************************************
209 *
210 * @retval SPM_SUCCESS on success
211 * @retval SPM_ERR_BADPARAMETER if the provided spm is incorrect
212 *
213 ******************************************************************************/
214static inline int
216 float alpha,
217 spm_int_t n,
218 float *A,
219 spm_int_t lda,
220 int shift,
221 unsigned long long int seed )
222{
223 float *tmp = A;
224 spm_int_t i, j, k, ig, dofi;
225 spm_int_t row, col;
226 unsigned long long int ran, jump;
227 const spm_int_t *l2g;
228 const spm_int_t *dofs = spm->dofs;
229 spm_int_t baseval = spm->baseval;
230
231 assert( !spm->replicated );
232 assert( NULL != spm->loc2glob );
233
234 /*
235 * Distributed version : the RHS might be distributed in a non-contiguous
236 * way, so the jump have to be recomputed with global index for each element.
237 */
238 for (j=0, col=0; j<n; j++, col++) {
239 tmp = A + j * lda;
240 l2g = spm->loc2glob;
241 for (i=0; i<spm->n; i++, l2g++ ) {
242 ig = *l2g - baseval;
243 if ( spm->dof > 0 ) {
244 dofi = spm->dof;
245 row = spm->dof * ig;
246 }
247 else {
248 dofi = dofs[ig+1] - dofs[ig];
249 row = dofs[ig] - baseval;
250 }
251
252 jump = row + col * (unsigned long long int)(spm->gNexp) + shift;
253 ran = Rnd64_jump( NBELEM*jump, seed );
254
255 for( k=0; k<dofi; k++, tmp++ ) {
256 s_updateRndVal( alpha, tmp, &ran );
257 }
258 }
259 }
260 return SPM_SUCCESS;
261}
262
263/**
264 *******************************************************************************
265 *
266 * @brief Generate a set of vectors of random values in
267 * distributed memory for IJV format.
268 *
269 * @warning The matrix has to be sorted by column or by row.
270 *
271 *******************************************************************************
272 *
273 * @param[in] spm
274 * The sparse matrix associated to the right hand side.
275 *
276 * @param[in] alpha
277 * Scaling factor for each value of the vector.
278 *
279 * @param[in] n
280 * The number of columns in A. n >= 0.
281 *
282 * @param[inout] A
283 * On entry, the lda-by-n matrix to be initialized.
284 * On exit, the matrix initialized.
285 *
286 * @param[in] lda
287 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
288 *
289 * @param[in] shift
290 * The initial shift in the random sequence.
291 *
292 * @param[in] seed
293 * The seed used for random generation. Must be the same for
294 * all tiles initialized with this routine.
295 *
296 *******************************************************************************
297 *
298 * @retval SPM_SUCCESS on success
299 * @retval SPM_ERR_BADPARAMETER if the provided spm is incorrect
300 *
301 ******************************************************************************/
302static inline int
304 float alpha,
305 spm_int_t n,
306 float *A,
307 spm_int_t lda,
308 int shift,
309 unsigned long long int seed )
310{
311 float *tmp = A;
312 spm_int_t *dofs = spm->dofs;
313 spm_int_t *vertice;
314 spm_int_t *verticeptr;
315 spm_int_t j, k, previous;
316 spm_int_t ig, dofi, row, col;
317 unsigned long long int ran, jump;
318 int distribution;
319 spm_int_t baseval = spm->baseval;
320
321 distribution = spm_get_distribution( spm );
322
323 /* It could happen if we're on one node */
324 if ( (distribution & SpmDistByColumn) &&
325 (distribution & SpmDistByRow) ) {
326 distribution = SpmDistByRow;
327 vertice = spm->rowptr + 1;
328 for( j=1; j<spm->nnz; j++, vertice++ )
329 {
330 /* The matrix isn't sorted by row */
331 if ( vertice[0] > vertice[1] ) {
332 distribution = SpmDistByColumn;
333 break;
334 }
335 }
336 }
337
338 verticeptr = (distribution & SpmDistByColumn) ? spm->colptr : spm->rowptr;
339
340 /*
341 * Distributed version : the RHS might be distributed in a non-contiguous
342 * way, so the jump have to be recomputed with global index for each element.
343 */
344 for ( col=0; col<n; col++)
345 {
346 tmp = A + col * lda;
347 vertice = verticeptr;
348 previous = -1;
349 for ( j=0; j<spm->nnz; j++, vertice++ )
350 {
351 ig = *vertice - baseval;
352
353 if( ig == previous ) {
354 continue;
355 }
356 /* The spm has to be sorted */
357 if( ig < previous ) {
358 fprintf(stderr, "The spm isn't sorted for GenRnd, we leave the routine now\n");
360 }
361
362 if ( spm->dof > 0 ) {
363 dofi = spm->dof;
364 row = spm->dof * ig;
365 }
366 else {
367 dofi = dofs[ig+1] - dofs[ig];
368 row = dofs[ig] - baseval;
369 }
370 jump = row + col * (unsigned long long int)(spm->gNexp) + shift;
371 ran = Rnd64_jump( NBELEM*jump, seed );
372
373 for( k=0; k<dofi; k++, tmp++ ) {
374 s_updateRndVal( alpha, tmp, &ran );
375 }
376 previous = ig;
377 }
378 }
379 (void)lda;
380 return SPM_SUCCESS;
381}
382
383/**
384 *******************************************************************************
385 *
386 * @ingroup spm_dev_rhs
387 *
388 * @brief Generate a set of vectors of random values in distributed memory.
389 *
390 *******************************************************************************
391 *
392 * @param[in] spm
393 * The sparse matrix associated to the right hand side.
394 *
395 * @param[in] alpha
396 * Scaling factor for each value of the vector.
397 *
398 * @param[in] n
399 * The number of columns in A. n >= 0.
400 *
401 * @param[inout] A
402 * On entry, the lda-by-n matrix to be initialized.
403 * On exit, the matrix initialized.
404 *
405 * @param[in] lda
406 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
407 *
408 * @param[in] shift
409 * The initial shift in the random sequence.
410 *
411 * @param[in] seed
412 * The seed used for random generation. Must be the same for
413 * all tiles initialized with this routine.
414 *
415 *******************************************************************************
416 *
417 * @retval SPM_SUCCESS on success
418 * @retval SPM_ERR_BADPARAMETER if the provided spm is incorrect
419 *
420 ******************************************************************************/
421int
423 float alpha,
424 spm_int_t n,
425 float *A,
426 spm_int_t lda,
427 int shift,
428 unsigned long long int seed )
429{
430 if( spm->fmttype == SpmIJV ) {
431 return s_spm_rhs_dist_genRnd_ijv( spm, alpha, n, A, lda, shift, seed );
432 }
433 else {
434 return s_spm_rhs_dist_genRnd_csx( spm, alpha, n, A, lda, shift, seed );
435 }
436}
437
438/**
439 *******************************************************************************
440 *
441 * @ingroup spm_dev_rhs
442 *
443 * @brief Generate a set of vectors of constant values.
444 *
445 *******************************************************************************
446 *
447 * @param[in] spm
448 * The sparse matrix associated to the right hand side.
449 *
450 * @param[in] alpha
451 * Initialize each value to alpha [ + I * alpha ]
452 *
453 * @param[in] n
454 * The number of columns in A. n >= 0.
455 *
456 * @param[inout] A
457 * On entry, the lda-by-n matrix to be initialized.
458 * On exit, the matrix initialized.
459 *
460 * @param[in] lda
461 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
462 *
463 *******************************************************************************
464 *
465 * @retval SPM_SUCCESS to match prototype of equivalent function
466 *
467 ******************************************************************************/
468static inline int
470 float alpha,
471 spm_int_t n,
472 float *A,
473 spm_int_t lda )
474{
475 float *tmp = A;
476 int64_t i, j, m = spm->nexp;
477
478 /*
479 * Global version : the RHS is contiguous. The jump can follow the vector.
480 */
481 for( i=0; i<m; i++, tmp++ )
482 {
483#if defined(PRECISION_z) || defined(PRECISION_c)
484 *tmp = (float)(alpha + alpha * I);
485#else
486 *tmp = (float)alpha;
487#endif
488 }
489 tmp += lda - i;
490 for (j=1; j<n; ++j) {
491 memcpy( tmp, A, spm->nexp * sizeof(float) );
492 tmp += lda;
493 }
494
495 return SPM_SUCCESS;
496}
497
498/**
499 *******************************************************************************
500 *
501 * @brief Generate a set of vectors x[i] = alpha * ( i [+ i* I ] )
502 * for CSC format.
503 *
504 *******************************************************************************
505 *
506 * @param[in] spm
507 * The sparse matrix associated to the right hand side.
508 *
509 * @param[in] alpha
510 * Scaling factor for each value of the vector.
511 *
512 * @param[in] n
513 * The number of columns in A. n >= 0.
514 *
515 * @param[inout] A
516 * On entry, the lda-by-n matrix to be initialized.
517 * On exit, the matrix initialized.
518 *
519 * @param[in] lda
520 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
521 *
522 *******************************************************************************
523 *
524 * @retval SPM_SUCCESS on success
525 * @retval SPM_ERR_BADPARAMETER if the provided spm is incorrect
526 *
527 ******************************************************************************/
528static inline int
530 float alpha,
531 spm_int_t n,
532 float *A,
533 spm_int_t lda )
534{
535 float *tmp = A;
536 const spm_int_t *dofs = spm->dofs;
537 spm_int_t *loc2glob = spm->loc2glob;
538 spm_int_t baseval = spm->baseval;
539 spm_int_t i, j, k;
540 spm_int_t ig, dofi, row;
541
542 for( i=0; i<spm->n; i++, loc2glob++ )
543 {
544 ig = spm->replicated ? i : *loc2glob - baseval;
545 if ( spm->dof > 0 ) {
546 dofi = spm->dof;
547 row = spm->dof * ig;
548 }
549 else {
550 dofi = dofs[ig+1] - dofs[ig];
551 row = dofs[ig] - baseval;
552 }
553
554 row++; /* To avoid 0 */
555 for( k=0; k<dofi; k++, row++, tmp++ )
556 {
557#if defined(PRECISION_z) || defined(PRECISION_c)
558 *tmp = (float)(row + row * I) * alpha;
559#else
560 *tmp = (float)row * alpha;
561#endif
562 }
563 }
564 tmp += lda - spm->nexp;
565
566 for( j = 1; j < n; j++ ) {
567 memcpy( tmp, A, spm->nexp * sizeof(float) );
568 tmp += lda;
569 }
570
571 return SPM_SUCCESS;
572}
573
574/**
575 *******************************************************************************
576 *
577 * @brief Generate a set of vectors x[i] = alpha * ( i [+ i* I ] )
578 * for IJV format.
579 *
580 * @warning The matrix has to be sorted by column or by row.
581 *
582 *******************************************************************************
583 *
584 * @param[in] spm
585 * The sparse matrix associated to the right hand side.
586 *
587 * @param[in] alpha
588 * Scaling factor for each value of the vector.
589 *
590 * @param[in] n
591 * The number of columns in A. n >= 0.
592 *
593 * @param[inout] A
594 * On entry, the lda-by-n matrix to be initialized.
595 * On exit, the matrix initialized.
596 *
597 * @param[in] lda
598 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
599 *
600 *******************************************************************************
601 *
602 * @retval SPM_SUCCESS on success
603 * @retval SPM_ERR_BADPARAMETER if the provided spm is incorrect
604 *
605 ******************************************************************************/
606static inline int
608 float alpha,
609 spm_int_t n,
610 float *A,
611 spm_int_t lda )
612{
613 float *tmp = A;
614 const spm_int_t *dofs = spm->dofs;
615 spm_int_t *vertice = NULL;
616 spm_int_t baseval = spm->baseval;
617 spm_int_t i, j, k;
618 spm_int_t ig, dofi, row, previous;
619 int distribution;
620
621 distribution = spm_get_distribution( spm );
622
623 /**
624 * If the spm is global, we have to know which vertice
625 * is sorted
626 */
627 if ( (distribution & SpmDistByColumn) &&
628 (distribution & SpmDistByRow) ) {
629 distribution = SpmDistByRow;
630 vertice = spm->rowptr + 1;
631 for( i=1; i<spm->nnz; i++, vertice++ )
632 {
633 /* The matrix isn't sorted by row */
634 if ( vertice[0] > vertice[1] ) {
635 distribution = SpmDistByColumn;
636 break;
637 }
638 }
639 }
640
641 vertice = (distribution & SpmDistByColumn) ? spm->colptr : spm->rowptr;
642
643 if( vertice == NULL ) {
644 fprintf( stderr, "Problem in distribution detection\n" );
646 }
647
648 previous = -1;
649 for( i=0; i<spm->nnz; i++, vertice++ )
650 {
651 ig = *vertice - baseval;
652
653 if( ig == previous ) {
654 continue;
655 }
656 /* The matrix has to be sorted */
657 if( ig < previous ) {
658 fprintf(stderr, "The spm isn't sorted for GenI, we leave the routine now\n");
660 }
661
662 if ( spm->dof > 0 ) {
663 dofi = spm->dof;
664 row = spm->dof * ig;
665 }
666 else {
667 dofi = dofs[ig+1] - dofs[ig];
668 row = dofs[ig] - baseval;
669 }
670
671 row++; /* To avoid 0 */
672 for( k=0; k<dofi; k++, row++, tmp++ )
673 {
674#if defined(PRECISION_z) || defined(PRECISION_c)
675 *tmp = (float)(row + row * I) * alpha;
676#else
677 *tmp = (float)row * alpha;
678#endif
679 }
680 previous = ig;
681 }
682
683 for( j = 1; j < n; j++ ) {
684 memcpy( tmp, A, spm->nexp * sizeof(float) );
685 tmp += lda;
686 }
687
688 return SPM_SUCCESS;
689}
690
691/**
692 *******************************************************************************
693 *
694 * @ingroup spm_dev_rhs
695 *
696 * @brief Generate a set of vectors x[i] = alpha * ( i [+ i* I ] ).
697 *
698 *******************************************************************************
699 *
700 * @param[in] spm
701 * The sparse matrix associated to the right hand side.
702 *
703 * @param[in] alpha
704 * Scaling factor for each value of the vector.
705 *
706 * @param[in] n
707 * The number of columns in A. n >= 0.
708 *
709 * @param[inout] A
710 * On entry, the lda-by-n matrix to be initialized.
711 * On exit, the matrix initialized.
712 *
713 * @param[in] lda
714 * The leading dimension of the matrix A. lda >= max(1,spm->nexp).
715 *
716 *******************************************************************************
717 *
718 * @retval SPM_SUCCESS on success
719 * @retval SPM_ERR_BADPARAMETER if the provided spm is incorrect
720 *
721 ******************************************************************************/
722static inline int
724 float alpha,
725 spm_int_t n,
726 float *A,
727 spm_int_t lda )
728{
729 if( spm->fmttype == SpmIJV ) {
730 return s_spm_rhs_genI_ijv( spm, alpha, n, A, lda );
731 }
732 else {
733 return s_spm_rhs_genI_csx( spm, alpha, n, A, lda );
734 }
735}
736
737/**
738 *******************************************************************************
739 *
740 * @ingroup spm_dev_rhs
741 *
742 * @brief Generate nrhs right hand side vectors associated to a given
743 * matrix to test a problem with a solver.
744 *
745 *******************************************************************************
746 *
747 * @param[in] type
748 * Defines how to compute the vector b.
749 * @arg SpmRhsOne: b is computed such that x = 1 [ + I ]
750 * @arg SpmRhsI: b is computed such that x = i [ + i * I ]
751 * @arg SpmRhsRndX: b is computed by matrix-vector product, such that
752 * is a random vector in the range [-0.5, 0.5]
753 * @arg SpmRhsRndB: b is computed randomly and x is not computed.
754 *
755 * @param[in] nrhs
756 * Defines the number of right hand side that must be generated.
757 *
758 * @param[in] spm
759 * The sparse matrix uses to generate the right hand side, and the
760 * solution of the full problem.
761 *
762 * @param[in] alphaptr
763 * The pointer to the scaling factor of the matrix.
764 *
765 * @param[in] seed
766 * Random seed generator.
767 *
768 * @param[out] A
769 * The generated matrix. It has to be preallocated with a size
770 * lda -by- nrhs.
771 *
772 * @param[in] lda
773 * Defines the leading dimension of A when multiple right hand sides
774 * are available. lda >= spm->nexp.
775 *
776 *******************************************************************************
777 *
778 * @retval SPM_SUCCESS if the b vector has been computed succesfully,
779 * @retval SPM_ERR_BADPARAMETER otherwise.
780 *
781 *******************************************************************************/
782int
784 int nrhs,
785 const spmatrix_t *spm,
786 void *alphaptr,
787 unsigned long long int seed,
788 void *A,
789 int lda )
790{
791 float *Aptr = (float*)A;
792 float alpha = *((float*)alphaptr);
793 int rc = 0;
794
795 if( (nrhs > 1) && (lda < spm->nexp) ) {
797 }
798
799 switch( type ) {
800 case SpmRhsOne:
801 rc = s_spmRhsGenOne( spm, alpha, nrhs, Aptr, lda );
802 break;
803
804 case SpmRhsI:
805 rc = s_spmRhsGenI( spm, alpha, nrhs, Aptr, lda );
806 break;
807
808 case SpmRhsRndX:
809 default:
810 if ( spm->replicated ) {
811 rc = s_spmRhsGenRndShm( spm, alpha, nrhs,
812 Aptr, lda, 1, seed );
813 }
814 else {
815 rc = s_spmRhsGenRndDist( spm, alpha, nrhs,
816 Aptr, lda, 1, seed );
817 }
818 }
819 if ( rc != 0 ) {
821 }
822
823 return SPM_SUCCESS;
824}
#define SpmDistByRow
Definition const.h:43
enum spm_rhstype_e spm_rhstype_t
How to generate RHS.
#define SpmDistByColumn
Distribution of the matrix storage.
Definition const.h:42
@ SPM_ERR_BADPARAMETER
Definition const.h:89
@ SPM_SUCCESS
Definition const.h:82
@ SpmIJV
Definition const.h:75
int s_spmRhsGenRndDist(const spmatrix_t *spm, float scale, spm_int_t n, float *A, spm_int_t lda, int shift, unsigned long long int seed)
Generate a set of vectors of random values in distributed memory.
static void s_updateRndVal(float scale, float *val, unsigned long long int *ran)
Generate a value of the RHS.
static int s_spmRhsGenOne(const spmatrix_t *spm, float alpha, spm_int_t n, float *A, spm_int_t lda)
Generate a set of vectors of constant values.
int s_spmRhsGenRndShm(const spmatrix_t *spm, float scale, spm_int_t n, float *A, spm_int_t lda, int shift, unsigned long long int seed)
Generate a set of vectors of random values in shared memory.
static int s_spmRhsGenI(const spmatrix_t *spm, float alpha, spm_int_t n, float *A, spm_int_t lda)
Generate a set of vectors x[i] = alpha * ( i [+ i* I ] ).
int s_spmGenMat(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, int lda)
Generate nrhs right hand side vectors associated to a given matrix to test a problem with a solver.
spm_int_t * dofs
Definition spm.h:85
spm_int_t nexp
Definition spm.h:78
spm_int_t nnz
Definition spm.h:75
spm_int_t * rowptr
Definition spm.h:90
spm_fmttype_t fmttype
Definition spm.h:69
spm_int_t dof
Definition spm.h:82
spm_int_t n
Definition spm.h:73
spm_int_t * loc2glob
Definition spm.h:91
spm_int_t baseval
Definition spm.h:71
spm_int_t * colptr
Definition spm.h:89
spm_int_t gNexp
Definition spm.h:77
int replicated
Definition spm.h:98
int spm_int_t
The main integer datatype used in spm arrays.
Definition datatypes.h:70
The sparse matrix data structure.
Definition spm.h:64
static int s_spm_rhs_dist_genRnd_csx(const spmatrix_t *spm, float alpha, spm_int_t n, float *A, spm_int_t lda, int shift, unsigned long long int seed)
Generate a set of vectors of random values in distributed memory for CSX format.
static int s_spm_rhs_dist_genRnd_ijv(const spmatrix_t *spm, float alpha, spm_int_t n, float *A, spm_int_t lda, int shift, unsigned long long int seed)
Generate a set of vectors of random values in distributed memory for IJV format.
static int s_spm_rhs_genI_csx(const spmatrix_t *spm, float alpha, spm_int_t n, float *A, spm_int_t lda)
Generate a set of vectors x[i] = alpha * ( i [+ i* I ] ) for CSC format.
static int s_spm_rhs_genI_ijv(const spmatrix_t *spm, float alpha, spm_int_t n, float *A, spm_int_t lda)
Generate a set of vectors x[i] = alpha * ( i [+ i* I ] ) for IJV format.
static unsigned long long int Rnd64_jump(unsigned long long int n, unsigned long long int seed)
Random generator from the HPL library.
int spm_get_distribution(const spmatrix_t *spm)
Search the distribution pattern used in the spm structure.
Definition spm.c:2049