Skip to content
Permalink
Browse files

Merge pull request #1 from mcg1969/master

Updated dortwp
  • Loading branch information...
tenomoto committed Sep 14, 2014
2 parents ea3da3a + 1dde8d5 commit d5816854fd4e97e44fe82bca519e1f174dd17408
Showing with 109 additions and 56 deletions.
  1. +28 −6 README
  2. +81 −0 dotwrp.c
  3. +0 −50 dotwrp.f90
34 README
@@ -1,8 +1,30 @@
# dotwrp.f90
# dotwrp.c

This is a wrapper for four Level 1 BLAS functions
CDOTC CDOTU ZDOTC ZDOTU and SDOT in Accelerate.framework
of Mac OS X.
This is a wrapper for all of the BLAS functions in Apple's vecLib Framework
that have compatibility issues between F2C and GNU Fortran.

# Reference
http://developer.apple.com/hardwaredrivers/ve/errata.html#fortran_conventions
The functions fixed are:
cdotc
cdotu
zdotc
zdotu
sdot
snrm2
sasum
scnrm2
scasum
All other BLAS routines work correctly with or without the -ff2c flag.

Instead of using this package, you could instead compile your FORTRAN with
-ff2c. However, if your code exports any functions returning single-precision
or (single- or double-precision) complex results, then any code that calls
those functions will be forced to follow F2C conventions as well.

To use, just add dotwrp.c to your existing project, or link to it statically.

This is an expansion of the "dotwrp" project by tenomoto:
https://github.com/tenomoto/dotwrp
We've chosen to convert the f90 code to c so we can take advantage of the
__attribute__((visibility ("hidden"))) settings. This ensures that the symbols
generated by this code are not visible outside of your project---which is
important if you're mixing multiple FORTRAN-based projects together.
@@ -0,0 +1,81 @@
// compile with: clang -c dotwrp.c
#include <vecLib/cblas.h>

#ifdef DOTWRP_GLOBAL
#define DYLIB_LOCAL
#else
#define DYLIB_LOCAL __attribute__ ((visibility ("hidden")))
#endif

typedef struct cplx_ { float r, i; } fcplx;
typedef struct dcplx_ { double r, i; } dcplx;

DYLIB_LOCAL
dcplx zdotc_( const int* n, const dcplx* x, const int* ix, const dcplx *y, const int* iy )
{
dcplx z;
cblas_zdotc_sub( *n, x, *ix, y, *iy, &z );
return z;
}

DYLIB_LOCAL
dcplx zdotu_( const int* n, const dcplx* x, const int* ix, const dcplx *y, const int* iy )
{
dcplx z;
cblas_zdotu_sub( *n, x, *ix, y, *iy, &z );
return z;
}

DYLIB_LOCAL
fcplx cdotc_( const int* n, const fcplx* x, const int* ix, const fcplx *y, const int* iy )
{
fcplx z;
cblas_cdotc_sub( *n, x, *ix, y, *iy, &z );
return z;
}

DYLIB_LOCAL
fcplx cdotu_( const int* n, const fcplx* x, const int* ix, const fcplx *y, const int* iy )
{
fcplx z;
cblas_cdotu_sub( *n, x, *ix, y, *iy, &z );
return z;
}

DYLIB_LOCAL
float sdot_( const int* n, const float* x, const int* ix, const float *y, const int* iy )
{
return cblas_sdot( *n, x, *ix, y, *iy );
}

DYLIB_LOCAL
float sdsdot_( const int* n, const float* a, const float* x, const int* ix, const float *y, const int* iy )
{
return cblas_sdsdot( *n, *a, x, *ix, y, *iy );
}

DYLIB_LOCAL
float snrm2_( const int* n, const float* x, const int* ix )
{
return cblas_snrm2( *n, x, *ix );
}

DYLIB_LOCAL
float sasum_( const int* n, const float* x, const int* ix )
{
return cblas_snrm2( *n, x, *ix );
}

DYLIB_LOCAL
float scnrm2_( const int* n, const fcplx* x, const int* ix )
{
return cblas_scnrm2( *n, x, *ix );
}

DYLIB_LOCAL
float scasum_( const int* n, const fcplx* x, const int* ix )
{
return cblas_scasum( *n, x, *ix );
}


This file was deleted.

Oops, something went wrong.

0 comments on commit d581685

Please sign in to comment.
You can’t perform that action at this time.