Line data Source code
1 : /*************************************************************************
2 : *
3 : * Project
4 : * _____ _____ __ __ _____
5 : * / ____| __ \| \/ | __ \
6 : * ___ _ __ ___ _ __ | | __| |__) | \ / | |__) |
7 : * / _ \| '_ \ / _ \ '_ \| | |_ | ___/| |\/| | ___/
8 : *| (_) | |_) | __/ | | | |__| | | | | | | |
9 : * \___/| .__/ \___|_| |_|\_____|_| |_| |_|_|
10 : * | |
11 : * |_|
12 : *
13 : * Copyright (C) Akiel Aries, <akiel@akiel.org>, et al.
14 : *
15 : * This software is licensed as described in the file LICENSE, which
16 : * you should have received as part of this distribution. The terms
17 : * among other details are referenced in the official documentation
18 : * seen here : https://akielaries.github.io/openGPMP/ along with
19 : * important files seen in this project.
20 : *
21 : * You may opt to use, copy, modify, merge, publish, distribute
22 : * and/or sell copies of the Software, and permit persons to whom
23 : * the Software is furnished to do so, under the terms of the
24 : * LICENSE file. As this is an Open Source effort, all implementations
25 : * must be of the same methodology.
26 : *
27 : *
28 : *
29 : * This software is distributed on an AS IS basis, WITHOUT
30 : * WARRANTY OF ANY KIND, either express or implied.
31 : *
32 : ************************************************************************/
33 : #include <cassert>
34 : #include <cstddef>
35 : #include <cstdint>
36 : #include <iostream>
37 : #include <openGPMP/linalg/mtx.hpp>
38 : #include <vector>
39 :
40 : /************************************************************************
41 : *
42 : * Matrix Operations on Arrays using Fortran Subroutines
43 : * in `mtx_routines.f90`
44 : *
45 : ************************************************************************/
46 :
47 : // if source C++ API is being compiled, include these Fortran refs and wrappers
48 : #if defined(__GPMP_CPP_API__)
49 :
50 : extern "C" {
51 : // Matrix add routine (FLOAT)
52 : void mtx_add_routine_float_(float *A,
53 : float *B,
54 : float *C,
55 : std::size_t *mtx_size);
56 :
57 : // Matrix add routine (INT)
58 : void mtx_add_routine_int_(int *A, int *B, int *C, std::size_t *mtx_size);
59 :
60 : void mtx_mult_routine_int_(int *A,
61 : int *B,
62 : int *C,
63 : std::size_t *rows_a,
64 : std::size_t *cols_a,
65 : std::size_t *cols_b);
66 : }
67 :
68 : // C++ wrapper for Fortran mtx addition subroutine FLOAT
69 0 : void gpmp::linalg::Mtx::mtx_add_f90(float *A,
70 : float *B,
71 : float *C,
72 : std::size_t mtx_size) {
73 0 : mtx_add_routine_float_(A, B, C, &mtx_size);
74 0 : }
75 :
76 : // C++ wrapper for Fortran mtx addition subroutine INT
77 1 : void gpmp::linalg::Mtx::mtx_add_f90(int *A,
78 : int *B,
79 : int *C,
80 : std::size_t mtx_size) {
81 1 : mtx_add_routine_int_(A, B, C, &mtx_size);
82 1 : }
83 :
84 : // C++ wrapper for Fortran mtx multiplication subroutine INT
85 2 : void gpmp::linalg::Mtx::mtx_mult_f90(int *A,
86 : int *B,
87 : int *C,
88 : std::size_t rows_a,
89 : std::size_t cols_a,
90 : std::size_t cols_b) {
91 2 : mtx_mult_routine_int_(A, B, C, &rows_a, &cols_a, &cols_b);
92 2 : }
93 :
94 : #endif
|