27 #include <type_traits> 30 #ifndef _H_GRB_IO_BASE 31 #define _H_GRB_IO_BASE 36 #include <graphblas/synchronizedNonzeroIterator.hpp> 154 typename ElementType,
typename Coords,
155 Backend implementation = config::default_backend
162 const bool this_is_an_invalid_default_implementation =
false;
164 assert( this_is_an_invalid_default_implementation );
165 return static_cast< uintptr_t >(-1);
175 typename ElementType,
typename RIT,
typename CIT,
typename NIT,
176 Backend implementation = config::default_backend
183 const bool this_is_an_invalid_default_implementation =
false;
185 assert( this_is_an_invalid_default_implementation );
186 return static_cast< uintptr_t >(-1);
233 Backend backend,
typename Coords
237 const bool may_not_call_base_size =
false;
240 assert( may_not_call_base_size );
283 typename InputType,
Backend backend,
284 typename RIT,
typename CIT,
typename NIT
290 const bool may_not_call_base_nrows =
false;
293 assert( may_not_call_base_nrows );
336 typename InputType,
Backend backend,
337 typename RIT,
typename CIT,
typename NIT
343 const bool may_not_call_base_ncols =
false;
346 assert( may_not_call_base_ncols );
386 typename InputType,
Backend backend,
typename Coords
390 const bool should_not_call_base_vector_capacity =
false;
392 assert( should_not_call_base_vector_capacity );
429 typename InputType,
Backend backend,
430 typename RIT,
typename CIT,
typename NIT
436 const bool should_not_call_base_matrix_capacity =
false;
438 assert( should_not_call_base_matrix_capacity );
478 template<
typename DataType, Backend backend,
typename Coords >
481 const bool should_not_call_base_vector_nnz =
false;
484 assert( should_not_call_base_vector_nnz );
520 typename InputType,
Backend backend,
521 typename RIT,
typename CIT,
typename NIT
527 const bool should_not_call_base_matrix_nnz =
false;
530 assert( should_not_call_base_matrix_nnz );
573 template<
typename DataType, Backend backend,
typename Coords >
576 const bool should_not_call_base_vector_clear =
false;
579 assert( should_not_call_base_vector_clear );
619 typename InputType,
Backend backend,
620 typename RIT,
typename CIT,
typename NIT
626 const bool should_not_call_base_matrix_clear =
false;
629 assert( should_not_call_base_matrix_clear );
701 Backend backend,
typename Coords
708 const bool should_not_call_base_vector_resize =
false;
712 assert( should_not_call_base_vector_resize );
783 typename InputType,
Backend backend,
784 typename RIT,
typename CIT,
typename NIT
791 const bool should_not_call_base_matrix_resize =
false;
795 assert( should_not_call_base_matrix_resize );
855 typename DataType,
typename T,
856 typename Coords,
Backend backend
861 const typename std::enable_if<
864 void >::type *
const =
nullptr 867 const bool should_not_call_base_vector_set =
false;
868 assert( should_not_call_base_vector_set );
939 typename DataType,
typename MaskType,
typename T,
940 Backend backend,
typename Coords
947 const typename std::enable_if<
949 void >::type *
const =
nullptr 952 const bool should_not_call_base_masked_vector_set =
false;
953 assert( should_not_call_base_masked_vector_set );
996 typename OutputType,
typename InputType,
997 Backend backend,
typename Coords
1005 const bool should_not_call_base_vector_set_copy =
false;
1006 assert( should_not_call_base_vector_set_copy );
1057 typename OutputType,
typename MaskType,
typename InputType,
1058 Backend backend,
typename Coords
1068 void >::type *
const =
nullptr 1071 const bool should_not_call_base_vector_set_copy_masked =
false;
1072 assert( should_not_call_base_vector_set_copy_masked );
1126 typename DataType,
typename T,
1127 Backend backend,
typename Coords
1138 const bool should_not_call_base_setElement =
false;
1139 assert( should_not_call_base_setElement );
1156 typename InputType,
typename fwd_iterator,
1157 Backend backend,
typename Coords
1161 fwd_iterator start,
const fwd_iterator end,
1165 return buildVector< descr >( x, accum, start, end, mode );
1177 class Merger = operators::right_assign< InputType >,
1178 typename fwd_iterator1,
typename fwd_iterator2,
1179 Backend backend,
typename Coords
1182 fwd_iterator1 ind_start,
const fwd_iterator1 ind_end,
1183 fwd_iterator2 val_start,
const fwd_iterator2 val_end,
1184 const IOMode mode,
const Merger & merger = Merger()
1187 return buildVector< descr >( x, accum, ind_start, ind_end, val_start, val_end,
1225 class Merger = operators::right_assign< InputType >,
1226 typename fwd_iterator1,
typename fwd_iterator2,
1227 Backend backend,
typename Coords
1231 fwd_iterator1 ind_start,
const fwd_iterator1 ind_end,
1232 fwd_iterator2 val_start,
const fwd_iterator2 val_end,
1235 return buildVector< descr | descriptors::no_duplicates >(
1334 typename InputType,
typename RIT,
typename CIT,
typename NIT,
1335 typename fwd_iterator1 =
const RIT * __restrict__,
1336 typename fwd_iterator2 =
const CIT * __restrict__,
1337 typename fwd_iterator3 =
const InputType * __restrict__,
1338 Backend implementation = config::default_backend
1342 fwd_iterator1 I,
const fwd_iterator1 I_end,
1343 fwd_iterator2 J,
const fwd_iterator2 J_end,
1344 fwd_iterator3 V,
const fwd_iterator3 V_end,
1348 auto start = internal::makeSynchronized(
1352 const auto end = internal::makeSynchronized(
1353 I_end, J_end, V_end,
1357 return buildMatrixUnique< descr >( A, start, end, mode );
1366 typename InputType,
typename RIT,
typename CIT,
typename NIT,
1367 typename fwd_iterator1 =
const RIT * __restrict__,
1368 typename fwd_iterator2 =
const CIT * __restrict__,
1369 typename fwd_iterator3 =
const InputType * __restrict__,
1370 Backend implementation = config::default_backend
1374 fwd_iterator1 I, fwd_iterator2 J, fwd_iterator3 V,
1375 const size_t nz,
const IOMode mode
1377 return buildMatrixUnique< descr >(
1392 typename InputType,
typename RIT,
typename CIT,
typename NIT,
1393 typename fwd_iterator1 =
const RIT * __restrict__,
1394 typename fwd_iterator2 =
const CIT * __restrict__,
1395 typename length_type = size_t,
1396 Backend implementation = config::default_backend
1400 fwd_iterator1 I, fwd_iterator2 J,
1401 const length_type nz,
const IOMode mode
1404 auto start = internal::makeSynchronized( I, J, I + nz, J + nz );
1405 const auto end = internal::makeSynchronized( I + nz, J + nz, I + nz, J + nz );
1407 return buildMatrixUnique< descr >( A, start, end, mode );
1416 typename InputType,
typename RIT,
typename CIT,
typename NIT,
1417 typename fwd_iterator1 =
const RIT * __restrict__,
1418 typename fwd_iterator2 =
const CIT * __restrict__,
1419 Backend implementation = config::default_backend
1423 fwd_iterator1 I,
const fwd_iterator1 I_end,
1424 fwd_iterator2 J,
const fwd_iterator2 J_end,
1428 auto start = internal::makeSynchronized( I, J, I_end, J_end );
1429 const auto end = internal::makeSynchronized( I_end, J_end, I_end, J_end );
1431 return buildMatrixUnique< descr >( A, start, end, mode );
1477 typename InputType,
typename RIT,
typename CIT,
typename NIT,
1478 typename fwd_iterator,
1479 Backend implementation = config::default_backend
1483 fwd_iterator start,
const fwd_iterator end,
1491 std::cerr <<
"Should not call base grb::buildMatrixUnique" << std::endl;
1492 const bool should_not_call_base_buildMatrixUnique =
false;
1493 assert( should_not_call_base_buildMatrixUnique );
1544 template< Backend backend = config::default_backend >
1547 const bool should_not_call_base_wait =
false;
1548 assert( should_not_call_base_wait );
1579 Backend backend,
typename InputType,
typename Coords,
1584 const Args &... args
1587 const bool should_not_call_base_vector_wait =
false;
1588 assert( should_not_call_base_vector_wait );
1591 return wait( args... );
1621 typename InputType,
typename RIT,
typename CIT,
typename NIT,
1626 const Args &... args
1629 const bool should_not_call_base_matrix_wait =
false;
1630 assert( should_not_call_base_matrix_wait );
1633 return wait( args... );
1640 #endif // end _H_GRB_IO_BASE Defines the ALP error codes.
RC set(Vector< DataType, backend, Coords > &x, const T val, const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< DataType >::value &&!grb::is_object< T >::value, void >::type *const =nullptr) noexcept
Sets all elements of a vector to the given value.
Definition: io.hpp:858
RC buildVector(Vector< InputType, backend, Coords > &x, fwd_iterator start, const fwd_iterator end, const IOMode mode)
Constructs a dense vector from a container of exactly grb::size(x) elements.
Definition: io.hpp:1159
Defines a series of useful type traits for both STL and ALP iterators.
An ALP/GraphBLAS matrix.
Definition: matrix.hpp:72
Defines the various I/O modes a user could employ with ALP data ingestion or extraction.
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
A GraphBLAS vector.
Definition: vector.hpp:64
Specifies the ALP/GraphBLAS matrix container.
uintptr_t getID(const Vector< ElementType, implementation, Coords > &x)
Function that returns a unique ID for a given non-empty container.
Definition: io.hpp:157
RC wait()
Depending on the backend, ALP/GraphBLAS primitives may be non-blocking, meaning that the operation im...
Definition: io.hpp:1545
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
size_t nnz(const Vector< DataType, backend, Coords > &x) noexcept
Request the number of nonzeroes in a given vector.
Definition: io.hpp:479
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
size_t nrows(const Matrix< InputType, backend, RIT, CIT, NIT > &A) noexcept
Requests the row size of a given matrix.
Definition: io.hpp:286
RC buildMatrixUnique(Matrix< InputType, implementation, RIT, CIT, NIT > &A, fwd_iterator1 I, const fwd_iterator1 I_end, fwd_iterator2 J, const fwd_iterator2 J_end, fwd_iterator3 V, const fwd_iterator3 V_end, const IOMode mode)
Assigns nonzeroes to the matrix from a coordinate format.
Definition: io.hpp:1340
size_t ncols(const Matrix< InputType, backend, RIT, CIT, NIT > &A) noexcept
Requests the column size of a given matrix.
Definition: io.hpp:339
Indicates that the execution of the requested primitive with the given arguments is not supported by ...
Definition: rc.hpp:129
This operator discards all left-hand side input and simply copies the right-hand side input to the ou...
Definition: ops.hpp:115
Backend
A collection of all backends.
Definition: backends.hpp:49
RC buildVectorUnique(Vector< InputType, backend, Coords > &x, fwd_iterator1 ind_start, const fwd_iterator1 ind_end, fwd_iterator2 val_start, const fwd_iterator2 val_end, const IOMode mode)
Ingests a set of nonzeroes into a given vector x.
Definition: io.hpp:1229
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:477
IOMode
The GraphBLAS input and output functionalities can either be used in a sequential or parallel fashion...
Definition: iomode.hpp:67
Specifies the ALP/GraphBLAS vector container.
Generic fatal error code.
Definition: rc.hpp:68
size_t size(const Vector< DataType, backend, Coords > &x) noexcept
Request the size of a given vector.
Definition: io.hpp:235
size_t capacity(const Vector< InputType, backend, Coords > &x) noexcept
Queries the capacity of the given ALP/GraphBLAS container.
Definition: io.hpp:388
RC setElement(Vector< DataType, backend, Coords > &x, const T val, const size_t i, const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< DataType >::value &&!grb::is_object< T >::value, void >::type *const =nullptr)
Sets the element of a given vector at a given position to a given value.
Definition: io.hpp:1129
RC clear(Vector< DataType, backend, Coords > &x) noexcept
Clears a given vector of all nonzeroes.
Definition: io.hpp:574
RC resize(Vector< InputType, backend, Coords > &x, const size_t new_nz) noexcept
Resizes the nonzero capacity of this vector.
Definition: io.hpp:703