GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
GHOST 1.1.2 API documentation

Minimal code example

The following code example performs a sparse matrix-vector multiplication with random input vector and a diagonal matrix.

#include <ghost.h>
#include <stdio.h>
#define N 4
static int diag(ghost_gidx row, ghost_lidx *rowlen, ghost_gidx *col, void *val, __attribute__((unused)) void *arg)
{
*rowlen = 1;
col[0] = row;
((double *)val)[0] = (double)(row+1);
return 0;
}
int main(int argc, char **argv)
{
double zero = 0.;
char *Astr, *xstr, *ystr;
mtraits.flags = GHOST_SPARSEMAT_SAVE_ORIG_COLS; // needed for printing if more than one process
// create matrix source
matsrc.func = diag;
matsrc.maxrowlen = 1;
matsrc.gnrows = N;
// create sparse matrix A from row-wise source function
GHOST_CALL_RETURN(ghost_sparsemat_create(&A, NULL, &mtraits, 1));
// create and initialize input vector x and output vector y
// compute y = A*x
// print y, A and x
printf("%s\n=\n%s\n*\n%s\n",ystr,Astr,xstr);
// clean up
free(Astr);
free(xstr);
free(ystr);
return 0;
}

This Doxygen documentation has been created with the following ghost/config.h:

/**
 * @file config.h.in
 * @brief The config header for GHOST.
 * @author Moritz Kreutzer <moritz.kreutzer@fau.de>
 */
#ifndef GHOST_CONFIG_H
#define GHOST_CONFIG_H

/* project settings */
#define GHOST_NAME "GHOST"
#define GHOST_VERSION "1.1.2"
#define GHOST_VERSION_MAJOR 1
#define GHOST_VERSION_MINOR 1
#define GHOST_VERSION_REVISION 2

/* third party libraries */
#define GHOST_HAVE_MPI
#define GHOST_HAVE_OPENMP
/* #undef GHOST_HAVE_SCOTCH */
/* #undef GHOST_HAVE_COLPACK */
/* #undef GHOST_HAVE_ZOLTAN */
#define GHOST_HAVE_CUDA
/* #undef GHOST_HAVE_OPENCL */
/* #undef GHOST_HAVE_MKL */
#define GHOST_HAVE_GSL
/* #undef GHOST_HAVE_LIBSCI */
/* #undef GHOST_HAVE_LAPACK */
/* #undef GHOST_HAVE_SPMP */
/* #undef GHOST_HAVE_GPUDIRECT */

/* hardware features */
/* #undef GHOST_BUILD_MIC */
/* #undef GHOST_BUILD_AVX512 */
#define GHOST_BUILD_AVX2
#define GHOST_BUILD_AVX
#define GHOST_BUILD_SSE

/* instrumentation */
/* #undef GHOST_INSTR_TIMING */
/* #undef GHOST_INSTR_IACA */
/* #undef GHOST_INSTR_LIKWID */
/* #undef GHOST_INSTR_BARRIER */
/* #undef GHOST_TRACK_DATATRANSFERS */
#define GHOST_INSTRUMENT_FUNCTYPES "(functype) & GHOST_FUNCTYPE_ANY"

/* logging */
#define GHOST_LOG_ONLYFIRST
/* #undef GHOST_LOG_TIMESTAMP */
#define GHOST_LOG_RANK -1
#define GHOST_VERBOSITY 1

/* index size */
/* #undef GHOST_IDX64_LOCAL */
#define GHOST_IDX64_GLOBAL

/* code generation */
#define GHOST_AUTOGEN_MAX_CHUNKHEIGHT "32"
#define GHOST_AUTOGEN_KACZ "*,*,*;32,1,0;32,4,0;1,4,0;1,4,4"
#define GHOST_AUTOGEN_SPMMV "*,*;32,1;1,4;32,*;1,*"
#define GHOST_AUTOGEN_SPMMV_CUDA "32,1,0,0,0,0,0,0,0;1,4,0,0,0,0,0,0,0;32,*,0,0,0,0,0,0,0;1,*,0,0,0,0,0,0,0"

/* sparsemat statistics */
/* #undef GHOST_SPARSEMAT_STATS */
/* #undef GHOST_SPARSEMAT_GLOBALSTATS */

/* Kaczmarz analytics*/
/* #undef GHOST_KACZ_ANALYZE */

/* Compatibility checking */
#define GHOST_COMPATIBLE_CHECK
/* #undef GHOST_COMPATIBLE_PERM */

/* Platform checks */
#define HAVE_QSORT_R

/* Benchmarks */
#define GHOST_STREAM_ARRAY_SIZE 1e6

#endif