Created
January 20, 2013 05:11
-
-
Save danpovey/4576774 to your computer and use it in GitHub Desktop.
Fixing problems I encountered with the headers, RE const and some missing LAPACK functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8eb680b6f8f7bb6179625dbfe600e69c9c8b8dbb Mon Sep 17 00:00:00 2001 | |
From: Daniel Povey <dpovey@a13.clsp.jhu.edu> | |
Date: Sat, 19 Jan 2013 16:26:47 -0500 | |
Subject: [PATCH 1/3] Adding missing declarations to common_interface.h | |
--- | |
common_interface.h | 16 ++++++++++++++++ | |
1 files changed, 16 insertions(+), 0 deletions(-) | |
diff --git a/common_interface.h b/common_interface.h | |
index 14c2cf7..121d851 100644 | |
--- a/common_interface.h | |
+++ b/common_interface.h | |
@@ -658,6 +658,20 @@ int BLASFUNC(cgetrf)(blasint *, blasint *, float *, blasint *, blasint *, blasi | |
int BLASFUNC(zgetrf)(blasint *, blasint *, double *, blasint *, blasint *, blasint *); | |
int BLASFUNC(xgetrf)(blasint *, blasint *, xdouble *, blasint *, blasint *, blasint *); | |
+int BLASFUNC(ssptrf)(char *, blasint *, float *, blasint *, blasint *); | |
+int BLASFUNC(dsptrf)(char *, blasint *, double *, blasint *, blasint *); | |
+int BLASFUNC(qsptrf)(char *, blasint *, xdouble *, blasint *, blasint *); | |
+int BLASFUNC(csptrf)(char *, blasint *, float *, blasint *, blasint *); | |
+int BLASFUNC(zsptrf)(char *, blasint *, double *, blasint *, blasint *); | |
+int BLASFUNC(xsptrf)(char *, blasint *, xdouble *, blasint *, blasint *); | |
+ | |
+int BLASFUNC(ssptrf)(char *, blasint *, float *, blasint *, float *, blasint *); | |
+int BLASFUNC(dsptrf)(char *, blasint *, double *, blasint *, double *, blasint *); | |
+int BLASFUNC(qsptrf)(char *, blasint *, xdouble *, blasint *, xdouble *, blasint *); | |
+int BLASFUNC(csptrf)(char *, blasint *, float *, blasint *, float *, blasint *); | |
+int BLASFUNC(zsptrf)(char *, blasint *, double *, blasint *, double *, blasint *); | |
+int BLASFUNC(xsptrf)(char *, blasint *, xdouble *, blasint *, xdouble *, blasint *); | |
+ | |
int BLASFUNC(slaswp)(blasint *, float *, blasint *, blasint *, blasint *, blasint *, blasint *); | |
int BLASFUNC(dlaswp)(blasint *, double *, blasint *, blasint *, blasint *, blasint *, blasint *); | |
int BLASFUNC(qlaswp)(blasint *, xdouble *, blasint *, blasint *, blasint *, blasint *, blasint *); | |
@@ -742,6 +756,8 @@ int BLASFUNC(cpotri)(char *, blasint *, float *, blasint *, blasint *); | |
int BLASFUNC(zpotri)(char *, blasint *, double *, blasint *, blasint *); | |
int BLASFUNC(xpotri)(char *, blasint *, xdouble *, blasint *, blasint *); | |
+ | |
+ | |
int BLASFUNC(slarf)(char *, blasint *, blasint *, float *, blasint *, float *, float *, blasint *, float *); | |
int BLASFUNC(dlarf)(char *, blasint *, blasint *, double *, blasint *, double *, double *, blasint *, double *); | |
int BLASFUNC(qlarf)(char *, blasint *, blasint *, xdouble *, blasint *, xdouble *, xdouble *, blasint *, xdouble *); | |
-- | |
1.7.2.5 | |
From f219147f0337f45016647cf3406adebe7d264447 Mon Sep 17 00:00:00 2001 | |
From: Daniel Povey <dpovey@gmail.com> | |
Date: Sat, 19 Jan 2013 17:24:20 -0500 | |
Subject: [PATCH 2/3] A few bug fixes; everything seems to work now. | |
--- | |
0 files changed, 0 insertions(+), 0 deletions(-) | |
create mode 100755 add_const.pl | |
diff --git a/add_const.pl b/add_const.pl | |
new file mode 100755 | |
index 0000000..e69de29 | |
-- | |
1.7.2.5 | |
From 76b9a091956b53ad594fff09dd53d31d43dae8d3 Mon Sep 17 00:00:00 2001 | |
From: Daniel Povey <dpovey@gmail.com> | |
Date: Sat, 19 Jan 2013 17:25:01 -0500 | |
Subject: [PATCH 3/3] A few bug fixes; everything seems to work now. | |
--- | |
Makefile.install | 4 ++-- | |
add_const.pl | 29 +++++++++++++++++++++++++++++ | |
cblas.h | 6 ++++++ | |
3 files changed, 37 insertions(+), 2 deletions(-) | |
diff --git a/Makefile.install b/Makefile.install | |
index 87730a1..d30cb10 100644 | |
--- a/Makefile.install | |
+++ b/Makefile.install | |
@@ -29,12 +29,12 @@ install : lib.grd | |
@echo \#ifndef OPENBLAS_F77BLAS_H > $(OPENBLAS_INCLUDE_DIR)/f77blas.h | |
@echo \#define OPENBLAS_F77BLAS_H >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h | |
@echo \#include \"openblas_config.h\" >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h | |
- @cat common_interface.h >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h | |
+ @./add_const.pl common_interface.h >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h | |
@echo \#endif >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h | |
ifndef NO_CBLAS | |
@echo Generating cblas.h in $(OPENBLAS_INCLUDE_DIR) | |
- @sed 's/common/openblas_config/g' cblas.h > $(OPENBLAS_INCLUDE_DIR)/cblas.h | |
+ @sed 's/common/openblas_config/g' cblas.h | ./add_const.pl > $(OPENBLAS_INCLUDE_DIR)/cblas.h | |
endif | |
ifndef NO_LAPACKE | |
diff --git a/add_const.pl b/add_const.pl | |
index e69de29..6687199 100755 | |
--- a/add_const.pl | |
+++ b/add_const.pl | |
@@ -0,0 +1,29 @@ | |
+#!/usr/bin/perl | |
+ | |
+# This script is used to convert the headers cblas.h and common_interface.h in | |
+# this directory, by adding const. This makes them easier to use in external code | |
+# which uses "const". We just add const to everything. This is not really right. | |
+# What needs to be done is to use "const" correctly throughout the project, but | |
+# this would take a lot of time. | |
+ | |
+while (<>) { | |
+ # declaration of a CBLAS function, e.g. in cblas.h. | |
+ if ($_ =~ m/^\s*\w+\s+cblas_/) { | |
+ $a = $_; | |
+ while ($a =~ m/,\s*$/) { # line ends with a comma -> declaration spills over to next line. | |
+ $a .= <>; # Append the next line. | |
+ } | |
+ $a =~ s/([(,]\s*)(\w)/${1}const ${2}/g; | |
+ print $a; | |
+ } elsif ($_ =~ m/^\w*\S+\s*BLASFUNC/) { # macro that declares a | |
+ # LAPACK function, e.g. in common_interface.h. | |
+ $a = $_; | |
+ while ($a =~ m/,\s*$/) { # line ends with a comma -> declaration spills over to next line. | |
+ $a .= <>; # Append the next line. | |
+ } | |
+ $a =~ s/((\)\s*\(|,)\s*)(\w)/${1}const $3/g; | |
+ print $a; | |
+ } else { | |
+ print $_; | |
+ } | |
+} | |
diff --git a/cblas.h b/cblas.h | |
index e9664fe..6fc0f86 100644 | |
--- a/cblas.h | |
+++ b/cblas.h | |
@@ -1,6 +1,12 @@ | |
#ifndef CBLAS_H | |
#define CBLAS_H | |
+/* Warning: at the moment, this project does not use "const". In order to | |
+ avoid inconvenience for the user, we use the script add_const.pl add | |
+ "const" to all function arguments when copying this code to | |
+ $install_dir/include/. */ | |
+ | |
+ | |
#ifdef __cplusplus | |
extern "C" { | |
/* Assume C declarations for C++ */ | |
-- | |
1.7.2.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment