Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Int64 support #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.a
*.o
52 changes: 26 additions & 26 deletions EXAMPLES/C/main_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@
#include "mpi.h"
#include "pmrrr.h"

static int read_tri_mat(char*, double**, double**);
static void print_vector(char*, double*, char*, int);
static void print_matrix(char*, double*, int, int, int);
static PMRRR_Int read_tri_mat(char*, double**, double**);
static void print_vector(char*, double*, char*, PMRRR_Int);
static void print_matrix(char*, double*, PMRRR_Int, PMRRR_Int, PMRRR_Int);


int main(int argc, char **argv)
{
/* Input parameter to 'pmrrr' */
int n; /* Matrix size */
int il, iu;
int tryRAC = 1; /* Try high rel. accuracy */
double *D, *E; /* Diagonal and off-diagonal elements */
double vl, vu;

double *W; /* eigenvalues */
int nz; /* # local eigenvectors */
int offset;
double *Z; /* eigenvectors; stored by colums */
int ldz;
int *Zsupp; /* eigenvector support */
PMRRR_Int n; /* Matrix size */
PMRRR_Int il, iu;
PMRRR_Int tryRAC = 1; /* Try high rel. accuracy */
double *D, *E; /* Diagonal and off-diagonal elements */
double vl, vu;

double *W; /* eigenvalues */
PMRRR_Int nz; /* # local eigenvectors */
PMRRR_Int offset;
double *Z; /* eigenvectors; stored by colums */
PMRRR_Int ldz;
PMRRR_Int *Zsupp; /* eigenvector support */

/* Others */
int pid, nproc, info, status;
int i;
int pid, nproc, status;
PMRRR_Int info, i;

MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &status);
MPI_Comm_rank(MPI_COMM_WORLD, &pid);
Expand All @@ -55,9 +55,9 @@ int main(int argc, char **argv)

/* Allocate memory */
W = (double *) malloc( n * sizeof(double) );
Zsupp = (int *) malloc( 2*n * sizeof(int) );
Zsupp = (PMRRR_Int *) malloc( 2*n * sizeof(PMRRR_Int) );

nz = (int) ceil(n / (double) nproc);
nz = (PMRRR_Int) ceil(n / (double) nproc);
ldz = n;

