ALP User Documentation  0.8.preview
Algebraic Programming User Documentation
blas3.hpp
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2021 Huawei Technologies Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
26 #ifndef _H_GRB_BLAS3_BASE
27 #define _H_GRB_BLAS3_BASE
28 
29 #include <graphblas/backends.hpp>
30 #include <graphblas/phase.hpp>
31 
32 #include "matrix.hpp"
33 #include "vector.hpp"
34 
35 
36 namespace grb {
37 
87  template<
89  typename OutputType, typename InputType1, typename InputType2,
90  typename CIT1, typename RIT1, typename NIT1,
91  typename CIT2, typename RIT2, typename NIT2,
92  typename CIT3, typename RIT3, typename NIT3,
93  class Semiring,
94  Backend backend
95  >
100  const Semiring &ring = Semiring(),
101  const Phase &phase = EXECUTE
102  ) {
103 #ifdef _DEBUG
104  std::cerr << "Selected backend does not implement grb::mxm "
105  << "(semiring version)\n";
106 #endif
107 #ifndef NDEBUG
108  const bool selected_backend_does_not_support_mxm = false;
109  assert( selected_backend_does_not_support_mxm );
110 #endif
111  (void) C;
112  (void) A;
113  (void) B;
114  (void) ring;
115  (void) phase;
116  // this is the generic stub implementation
117  return UNSUPPORTED;
118  }
119 
177  template<
179  typename OutputType, typename InputType1, typename InputType2,
180  typename InputType3, typename RIT, typename CIT, typename NIT,
181  Backend backend, typename Coords
182  >
188  const Phase &phase = EXECUTE
189  ) {
190  (void) x;
191  (void) y;
192  (void) z;
193  (void) phase;
194 #ifdef _DEBUG
195  std::cerr << "Selected backend does not implement grb::zip (vectors into "
196  << "matrices, non-void)\n";
197 #endif
198 #ifndef NDEBUG
199  const bool selected_backend_does_not_support_zip_from_vectors_to_matrix
200  = false;
201  assert( selected_backend_does_not_support_zip_from_vectors_to_matrix );
202 #endif
203  const RC ret = grb::clear( A );
204  return ret == SUCCESS ? UNSUPPORTED : ret;
205  }
206 
219  template<
221  typename InputType1, typename InputType2, typename InputType3,
222  typename RIT, typename CIT, typename NIT,
223  Backend backend, typename Coords
224  >
229  const Phase &phase = EXECUTE
230  ) {
231  (void) x;
232  (void) y;
233  (void) phase;
234 #ifdef _DEBUG
235  std::cerr << "Selected backend does not implement grb::zip (vectors into "
236  << "matrices, void)\n";
237 #endif
238 #ifndef NDEBUG
239  const bool selected_backend_does_not_support_zip_from_vectors_to_void_matrix
240  = false;
241  assert( selected_backend_does_not_support_zip_from_vectors_to_void_matrix );
242 #endif
243  const RC ret = grb::clear( A );
244  return ret == SUCCESS ? UNSUPPORTED : ret;
245  }
246 
309  template<
311  class Monoid,
312  typename OutputType, typename InputType1, typename InputType2,
313  typename RIT1, typename CIT1, typename NIT1,
314  typename RIT2, typename CIT2, typename NIT2,
315  typename RIT3, typename CIT3, typename NIT3,
316  Backend backend
317  >
322  const Monoid &monoid,
323  const Phase phase = EXECUTE,
324  const typename std::enable_if<
329  void >::type * const = nullptr
330  ) {
331  (void) C;
332  (void) A;
333  (void) B;
334  (void) phase;
335 #ifdef _DEBUG
336  std::cerr << "Selected backend does not implement grb::eWiseApply\n";
337 #endif
338 #ifndef NDEBUG
339  const bool selected_backend_does_not_support_ewiseapply = false;
340  assert( selected_backend_does_not_support_ewiseapply );
341 #endif
342  const RC ret = grb::clear( A );
343  return ret == SUCCESS ? UNSUPPORTED : ret;
344  }
345 
408  template<
410  class Operator,
411  typename OutputType, typename InputType1, typename InputType2,
412  typename RIT1, typename CIT1, typename NIT1,
413  typename RIT2, typename CIT2, typename NIT2,
414  typename RIT3, typename CIT3, typename NIT3,
415  Backend backend
416  >
421  const Operator &op,
422  const Phase phase = EXECUTE,
423  const typename std::enable_if<
428  void >::type * const = nullptr
429  ) {
430  (void) C;
431  (void) A;
432  (void) B;
433  (void) phase;
434 #ifdef _DEBUG
435  std::cerr << "Selected backend does not implement grb::eWiseApply\n";
436 #endif
437 #ifndef NDEBUG
438  const bool selected_backend_does_not_support_ewiseapply = false;
439  assert( selected_backend_does_not_support_ewiseapply );
440 #endif
441  const RC ret = grb::clear( A );
442  return ret == SUCCESS ? UNSUPPORTED : ret;
443  }
444 
449 } // namespace grb
450 
451 #endif // end _H_GRB_BLAS3_BASE
452 
RC eWiseApply(Vector< OutputType, backend, Coords > &z, const InputType1 alpha, const InputType2 beta, const OP &op=OP(), const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< OutputType >::value &&!grb::is_object< InputType1 >::value &&!grb::is_object< InputType2 >::value &&grb::is_operator< OP >::value, void >::type *const =nullptr)
Computes , out of place, operator version.
Definition: blas1.hpp:208
This file contains a register of all backends that are either implemented, under implementation,...
An ALP/GraphBLAS matrix.
Definition: matrix.hpp:72
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
A GraphBLAS vector.
Definition: vector.hpp:64
Specifies the ALP/GraphBLAS matrix container.
Used to inspect whether a given type is an ALP monoid.
Definition: type_traits.hpp:85
Speculatively assumes that the output container of the requested operation has enough capacity to com...
Definition: phase.hpp:257
Defines the various phases an ALP/GraphBLAS primitive may be executed with.
Used to inspect whether a given type is an ALP/GraphBLAS object.
Definition: type_traits.hpp:130
Phase
Primitives with sparse ALP/GraphBLAS output containers may run into the issue where an appropriate gr...
Definition: phase.hpp:152
static constexpr Descriptor no_operation
Indicates no additional pre- or post-processing on any of the GraphBLAS function arguments.
Definition: descriptors.hpp:63
unsigned int Descriptor
Descriptors indicate pre- or post-processing for some or all of the arguments to an ALP/GraphBLAS cal...
Definition: descriptors.hpp:54
Indicates that the execution of the requested primitive with the given arguments is not supported by ...
Definition: rc.hpp:129
Backend
A collection of all backends.
Definition: backends.hpp:49
RC zip(Matrix< OutputType, backend, RIT, CIT, NIT > &A, const Vector< InputType1, backend, Coords > &x, const Vector< InputType2, backend, Coords > &y, const Vector< InputType3, backend, Coords > &z, const Phase &phase=EXECUTE)
The grb::zip merges three vectors into a matrix.
Definition: blas3.hpp:183
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:477
Specifies the ALP/GraphBLAS vector container.
RC mxm(Matrix< OutputType, backend, CIT1, RIT1, NIT1 > &C, const Matrix< InputType1, backend, CIT2, RIT2, NIT2 > &A, const Matrix< InputType2, backend, CIT3, RIT3, NIT3 > &B, const Semiring &ring=Semiring(), const Phase &phase=EXECUTE)
Unmasked and in-place sparse matrix–sparse matrix multiplication (SpMSpM), .
Definition: blas3.hpp:96
Indicates the primitive has executed successfully.
Definition: rc.hpp:54
A generalised semiring.
Definition: semiring.hpp:190
Used to inspect whether a given type is an ALP operator.
Definition: type_traits.hpp:104
RC clear(Vector< DataType, backend, Coords > &x) noexcept
Clears a given vector of all nonzeroes.
Definition: io.hpp:574
A generalised monoid.
Definition: monoid.hpp:54