Introduce openblas_get_num_threads and openblas_get_num_procs
authorErik Schnetter <schnetter@gmail.com>
Tue, 3 Feb 2015 17:23:34 +0000 (12:23 -0500)
committerErik Schnetter <schnetter@gmail.com>
Tue, 3 Feb 2015 17:23:41 +0000 (12:23 -0500)
cblas.h
cblas_noconst.h
driver/others/Makefile
driver/others/memory.c
driver/others/openblas_get_num_procs.c [new file with mode: 0644]
driver/others/openblas_get_num_threads.c [new file with mode: 0644]
exports/gensymbol

diff --git a/cblas.h b/cblas.h
index d1c029a..a21863d 100644 (file)
--- a/cblas.h
+++ b/cblas.h
@@ -13,6 +13,12 @@ extern "C" {
 void openblas_set_num_threads(int num_threads);
 void goto_set_num_threads(int num_threads);
 
+/*Get the number of threads on runtime.*/
+int openblas_get_num_threads(void);
+
+/*Get the number of physical processors (cores).*/
+int openblas_get_num_procs(void);
+
 /*Get the build configure on runtime.*/
 char* openblas_get_config(void);
 
index bc63825..f6a6baf 100644 (file)
@@ -13,6 +13,12 @@ extern "C" {
 void openblas_set_num_threads(int num_threads);
 void goto_set_num_threads(int num_threads);
 
+/*Get the number of threads on runtime.*/
+int openblas_get_num_threads(void);
+
+/*Get the number of physical processors (cores).*/
+int openblas_get_num_procs(void);
+
 /*Get the build configure on runtime.*/
 char* openblas_get_config(void);
 
index fc73871..ed145ce 100644 (file)
@@ -1,7 +1,7 @@
 TOPDIR = ../..
 include ../../Makefile.system
 
-COMMONOBJS      = memory.$(SUFFIX) xerbla.$(SUFFIX) c_abs.$(SUFFIX) z_abs.$(SUFFIX) openblas_set_num_threads.$(SUFFIX) openblas_get_config.$(SUFFIX) openblas_get_parallel.$(SUFFIX) openblas_error_handle.$(SUFFIX)
+COMMONOBJS      = memory.$(SUFFIX) xerbla.$(SUFFIX) c_abs.$(SUFFIX) z_abs.$(SUFFIX) openblas_set_num_threads.$(SUFFIX) openblas_get_num_threads.$(SUFFIX) openblas_get_num_procs.$(SUFFIX) openblas_get_config.$(SUFFIX) openblas_get_parallel.$(SUFFIX) openblas_error_handle.$(SUFFIX)
 
 #COMMONOBJS    += slamch.$(SUFFIX) slamc3.$(SUFFIX) dlamch.$(SUFFIX)  dlamc3.$(SUFFIX)
 
@@ -103,6 +103,12 @@ blas_server.$(SUFFIX) : $(BLAS_SERVER) ../../common.h ../../common_thread.h ../.
 openblas_set_num_threads.$(SUFFIX) : openblas_set_num_threads.c
        $(CC) $(CFLAGS) -c $< -o $(@F)
 
+openblas_get_num_threads.$(SUFFIX) : openblas_get_num_threads.c
+       $(CC) $(CFLAGS) -c $< -o $(@F)
+
+openblas_get_num_procs.$(SUFFIX) : openblas_get_num_procs.c
+       $(CC) $(CFLAGS) -c $< -o $(@F)
+
 openblas_get_config.$(SUFFIX) : openblas_get_config.c
        $(CC) $(CFLAGS) -c $< -o $(@F)
 
index 16d68cc..e245d9e 100644 (file)
@@ -241,6 +241,10 @@ void set_stack_limit(int limitMB){
 */
 #endif
 
+int openblas_get_num_procs(void) {
+  return get_num_procs();
+}
+
 /*
 OpenBLAS uses the numbers of CPU cores in multithreading.
 It can be set by openblas_set_num_threads(int num_threads);
@@ -323,6 +327,10 @@ int blas_get_cpu_number(void){
 }
 #endif
 
+int openblas_get_num_threads(void) {
+  return blas_get_cpu_number();
+}
+
 struct release_t {
   void *address;
   void (*func)(struct release_t *);
diff --git a/driver/others/openblas_get_num_procs.c b/driver/others/openblas_get_num_procs.c
new file mode 100644 (file)
index 0000000..6b0c1ec
--- /dev/null
@@ -0,0 +1,40 @@
+/*****************************************************************************
+Copyright (c) 2011-2014, The OpenBLAS Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in
+      the documentation and/or other materials provided with the
+      distribution.
+   3. Neither the name of the OpenBLAS project nor the names of 
+      its contributors may be used to endorse or promote products 
+      derived from this software without specific prior written 
+      permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**********************************************************************************/
+
+#include "common.h"
+
+extern int openblas_get_num_procs(void);
+
+int openblas_get_num_procs_(void) {
+  return openblas_get_num_procs();
+}
diff --git a/driver/others/openblas_get_num_threads.c b/driver/others/openblas_get_num_threads.c
new file mode 100644 (file)
index 0000000..e31aa4b
--- /dev/null
@@ -0,0 +1,40 @@
+/*****************************************************************************
+Copyright (c) 2011-2014, The OpenBLAS Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in
+      the documentation and/or other materials provided with the
+      distribution.
+   3. Neither the name of the OpenBLAS project nor the names of 
+      its contributors may be used to endorse or promote products 
+      derived from this software without specific prior written 
+      permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**********************************************************************************/
+
+#include "common.h"
+
+extern int openblas_get_num_threads(void);
+
+int openblas_get_num_threads_(void) {
+  return openblas_get_num_threads();
+}
index 8bd2f17..2155f80 100644 (file)
 
 #both underscore and no underscore
 @misc_common_objs = (
-                     openblas_set_num_threads, openblas_get_parallel,
+                     openblas_get_parallel,
+                     openblas_get_num_procs,
+                     openblas_set_num_threads,
+                     openblas_get_num_threads,
                     );
 
 @misc_no_underscore_objs = (