Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocblas.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: Rocblas.C,v 1.23 2008/12/06 08:43:18 mtcampbe Exp $
24 
29 // Name: Rocblas.C
30 // Author: Greg Mackey and Xiangmin Jiao
31 // Date: 3/31/2004 (Updated for Roccom3)
32 //
33 
34 #include "Rocblas.h"
35 
36 //Creates window for Rocblas and initializes functions.
37 void Rocblas::init(const std::string &name) {
38 
39  const COM_Type arg4_types[] = { COM_METADATA, COM_METADATA, COM_METADATA, COM_METADATA };
40  const COM_Type arg4c_types[] = { COM_METADATA, COM_METADATA, COM_METADATA, COM_MPI_COMM, COM_METADATA };
41  const COM_Type arg4a_types[] = { COM_VOID, COM_METADATA, COM_METADATA, COM_METADATA };
42  const COM_Type arg3_types[] = { COM_METADATA, COM_METADATA, COM_METADATA };
43  const COM_Type arg4cso_types[] = { COM_METADATA, COM_VOID, COM_METADATA, COM_INT };
44  const COM_Type arg4mmvm_types[] = { COM_METADATA, COM_METADATA, COM_VOID, COM_METADATA };
45  const COM_Type arg4mmvcm_types[] = { COM_METADATA, COM_METADATA, COM_VOID, COM_MPI_COMM, COM_METADATA };
46  const COM_Type arg2_types[] = { COM_METADATA, COM_METADATA };
47  const COM_Type arg2s_types[] = { COM_VOID, COM_METADATA };
48 
49  COM_new_window(name.c_str());
50  COM_set_function((name+".add").c_str(), (Func_ptr)add, "iio", arg3_types);
51  COM_set_function((name+".sub").c_str(), (Func_ptr)sub, "iio", arg3_types);
52  COM_set_function((name+".mul").c_str(), (Func_ptr)mul, "iio", arg3_types);
53  COM_set_function((name+".div").c_str(), (Func_ptr)div, "iio", arg3_types);
54  COM_set_function((name+".limit1").c_str(),
55  (Func_ptr)limit1, "iio", arg3_types);
56 
57  COM_set_function((name+".add_scalar").c_str(), (Func_ptr)add_scalar, "iioI",
58  arg4cso_types);
59  COM_set_function((name+".sub_scalar").c_str(), (Func_ptr)sub_scalar, "iioI",
60  arg4cso_types);
61  COM_set_function((name+".mul_scalar").c_str(), (Func_ptr)mul_scalar, "iioI",
62  arg4cso_types);
63  COM_set_function((name+".div_scalar").c_str(), (Func_ptr)div_scalar, "iioI",
64  arg4cso_types);
65 
66  COM_set_function((name+".maxof_scalar").c_str(), (Func_ptr)maxof_scalar, "iioI", arg4cso_types);
67 
68  COM_set_function((name+".neg").c_str(), (Func_ptr)neg, "io", arg2_types);
69  COM_set_function((name+".sqrt").c_str(), (Func_ptr)sqrt, "io", arg2_types);
70  COM_set_function((name+".acos").c_str(), (Func_ptr)acos, "io", arg2_types);
71  COM_set_function((name+".dot").c_str(), (Func_ptr)dot, "iioI", arg4_types);
72  COM_set_function((name+".dot_scalar").c_str(), (Func_ptr)dot_scalar, "iioI", arg4mmvm_types);
73  COM_set_function((name+".dot_MPI").c_str(), (Func_ptr)dot_MPI, "iioII", arg4c_types);
74  COM_set_function((name+".dot_scalar_MPI").c_str(), (Func_ptr)dot_scalar_MPI, "iioII", arg4mmvcm_types);
75  COM_set_function((name+".nrm2").c_str(), (Func_ptr)nrm2, "ioI", &arg4_types[1]);
76  COM_set_function((name+".nrm2_scalar").c_str(), (Func_ptr)nrm2_scalar, "ioI", &arg4mmvm_types[1]);
77 
78  COM_set_function((name+".nrm2_MPI").c_str(), (Func_ptr)nrm2_MPI, "ioII", &arg4c_types[1]);
79  COM_set_function((name+".nrm2_scalar_MPI").c_str(), (Func_ptr)nrm2_scalar_MPI, "ioII", &arg4mmvcm_types[1]);
80 
81  COM_set_function((name+".swap").c_str(), (Func_ptr)swap, "bb", arg2_types);
82  COM_set_function((name+".copy").c_str(), (Func_ptr)copy, "io", arg2_types);
83  COM_set_function((name+".rand").c_str(), (Func_ptr)rand, "io", arg2_types);
84  COM_set_function((name+".copy_scalar").c_str(), (Func_ptr)copy_scalar,
85  "io", arg2s_types);
86  COM_set_function((name+".rand_scalar").c_str(), (Func_ptr)rand_scalar,
87  "io", arg2s_types);
88  COM_set_function((name+".axpy").c_str(), (Func_ptr)axpy, "iiio",
89  arg4_types);
90  COM_set_function((name+".axpy_scalar").c_str(), (Func_ptr)axpy_scalar,
91  "iiio", arg4a_types);
92 
94  COM_set_function((name+".min_MPI").c_str(),
95  (Func_ptr)min_MPI, "ioI", types);
96  COM_set_function((name+".max_MPI").c_str(),
97  (Func_ptr)max_MPI, "ioI", types);
98  COM_set_function((name+".sum_MPI").c_str(),
99  (Func_ptr)sum_MPI, "ioI", types);
100 
101  types[1] = COM_VOID;
102  COM_set_function((name+".min_scalar_MPI").c_str(),
103  (Func_ptr)min_scalar_MPI, "ioI", types);
104  COM_set_function((name+".max_scalar_MPI").c_str(),
105  (Func_ptr)max_scalar_MPI, "ioI", types);
106  COM_set_function((name+".sum_scalar_MPI").c_str(),
107  (Func_ptr)sum_scalar_MPI, "ioI", types);
108 
109  COM_window_init_done(name.c_str());
110 }
111 
112 void Rocblas::finalize(const std::string &name) {
113  COM_delete_window( name.c_str());
114 }
115 
116 
117 //Calls Rocblas initialization function.
118 extern "C" void Rocblas_load_module(const char *name) {
119  Rocblas::init(std::string(name));
120 }
121 extern "C" void Rocblas_unload_module(const char *name) {
122  Rocblas::finalize(std::string(name));
123 }
124 
125 #ifndef DOXYGEN_SHOULD_SKIP_THIS
126 
127 // All possible Fortran bindings
128 extern "C" void rocblas_load_module( const char *name, int length)
129 { Rocblas::init( std::string(name, length)); }
130 extern "C" void rocblas_unload_module( const char *name, int length)
131 { Rocblas::finalize( std::string(name, length)); }
132 
133 extern "C" void rocblas_load_module_( const char *name, int length)
134 { Rocblas::init( std::string(name, length)); }
135 extern "C" void rocblas_unload_module_( const char *name, int length)
136 { Rocblas::finalize( std::string(name, length)); }
137 
138 extern "C" void ROCBLAS_LOAD_MODULE( const char *name, int length)
139 { Rocblas::init( std::string(name, length)); }
140 extern "C" void ROCBLAS_UNLOAD_MODULE( const char *name, int length)
141 { Rocblas::finalize( std::string(name, length)); }
142 
143 extern "C" void ROCBLAS_LOAD_MODULE_( const char *name, int length)
144 { Rocblas::init( std::string(name, length)); }
145 extern "C" void ROCBLAS_UNLOAD_MODULE_( const char *name, int length)
146 { Rocblas::finalize( std::string(name, length)); }
147 
148 #endif // DOXYGEN_SHOULD_SKIP_THIS
149 
150 
151 
152 
153 
154 
static void div_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for division with y as a scalar pointer.
Definition: op3args.C:363
static void sub(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for subtraction.
Definition: op3args.C:237
int COM_Type
Indices for derived data types.
Definition: roccom_basic.h:122
void rocblas_unload_module_(const char *name, int length)
Definition: Rocblas.C:135
static void nrm2_scalar(const Attribute *x, void *y, const Attribute *mults=NULL)
Wrapper for 2-norm with y as a scalar pointer.
Definition: dots.C:293
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
static void nrm2_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL, const Attribute *mults=NULL)
Wrapper for 2-norm with MPI.
Definition: dots.C:298
static void rand(const Attribute *a, Attribute *z)
Generate a random number between 0 and $a$ for each entry in z.
Definition: op2args.C:388
void COM_set_function(const char *wf_str, Func_ptr func, const char *intents, const COM_Type *types)
Definition: roccom_c++.h:323
static void max_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm=NULL)
Operation wrapper for max (y is a scalar pointer).
Definition: op2args.C:763
static void init(const std::string &name)
Creates window for Rocblas and registers functions.
Definition: Rocblas.C:37
static void limit1(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for limit1.
Definition: op3args.C:284
static void dot_scalar_MPI(const Attribute *x, const Attribute *y, void *z, const MPI_Comm *comm=NULL, const Attribute *mults=NULL)
Wrapper for 2-norm with z as a scalar pointer.
Definition: dots.C:264
double length(Vector3D *const v, int n)
static void axpy(const Attribute *a, const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for z = a * x + y.
Definition: axpy.C:170
static void min_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL)
Wrapper for min.
Definition: op2args.C:714
static void max_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL)
Wrapper for max.
Definition: op2args.C:708
static void acos(const Attribute *x, Attribute *y)
Wrapper for acos (y=acos(x)).
Definition: op2args.C:545
void ROCBLAS_LOAD_MODULE_(const char *name, int length)
Definition: Rocblas.C:143
static void add(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for addition.
Definition: op3args.C:221
static void mul_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for multiplication with y as a scalar pointer.
Definition: op3args.C:347
static void finalize(const std::string &name)
Delete window for Rocblas.
Definition: Rocblas.C:112
static void dot_scalar(const Attribute *x, const Attribute *y, void *z, const Attribute *mults=NULL)
Wrapper for 2-norm with z as a scalar pointer.
Definition: dots.C:283
void rocblas_load_module(const char *name, int length)
Definition: Rocblas.C:128
static void axpy_scalar(const void *a, const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for z = a * x + y (a is a scalar pointer).
Definition: axpy.C:210
void Rocblas_unload_module(const char *name)
Definition: Rocblas.C:121
void(* Func_ptr)()
Pointer of functions.
Definition: roccom_basic.h:123
static void min_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm=NULL)
Operation wrapper for min (y is a scalar pointer).
Definition: op2args.C:771
static void sum_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm=NULL)
Operation wrapper for sum (y is a scalar pointer).
Definition: op2args.C:778
static void div(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for division.
Definition: op3args.C:269
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
static void sum_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL)
Wrapper for sum.
Definition: op2args.C:720
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
Definition for Rocblas API.
static void neg(const Attribute *x, Attribute *y)
Wrapper for neg (y=-x).
Definition: op2args.C:455
void ROCBLAS_UNLOAD_MODULE(const char *name, int length)
Definition: Rocblas.C:140
static void nrm2_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm, const Attribute *mults=NULL)
Wrapper for 2-norm with y as a scalar pointer with MPI.
Definition: dots.C:303
static void copy_scalar(const void *x, Attribute *y)
Operation wrapper for copy (x is a scalar pointer).
Definition: op2args.C:583
static void rand_scalar(const void *a, Attribute *z)
Generate a random number between 0 and $a$ for each entry in z.
Definition: op2args.C:604
static void swap(Attribute *x, Attribute *y)
Wrapper for swap.
Definition: op2args.C:271
static void copy(const Attribute *x, Attribute *y)
Wrapper for copy.
Definition: op2args.C:333
void rocblas_load_module_(const char *name, int length)
Definition: Rocblas.C:133
static void nrm2(const Attribute *x, Attribute *y, const Attribute *mults=NULL)
Wrapper for 2-norm.
Definition: dots.C:288
static void sqrt(const Attribute *x, Attribute *y)
Wrapper for sqrt (y=sqrt(x)).
Definition: op2args.C:507
void ROCBLAS_LOAD_MODULE(const char *name, int length)
Definition: Rocblas.C:138
static void dot(const Attribute *x, const Attribute *y, Attribute *z, const Attribute *mults=NULL)
Wrapper for dot product.
Definition: dots.C:279
static void maxof_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for addition with y as a scalar pointer.
Definition: op3args.C:315
static void dot_MPI(const Attribute *x, const Attribute *y, Attribute *z, const MPI_Comm *comm=NULL, const Attribute *mults=NULL)
Wrapper for dot product.
Definition: dots.C:226
void Rocblas_load_module(const char *name)
Calls Rocblas initialization function.
Definition: Rocblas.C:118
static void add_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for addition with y as a scalar pointer.
Definition: op3args.C:299
static void mul(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for multiplication.
Definition: op3args.C:253
void ROCBLAS_UNLOAD_MODULE_(const char *name, int length)
Definition: Rocblas.C:145
void rocblas_unload_module(const char *name, int length)
Definition: Rocblas.C:130
static void sub_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for subtraction with y as a scalar pointer.
Definition: op3args.C:331