There will be maintenance performed on git.ligo.org, chat.ligo.org, containers.lig.org, and docs.ligo.org starting at 9am PDT on Tuesday 18th August 2020. There will be an extremely small period of downtime at the start of the maintenance window as various services are restarted. Please address any comments, questions, or concerns to computing-help@igwn.org.

Commit 09697f6f authored by Daniel Brown's avatar Daniel Brown

Merge branch 'develop' of git.ligo.org:finesse/finesse into develop

parents 86c0c3c4 4c9bce39
This diff is collapsed.
/*
* -- SuperLU MT routine (version 2.0) --
* Lawrence Berkeley National Lab, Univ. of California Berkeley,
* and Xerox Palo Alto Research Center.
* September 10, 2007
*
*/
#include "pdsp_defs.h"
main(int argc, char *argv[])
{
SuperMatrix A, L, U;
SuperMatrix B, X;
NCformat *Astore;
SCPformat *Lstore;
NCPformat *Ustore;
int nprocs;
fact_t fact;
trans_t trans;
yes_no_t refact, usepr;
equed_t equed;
double *a;
int *asub, *xa;
int *perm_c; /* column permutation vector */
int *perm_r; /* row permutations from partial pivoting */
void *work;
superlumt_options_t superlumt_options;
int info, lwork, nrhs, ldx, panel_size, relax;
int m, n, nnz, permc_spec;
int i, firstfact;
double *rhsb, *rhsx, *xact;
double *R, *C;
double *ferr, *berr;
double u, drop_tol, rpg, rcond;
superlu_memusage_t superlu_memusage;
void parse_command_line();
/* Default parameters to control factorization. */
nprocs = 1;
fact = EQUILIBRATE;
trans = NOTRANS;
equed = NOEQUIL;
refact= NO;
panel_size = sp_ienv(1);
relax = sp_ienv(2);
u = 1.0;
usepr = NO;
drop_tol = 0.0;
lwork = 0;
nrhs = 1;
/* Command line options to modify default behavior. */
parse_command_line(argc, argv, &nprocs, &lwork, &panel_size, &relax,
&u, &fact, &trans, &refact, &equed);
if ( lwork > 0 ) {
work = SUPERLU_MALLOC(lwork);
printf("Use work space of size LWORK = %d bytes\n", lwork);
if ( !work ) {
SUPERLU_ABORT("DLINSOLX: cannot allocate work[]");
}
}
#if ( PRNTlevel==1 )
cpp_defs();
#endif
#define HB
#if defined( DEN )
m = n;
nnz = n * n;
dband(n, n, nnz, &a, &asub, &xa);
#elif defined( BAND )
m = n;
nnz = (2*b+1) * n;
dband(n, b, nnz, &a, &asub, &xa);
#elif defined( BD )
nb = 5;
bs = 200;
m = n = bs * nb;
nnz = bs * bs * nb;
dblockdiag(nb, bs, nnz, &a, &asub, &xa);
#elif defined( HB )
dreadhb(&m, &n, &nnz, &a, &asub, &xa);
#else
dreadmt(&m, &n, &nnz, &a, &asub, &xa);
#endif
firstfact = (fact == FACTORED || refact == YES);
dCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE);
Astore = A.Store;
printf("Dimension %dx%d; # nonzeros %d\n", A.nrow, A.ncol, Astore->nnz);
if (!(rhsb = doubleMalloc(m * nrhs))) SUPERLU_ABORT("Malloc fails for rhsb[].");
if (!(rhsx = doubleMalloc(m * nrhs))) SUPERLU_ABORT("Malloc fails for rhsx[].");
dCreate_Dense_Matrix(&B, m, nrhs, rhsb, m, SLU_DN, SLU_D, SLU_GE);
dCreate_Dense_Matrix(&X, m, nrhs, rhsx, m, SLU_DN, SLU_D, SLU_GE);
xact = doubleMalloc(n * nrhs);
ldx = n;
dGenXtrue(n, nrhs, xact, ldx);
dFillRHS(trans, nrhs, xact, ldx, &A, &B);
if (!(perm_r = intMalloc(m))) SUPERLU_ABORT("Malloc fails for perm_r[].");
if (!(perm_c = intMalloc(n))) SUPERLU_ABORT("Malloc fails for perm_c[].");
if (!(R = (double *) SUPERLU_MALLOC(A.nrow * sizeof(double))))
SUPERLU_ABORT("SUPERLU_MALLOC fails for R[].");
if ( !(C = (double *) SUPERLU_MALLOC(A.ncol * sizeof(double))) )
SUPERLU_ABORT("SUPERLU_MALLOC fails for C[].");
if ( !(ferr = (double *) SUPERLU_MALLOC(nrhs * sizeof(double))) )
SUPERLU_ABORT("SUPERLU_MALLOC fails for ferr[].");
if ( !(berr = (double *) SUPERLU_MALLOC(nrhs * sizeof(double))) )
SUPERLU_ABORT("SUPERLU_MALLOC fails for berr[].");
/*
* Get column permutation vector perm_c[], according to permc_spec:
* permc_spec = 0: natural ordering
* permc_spec = 1: minimum degree ordering on structure of A'*A
* permc_spec = 2: minimum degree ordering on structure of A'+A
* permc_spec = 3: approximate minimum degree for unsymmetric matrices
*/
permc_spec = 1;
get_perm_c(permc_spec, &A, perm_c);
superlumt_options.nprocs = nprocs;
superlumt_options.fact = fact;
superlumt_options.trans = trans;
superlumt_options.refact = refact;
superlumt_options.panel_size = panel_size;
superlumt_options.relax = relax;
superlumt_options.diag_pivot_thresh = u;
superlumt_options.usepr = usepr;
superlumt_options.drop_tol = drop_tol;
superlumt_options.SymmetricMode = NO;
superlumt_options.PrintStat = NO;
superlumt_options.perm_c = perm_c;
superlumt_options.perm_r = perm_r;
superlumt_options.work = work;
superlumt_options.lwork = lwork;
/*
* Solve the system and compute the condition number
* and error bounds using pdgssvx.
*/
pdgssvx(nprocs, &superlumt_options, &A, perm_c, perm_r,
&equed, R, C, &L, &U, &B, &X, &rpg, &rcond,
ferr, berr, &superlu_memusage, &info);
printf("pdgssvx(): info %d\n", info);
if ( info == 0 || info == n+1 ) {
printf("Recip. pivot growth = %e\n", rpg);
printf("Recip. condition number = %e\n", rcond);
printf("%8s%16s%16s\n", "rhs", "FERR", "BERR");
for (i = 0; i < nrhs; ++i) {
printf("%8d%16e%16e\n", i+1, ferr[i], berr[i]);
}
Lstore = (SCPformat *) L.Store;
Ustore = (NCPformat *) U.Store;
printf("No of nonzeros in factor L = %d\n", Lstore->nnz);
printf("No of nonzeros in factor U = %d\n", Ustore->nnz);
printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz - n);
printf("L\\U MB %.3f\ttotal MB needed %.3f\texpansions %d\n",
superlu_memusage.for_lu/1e6, superlu_memusage.total_needed/1e6,
superlu_memusage.expansions);
fflush(stdout);
} else if ( info > 0 && lwork == -1 ) {
printf("** Estimated memory: %d bytes\n", info - n);
}
SUPERLU_FREE (rhsb);
SUPERLU_FREE (rhsx);
SUPERLU_FREE (xact);
SUPERLU_FREE (perm_r);
SUPERLU_FREE (perm_c);
SUPERLU_FREE (R);
SUPERLU_FREE (C);
SUPERLU_FREE (ferr);
SUPERLU_FREE (berr);
Destroy_CompCol_Matrix(&A);
Destroy_SuperMatrix_Store(&B);
Destroy_SuperMatrix_Store(&X);
if ( lwork >= 0 ) {
Destroy_SuperNode_SCP(&L);
Destroy_CompCol_NCP(&U);
}
}
/*
* Parse command line options.
*/
void
parse_command_line(int argc, char *argv[], int *nprocs, int *lwork,
int *w, int *relax, double *u, fact_t *fact,
trans_t *trans, yes_no_t *refact, equed_t *equed)
{
int c;
extern char *optarg;
while ( (c = getopt(argc, argv, "hp:l:w:x:u:f:t:r:e:")) != EOF ) {
switch (c) {
case 'h':
printf("Options:\n");
printf("\t-p <int> - number of processes\n");
printf("\t-l <int> - length of work[*] array\n");
printf("\t-w <int> - panel size\n");
printf("\t-x <int> - maximum size of relaxed supernodes\n");
printf("\t-u <int> - pivoting threshold\n");
printf("\t-f <FACTORED/DOFACT/EQUILIBRATE> - factor control\n");
printf("\t-t <NOTRANS/TRANS/CONJ> - transpose or not\n");
printf("\t-r <NO/YES> - refactor or not\n");
printf("\t-e <NOEQUIL/ROW/COL/BOTH> - equilibrate or not\n");
exit(1);
break;
case 'p': *nprocs = atoi(optarg);
break;
case 'l': *lwork = atoi(optarg);
break;
case 'w': *w = atoi(optarg);
break;
case 'x': *relax = atoi(optarg);
break;
case 'u': *u = atof(optarg);
break;
case 'f': *fact = (fact_t) atoi(optarg);
break;
case 't': *trans = (trans_t) atoi(optarg);
break;
case 'r': *refact = (yes_no_t) atoi(optarg);
break;
case 'e': *equed = (equed_t) atoi(optarg);
break;
default: fprintf(stderr, "Invalid command line option.\n");
break;
}
}
}
This diff is collapsed.
/* Elimination tree computation and layout routines */
#include <stdio.h>
#ifndef __STDC__
#include <malloc.h>
#endif
#include <stdlib.h>
#include "util.h"
/*
* Implementation of disjoint set union routines.
* Elements are integers in 0..n-1, and the
* names of the sets themselves are of type int.
*
* Calls are:
* initialize_disjoint_sets (n) initial call.
* s = make_set (i) returns a set containing only i.
* s = link (t, u) returns s = t union u, destroying t and u.
* s = find (i) return name of set containing i.
* finalize_disjoint_sets final call.
*
* This implementation uses path compression but not weighted union.
* See Tarjan's book for details.
* John Gilbert, CMI, 1987.
*/
static int *pp; /* parent array for sets */
static
int *mxCallocInt(int n)
{
register int i;
int *buf;
buf = (int *) SUPERLU_MALLOC( n * sizeof(int) );
if ( !buf ) {
printf("SUPERLU_MALLOC failed for buf in mxCallocInt()");
exit (1);
}
for (i = 0; i < n; i++) buf[i] = 0;
return (buf);
}
static
void initialize_disjoint_sets (
int n
)
{
pp = mxCallocInt(n);
}
static
int make_set (
int i
)
{
pp[i] = i;
return i;
}
static
int link (
int s,
int t
)
{
pp[s] = t;
return t;
}
/* PATH HALVING */
static
int find (int i)
{
register int p, gp;
p = pp[i];
gp = pp[p];
while (gp != p) {
pp[i] = gp;
i = gp;
p = pp[i];
gp = pp[p];
}
return (p);
}
#if 0
static
int find (
int i
)
{
if (pp[i] != i)
pp[i] = find (pp[i]);
return pp[i];
}
#endif
static
void finalize_disjoint_sets (
void
)
{
SUPERLU_FREE(pp);
}
/*
* Find the elimination tree for A'*A.
* This uses something similar to Liu's algorithm.
* It runs in time O(nz(A)*log n) and does not form A'*A.
*
* Input:
* Sparse matrix A. Numeric values are ignored, so any
* explicit zeros are treated as nonzero.
* Output:
* Integer array of parents representing the elimination
* tree of the symbolic product A'*A. Each vertex is a
* column of A, and nc means a root of the elimination forest.
*
* John R. Gilbert, Xerox, 10 Dec 1990
* Based on code by JRG dated 1987, 1988, and 1990.
*/
/*
* Nonsymmetric elimination tree
*/
int
sp_coletree(
int *acolst, int *acolend, /* column start and end past 1 */
int *arow, /* row indices of A */
int nr, int nc, /* dimension of A */
int *parent /* parent in elim tree */
)
{
int *root; /* root of subtee of etree */
int *firstcol; /* first nonzero col in each row*/
int rset, cset;
int row, col;
int rroot;
int p;
root = mxCallocInt (nc);
initialize_disjoint_sets (nc);
/* Compute firstcol[row] = first nonzero column in row */
firstcol = mxCallocInt (nr);
for (row = 0; row < nr; firstcol[row++] = nc);
for (col = 0; col < nc; col++)
for (p = acolst[col]; p < acolend[col]; p++) {
row = arow[p];
firstcol[row] = MIN(firstcol[row], col);
}
/* Compute etree by Liu's algorithm for symmetric matrices,
except use (firstcol[r],c) in place of an edge (r,c) of A.
Thus each row clique in A'*A is replaced by a star
centered at its first vertex, which has the same fill. */
for (col = 0; col < nc; col++) {
cset = make_set (col);
root[cset] = col;
parent[col] = nc; /* Matlab */
for (p = acolst[col]; p < acolend[col]; p++) {
row = firstcol[arow[p]];
if (row >= col) continue;
rset = find (row);
rroot = root[rset];
if (rroot != col) {
parent[rroot] = col;
cset = link (cset, rset);
root[cset] = col;
}
}
}
SUPERLU_FREE (root);
SUPERLU_FREE (firstcol);
finalize_disjoint_sets ();
return 0;
}
/*
* q = TreePostorder (n, p);
*
* Postorder a tree.
* Input:
* p is a vector of parent pointers for a forest whose
* vertices are the integers 0 to n-1; p[root]==n.
* Output:
* q is a vector indexed by 0..n-1 such that q[i] is the
* i-th vertex in a postorder numbering of the tree.
*
* ( 2/7/95 modified by X.Li:
* q is a vector indexed by 0:n-1 such that vertex i is the
* q[i]-th vertex in a postorder numbering of the tree.
* That is, this is the inverse of the previous q. )
*
* In the child structure, lower-numbered children are represented
* first, so that a tree which is already numbered in postorder
* will not have its order changed.
*
* Written by John Gilbert, Xerox, 10 Dec 1990.
* Based on code written by John Gilbert at CMI in 1987.
*/
static int *first_kid, *next_kid; /* Linked list of children. */
static int *post, postnum;
static
/*
* Depth-first search from vertex v.
*/
void etdfs (
int v
)
{
int w;
for (w = first_kid[v]; w != -1; w = next_kid[w]) {
etdfs (w);
}
/* post[postnum++] = v; in Matlab */
post[v] = postnum++; /* Modified by X.Li on 2/14/95 */
}
/*
* Post order a tree
*/
int *TreePostorder(
int n,
int *parent
)
{
int v, dad;
/* Allocate storage for working arrays and results */
first_kid = mxCallocInt (n+1);
next_kid = mxCallocInt (n+1);
post = mxCallocInt (n+1);
/* Set up structure describing children */
for (v = 0; v <= n; first_kid[v++] = -1);
for (v = n-1; v >= 0; v--) {
dad = parent[v];
next_kid[v] = first_kid[dad];
first_kid[dad] = v;
}
/* Depth-first search from dummy root vertex #n */
postnum = 0;
etdfs (n);
SUPERLU_FREE (first_kid);
SUPERLU_FREE (next_kid);
return post;
}
......@@ -7,6 +7,11 @@
#
SHELL = bash
# Hard coded version string in case it cannot be derived using git, this needs to be
# updated manually upon every release!
VERSION = 2.2
SHA = 2.2-33-g9b50c06
.PHONY: clean tags cover_report test_clean api_clean
ifeq "$(ARCH)" "linux"
......@@ -207,10 +212,22 @@ PREREQS += $(OBJECTS)
# determine short SHA of git commit
#GIT_SHA_CMD = $(GIT) rev-parse --verify HEAD --short
GIT_SHA_CMD = $(GIT) describe --long
GIT_SHA = $(shell $(GIT_SHA_CMD))
GIT_VER_CMD = $(GIT) describe --abbrev=0
GIT_VERSION = $(shell $(GIT_VER_CMD))
#GIT_SHA_CMD = $(GIT) describe --long | awk '{ sub("-",".",$0)}1'
GIT_SHA_CMD = $(GIT) describe --long 2>/dev/null
GIT_SHA = $(shell $(GIT_SHA_CMD))
#GIT_VER_CMD = $(GIT) describe --long | awk '{ sub("-",".",$0)}1' | cut -d- -f1
GIT_VER_CMD = $(GIT) describe --abbrev=0 2>/dev/null
GIT_VERSION = $(shell $(GIT_VER_CMD))
ifeq ($(strip $(GIT_VERSION)),)
GIT_VERSION=$(VERSION)
endif
ifeq ($(strip $(GIT_SHA)),)
GIT_SHA=$(SHA)
endif
# Rewriting the SHA to replace the first - with a . for A.B.C like version string
VERSION_LIST = $(word $2, $(subst -, ,$(GIT_SHA)))
GIT_SHA_REWRITE=$(call VERSION_LIST,$*,1).$(call VERSION_LIST,$*,2)-$(call VERSION_LIST,$*,3)
# the default target
default: kat
......@@ -219,7 +236,7 @@ FAST_CFLAGS=$(BASE_CFLAGS)
# compile objects from c code
%.o: %.c
$(CC) ${GSL_CFLAGS} $(BASE_CFLAGS) -c $(INCLUDES) $<
# make all
all: kat win test versionnumber
......@@ -331,7 +348,7 @@ versionnumber: config $(PREREQS)
# generate the config file
config:
# output the value of GIT_SHA to kat_config.h
@echo "#define GIT_REVISION \"$(GIT_SHA)\"" > $(KAT_CONFIG_H)
@echo "#define GIT_REVISION \"$(GIT_SHA_REWRITE)\"" > $(KAT_CONFIG_H)
@echo "#define VERSION \"$(GIT_VERSION)\"" >> $(KAT_CONFIG_H)
@echo \#define MYTIME \"`date +%d.%m.%Y`\" >> $(KAT_CONFIG_H)
......
......@@ -108,6 +108,7 @@ static int closefn(void *handler) {
}
FILE *fmemopen(void *buf, size_t size, const char *mode) {
// This data is released on fclose.
fmem_t* mem = (fmem_t *) malloc(sizeof(fmem_t));
(void)mode; // silence compiler warning;
......
......@@ -52,6 +52,9 @@
#include<gsl/gsl_multimin.h>
// for suppressing 'unused parameter warings explicitly
#define UNUSED(x) (void)(x)
#if OS == MACOS
#include <stdint.h>
typedef struct timespec_kat
......@@ -2307,7 +2310,7 @@ typedef struct minimizerN {
double abserr;
int max_iter;
gsl_multimin_fminimizer_type *T;
const gsl_multimin_fminimizer_type *T;
gsl_multimin_fminimizer *s;
gsl_vector *ss, *x;
gsl_multimin_function minex_func;
......
......@@ -321,7 +321,7 @@ void knm_matrix_mult(zmatrix A, zmatrix B, zmatrix C) {
else
tmp = C;
size_t n, m, l;
long n, m, l;
for (n = 0; n < mem.num_fields; n++) {
for (m = 0; m < mem.num_fields; m++) {
......@@ -3038,8 +3038,8 @@ int set_k_modulator(int modulator_index) {
double gouy_1 = gouy(q1);
double gouy_2 = gouy(q2);
double w1 = w_size(q1, nr1);
double w2 = w_size(q2, nr2);
//double w1 = w_size(q1, nr1);
//double w2 = w_size(q2, nr2);
complex_t factor12 = complex_1;
complex_t factor21 = complex_1;
......
......@@ -2387,7 +2387,7 @@ void set_all_tems(void) {
*
* Returns 0 if ground/dump node
*/
int get_node_q_to(node_t *node, int component_idx, complex_t *qx, complex_t *qy){
//int get_node_q_to(node_t *node, int component_idx, complex_t *qx, complex_t *qy){
// if (NOT node->gnd_node) {
// // If q was traced away from a component, a node it will have the component index
// // set to it, so here we reverse it
......@@ -2401,7 +2401,7 @@ int get_node_q_to(node_t *node, int component_idx, complex_t *qx, complex_t *qy)
// } else {
// return 0;
// }
}
//}
/***
* Gets the complex beam parameter at a node going from a component.
......@@ -2413,7 +2413,7 @@ int get_node_q_to(node_t *node, int component_idx, complex_t *qx, complex_t *qy)
*
* Returns 0 if ground/dump node
*/
int get_node_q_from(node_t *node, int component_idx, complex_t *qx, complex_t *qy){
//int get_node_q_from(node_t *node, int component_idx, complex_t *qx, complex_t *qy){
// if (NOT node->gnd_node) {
// // If q was traced "from" a node it will have the component index
// // set to it
......@@ -2427,7 +2427,7 @@ int get_node_q_from(node_t *node, int component_idx, complex_t *qx, complex_t *q
// } else {
// return 0;
// }
}
//}
//! Returns factorial for n<=100
......@@ -2890,11 +2890,17 @@ const char *get_comp_name2(int type, int list_index){
case SAGNAC: return inter.sagnac_list[list_index].name;
case MODULATOR: return inter.modulator_list[list_index].name;
case DIODE: return inter.diode_list[list_index].name;
case SPACE: return inter.space_list[list_index].name;
case SPACE:
case SPACECONNECTION:
return inter.space_list[list_index].name;
case QFEEDBACK: return inter.slink_list[list_index].name;
case LIGHT_INPUT: return inter.light_in_list[list_index].name;
case GRATING: return inter.grating_list[list_index].name;
case SQUEEZER: return inter.squeezer_list[list_index].name;
case DBS: return inter.dbs_list[list_index].name;
default:
bug_error("type not handled");
}
return NULL;
}
......@@ -2910,6 +2916,10 @@ const char *get_comp_name(int type, void *comp){
case SPACECONNECTION:
return ((space_t*)comp)->name;
case QFEEDBACK: return ((slink_t*)comp)->name;
case LIGHT_INPUT: return ((light_in_t*)comp)->name;
case GRATING: return ((grating_t*)comp)->name;
case SQUEEZER: return ((squeezer_t*)comp)->name;
case DBS: return ((dbs_t*)comp)->name;
default:
bug_error("type not handled %i", type);
}
......@@ -4946,7 +4956,7 @@ int get_function_idx(char* name){
int strhash(char *key) {
size_t len = strlen(key);
int hash, i;
for(hash = i = 0; i < len; ++i)
for(hash = i = 0; i < (int)len; ++i)
{
hash += key[i];
hash += (hash << 10);
......
......@@ -146,8 +146,11 @@ int get_function_idx(char* name);
int strhash(char *key);
int get_node_q_from(node_t *node, int component_idx, complex_t *qx, complex_t *qy);
int get_node_q_to(node_t *node, int component_idx, complex_t *qx, complex_t *qy);
// Andreas, removed at the function bodies have been
// commneted out for a while 08.11.2019
//int get_node_q_from(node_t *node, int component_idx, complex_t *qx, complex_t *qy);
//int get_node_q_to(node_t *node, int component_idx, complex_t *qx, complex_t *qy);