Z = (double *) malloc((size_t) n * nz * sizeof(double) );
Expand Down Expand Up @@ -101,9 +101,9 @@ int main(int argc, char **argv)
/*
* Reads the triadiagonal matrix from a file.
*/
static int read_tri_mat(char *filename, double **Dp, double **Ep)
static PMRRR_Int read_tri_mat(char *filename, double **Dp, double **Ep)
{
int i, n;
PMRRR_Int i, n;
FILE *filedes;

filedes = fopen(filename, "r");
Expand All @@ -129,9 +129,9 @@ static int read_tri_mat(char *filename, double **Dp, double **Ep)



static void print_vector(char *pre, double *v, char *post, int n)
static void print_vector(char *pre, double *v, char *post, PMRRR_Int n)
{
int i;
PMRRR_Int i;

printf("\n%s\n", pre);
for (i=0; i<n; i++) {
Expand All @@ -143,10 +143,10 @@ static void print_vector(char *pre, double *v, char *post, int n)



static void print_matrix(char *name, double *A, int lda,
int numcols, int offset)
static void print_matrix(char *name, double *A, PMRRR_Int lda,
PMRRR_Int numcols, PMRRR_Int offset)
{
int j;
PMRRR_Int j;
char str1[20], str2[20];

for (j=1; j<=numcols; j++) {
Expand Down
52 changes: 26 additions & 26 deletions EXAMPLES/C/main_ind.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@
#include "mpi.h"
#include "pmrrr.h"

static int read_tri_mat(char*, double**, double**);
static void print_vector(char*, double*, char*, int);
static void print_matrix(char*, double*, int, int, int);
static PMRRR_Int read_tri_mat(char*, double**, double**);
static void print_vector(char*, double*, char*, PMRRR_Int);
static void print_matrix(char*, double*, PMRRR_Int, PMRRR_Int, PMRRR_Int);


int main(int argc, char **argv)
{
/* Input parameter to 'pmrrr' */
int n; /* Matrix size */
int il, iu;
int tryRAC = 1; /* Try high rel. accuracy */
double *D, *E; /* Diagonal and off-diagonal elements */
double vl, vu;

double *W; /* eigenvalues */
int nz; /* # local eigenvectors */
int offset;
double *Z; /* eigenvectors; stored by colums */
int ldz;
int *Zsupp; /* eigenvector support */
PMRRR_Int n; /* Matrix size */
PMRRR_Int il, iu;
PMRRR_Int tryRAC = 1; /* Try high rel. accuracy */
double *D, *E; /* Diagonal and off-diagonal elements */
double vl, vu;

double *W; /* eigenvalues */
PMRRR_Int nz; /* # local eigenvectors */
PMRRR_Int offset;
double *Z; /* eigenvectors; stored by colums */
PMRRR_Int ldz;
PMRRR_Int *Zsupp; /* eigenvector support */

/* Others */
int pid, nproc, info, status;
int i;
int pid, nproc, status;
PMRRR_Int info, i;

MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &status);
MPI_Comm_rank(MPI_COMM_WORLD, &pid);
Expand All @@ -58,9 +58,9 @@ int main(int argc, char **argv)

/* Allocate memory */
W = (double *) malloc( n * sizeof(double) );
Zsupp = (int *) malloc( 2*n * sizeof(int) );
Zsupp = (PMRRR_Int *) malloc( 2*n * sizeof(PMRRR_Int) );

nz = (int) ceil((iu-il+1) / (double) nproc);
nz = (PMRRR_Int) ceil((iu-il+1) / (double) nproc);
ldz = n;

Z = (double *) malloc((size_t) n * nz * sizeof(double) );
Expand Down Expand Up @@ -104,9 +104,9 @@ int main(int argc, char **argv)
/*
* Reads the triadiagonal matrix from a file.
*/
static int read_tri_mat(char *filename, double **Dp, double **Ep)
static PMRRR_Int read_tri_mat(char *filename, double **Dp, double **Ep)
{
int i, n;
PMRRR_Int i, n;
FILE *filedes;

filedes = fopen(filename, "r");
Expand All @@ -132,9 +132,9 @@ static int read_tri_mat(char *filename, double **Dp, double **Ep)



static void print_vector(char *pre, double *v, char *post, int n)
static void print_vector(char *pre, double *v, char *post, PMRRR_Int n)
{
int i;
PMRRR_Int i;

printf("\n%s\n", pre);
for (i=0; i<n; i++) {
Expand All @@ -146,10 +146,10 @@ static void print_vector(char *pre, double *v, char *post, int n)



static void print_matrix(char *name, double *A, int lda,
int numcols, int offset)
static void print_matrix(char *name, double *A, PMRRR_Int lda,
PMRRR_Int numcols, PMRRR_Int offset)
{
int j;
PMRRR_Int j;
char str1[20], str2[20];

for (j=1; j<=numcols; j++) {
Expand Down
50 changes: 25 additions & 25 deletions EXAMPLES/C/main_val.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@
#include "mpi.h"
#include "pmrrr.h"

static int read_tri_mat(char*, double**, double**);
static void print_vector(char*, double*, char*, int);
static void print_matrix(char*, double*, int, int, int);
static PMRRR_Int read_tri_mat(char*, double**, double**);
static void print_vector(char*, double*, char*, PMRRR_Int);
static void print_matrix(char*, double*, PMRRR_Int, PMRRR_Int, PMRRR_Int);


int main(int argc, char **argv)
{
/* Input parameter to 'pmrrr' */
int n; /* Matrix size */
int il, iu;
int tryRAC = 1; /* Try high rel. accuracy */
double *D, *E; /* Diagonal and off-diagonal elements */
double vl, vu;

double *W; /* eigenvalues */
int nz; /* # local eigenvectors */
int offset;
double *Z; /* eigenvectors; stored by colums */
int ldz;
int *Zsupp; /* eigenvector support */
PMRRR_Int n; /* Matrix size */
PMRRR_Int il, iu;
PMRRR_Int tryRAC = 1; /* Try high rel. accuracy */
double *D, *E; /* Diagonal and off-diagonal elements */
double vl, vu;

double *W; /* eigenvalues */
PMRRR_Int nz; /* # local eigenvectors */
PMRRR_Int offset;
double *Z; /* eigenvectors; stored by colums */
PMRRR_Int ldz;
PMRRR_Int *Zsupp; /* eigenvector support */

/* Others */
int pid, nproc, info, status;
int i;
PMRRR_Int pid, nproc, status;
int info, i;

MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &status);
MPI_Comm_rank(MPI_COMM_WORLD, &pid);
Expand All @@ -59,7 +59,7 @@ int main(int argc, char **argv)

/* Allocate memory */
W = (double *) malloc( n * sizeof(double) );
Zsupp = (int *) malloc( 2*n * sizeof(int) );
Zsupp = (PMRRR_Int *) malloc( 2*n * sizeof(PMRRR_Int) );

info = pmrrr("Count", "Value", &n, D, E, &vl, &vu, &il, &iu,
&tryRAC, MPI_COMM_WORLD, &nz, &offset, W,
Expand Down Expand Up @@ -107,9 +107,9 @@ int main(int argc, char **argv)
/*
* Reads the triadiagonal matrix from a file.
*/
static int read_tri_mat(char *filename, double **Dp, double **Ep)
static PMRRR_Int read_tri_mat(char *filename, double **Dp, double **Ep)
{
int i, n;
PMRRR_Int i, n;
FILE *filedes;

filedes = fopen(filename, "r");
Expand All @@ -135,9 +135,9 @@ static int read_tri_mat(char *filename, double **Dp, double **Ep)



static void print_vector(char *pre, double *v, char *post, int n)
static void print_vector(char *pre, double *v, char *post, PMRRR_Int n)
{
int i;
PMRRR_Int i;

printf("\n%s\n", pre);
for (i=0; i<n; i++) {
Expand All @@ -149,10 +149,10 @@ static void print_vector(char *pre, double *v, char *post, int n)



static void print_matrix(char *name, double *A, int lda,
int numcols, int offset)
static void print_matrix(char *name, double *A, PMRRR_Int lda,
PMRRR_Int numcols, PMRRR_Int offset)
{
int i, j;
PMRRR_Int i, j;
char str1[20], str2[20];

for (j=1; j<=numcols; j++) {
Expand Down
12 changes: 6 additions & 6 deletions INCLUDE/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@
#include "global.h"

typedef struct {
int value;
PMRRR_Int value;
#ifdef NOSPINLOCKS
pthread_mutex_t lock;
#else
pthread_spinlock_t lock;
#endif
} counter_t;

counter_t *PMR_create_counter(int init_value);
int PMR_get_counter_value(counter_t *counter);
int PMR_set_counter_value(counter_t *counter, int value);
int PMR_decrement_counter(counter_t *counter, int amount);
int PMR_increment_counter(counter_t *counter, int amount);
counter_t *PMR_create_counter(PMRRR_Int init_value);
PMRRR_Int PMR_get_counter_value(counter_t *counter);
PMRRR_Int PMR_set_counter_value(counter_t *counter, PMRRR_Int value);
PMRRR_Int PMR_decrement_counter(counter_t *counter, PMRRR_Int amount);
PMRRR_Int PMR_increment_counter(counter_t *counter, PMRRR_Int amount);
void PMR_destroy_counter(counter_t *counter);

#endif
16 changes: 16 additions & 0 deletions INCLUDE/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@
#else
/* C89 with or without Amendment 1, see H&S p.53 */

#ifndef __cplusplus
#define restrict /*nothing*/
#define inline /*nothing*/
#endif /* __cplusplus */

#define fmax(a,b) ( (a) > (b) ? (a) : (b) )
#define fmin(a,b) ( (a) < (b) ? (a) : (b) )

#ifndef __cplusplus
typedef int bool;
#define false 0
#define true 1
#endif /* __cplusplus */

#endif
#else /* __STDC__ not defined */
Expand All @@ -70,16 +74,20 @@ typedef int bool;

/* in case compiler does not support type qualifiers
* see Harbison and Steele p. 89*/
#ifndef __cplusplus
#define const /*nothing*/
#define volatile /*nothing*/
#define restrict /*nothing*/
#endif /* __cplusplus */

#define fmax(a,b) ( (a) > (b) ? (a) : (b) )
#define fmin(a,b) ( (a) < (b) ? (a) : (b) )

#ifndef __cplusplus
typedef int bool;
#define false 0
#define true 1
#endif /* __cplusplus */

/* need also remove all // style comments */
/* inline ... */
Expand All @@ -92,5 +100,13 @@ typedef int bool;
#define imin(a,b) ( (a) < (b) ? (a) : (b) )
#define iceil(a,b) ( (((a)%(b))!=0) ? (((a)/(b))+1) : ((a)/(b)) )

#ifdef MPRRR_INT64
typedef int64_t PMRRR_Int;
#define PMRRR_MPI_INT_TYPE MPI_LONG_LONG_INT
#else
typedef int PMRRR_Int;
#define PMRRR_MPI_INT_TYPE MPI_INT
#endif /* MPRRR_INT64 */

/* End of header file */
#endif
4 changes: 2 additions & 2 deletions INCLUDE/plarre.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
* Note: this implementation is here is not really optimized in
* terms of performance and memory usage.
*/
int plarre(proc_t *procinfo, char *jobz, char *range, in_t *Dstruct,
val_t *Wstruct, tol_t *tolstruct, int *nzp, int *offsetp);
PMRRR_Int plarre(proc_t *procinfo, char *jobz, char *range, in_t *Dstruct,
val_t *Wstruct, tol_t *tolstruct, PMRRR_Int *nzp, PMRRR_Int *offsetp);

/* Perturb the initial root representation by "1 + eps*RAND_FACTOR*rand";
* default: 8.0 */
Expand Down
6 changes: 3 additions & 3 deletions INCLUDE/plarrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
/*
* Computation of eigenvectors of a symmetric tridiagonal
*/
int plarrv(proc_t *procinfo, in_t *Dstruct, val_t *Wstruct,
vec_t *Zstruct, tol_t *tolstruct, int *nzp,
int *myfirstp);
PMRRR_Int plarrv(proc_t *procinfo, in_t *Dstruct, val_t *Wstruct,
vec_t *Zstruct, tol_t *tolstruct, PMRRR_Int *nzp,
PMRRR_Int *myfirstp);

#define COMM_COMPLETE 0
#define COMM_INCOMPLETE 1
Expand Down
Loading