diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml index 9f16f8cc9e6..f48b39ae785 100644 --- a/.github/workflows/windows-mingw.yml +++ b/.github/workflows/windows-mingw.yml @@ -23,6 +23,7 @@ concurrency: jobs: windows_mingw: + if: ${{ false }} strategy: fail-fast: false matrix: diff --git a/benchmark/blas/blas_common.hpp b/benchmark/blas/blas_common.hpp index 150b6c73c61..537feae0a26 100644 --- a/benchmark/blas/blas_common.hpp +++ b/benchmark/blas/blas_common.hpp @@ -343,13 +343,13 @@ class PrefixSumOperation : public BenchmarkOperation { gko::size_type get_memory() const override { - return 2 * sizeof(IndexType) * array_.get_num_elems(); + return 2 * sizeof(IndexType) * array_.get_size(); } void run() override { - array_.get_executor()->run(make_prefix_sum_nonnegative( - array_.get_data(), array_.get_num_elems())); + array_.get_executor()->run( + make_prefix_sum_nonnegative(array_.get_data(), array_.get_size())); } private: diff --git a/benchmark/sparse_blas/operations.cpp b/benchmark/sparse_blas/operations.cpp index f7f3dd23238..eab21a584dd 100644 --- a/benchmark/sparse_blas/operations.cpp +++ b/benchmark/sparse_blas/operations.cpp @@ -36,10 +36,10 @@ DEFINE_int32( "Maximum distance for row swaps to avoid rows with disjoint column ranges"); DEFINE_string(spgemm_mode, "normal", - R"(Which matrix B should be used to compute A * B: normal, + R"(Which matrix B should be used to compute A * B: normal, transposed, sparse, dense normal: B = A for A square, A^T otherwise\ntransposed: B = A^T -sparse: B is a sparse matrix with dimensions of A^T with uniformly +sparse: B is a sparse matrix with dimensions of A^T with uniformly random values, at most -spgemm_rowlength non-zeros per row dense: B is a 'dense' sparse matrix with -spgemm_rowlength columns and non-zeros per row)"); @@ -123,7 +123,7 @@ class SpgemmOperation : public BenchmarkOperation { get_engine())); } } - data.ensure_row_major_order(); + data.sort_row_major(); mtx2_ = Mtx::create(exec, size2); mtx2_->read(data); } else if (mode_str == "dense") { @@ -131,7 +131,7 @@ class SpgemmOperation : public BenchmarkOperation { std::uniform_real_distribution> dist( -1.0, 1.0); gko::matrix_data data{size2, dist, get_engine()}; - data.ensure_row_major_order(); + data.sort_row_major(); mtx2_ = Mtx::create(exec, size2); mtx2_->read(data); } else { @@ -433,7 +433,7 @@ class GenerateLookupOperation : public BenchmarkOperation { // read sparsity pattern and row pointers once, write lookup structures return mtx_->get_num_stored_elements() * sizeof(itype) + mtx_->get_size()[0] * (2 * sizeof(itype) + sizeof(gko::int64)) + - storage_.get_num_elems() * sizeof(gko::int32); + storage_.get_size() * sizeof(gko::int32); } void run() override @@ -518,7 +518,7 @@ class LookupOperation : public BenchmarkOperation { // column index and write a result return mtx_->get_size()[0] * (2 * sizeof(itype) + sizeof(gko::int64) + sample_size_ * 2 * sizeof(itype)) + - storage_.get_num_elems() * sizeof(gko::int32); + storage_.get_size() * sizeof(gko::int32); } void run() override diff --git a/benchmark/tools/matrix.cpp b/benchmark/tools/matrix.cpp index cf803752757..1501c7d53ff 100644 --- a/benchmark/tools/matrix.cpp +++ b/benchmark/tools/matrix.cpp @@ -52,7 +52,7 @@ int main(int argc, char** argv) bool binary = std::string{argv[1]} == "-b"; auto data = gko::read_generic_raw(std::cin); - data.ensure_row_major_order(); + data.sort_row_major(); for (int argi = binary ? 2 : 1; argi < argc; argi++) { std::string arg{argv[argi]}; if (arg == "lower-triangular") { diff --git a/benchmark/utils/generator.hpp b/benchmark/utils/generator.hpp index 4e55213d86c..57142c92bc6 100644 --- a/benchmark/utils/generator.hpp +++ b/benchmark/utils/generator.hpp @@ -39,7 +39,7 @@ struct DefaultSystemGenerator { throw std::runtime_error( "No known way to generate matrix data found."); } - data.ensure_row_major_order(); + data.sort_row_major(); return data; } @@ -181,7 +181,7 @@ struct DistributedDefaultSystemGenerator { throw std::runtime_error( "No known way to generate matrix data found."); } - data.ensure_row_major_order(); + data.sort_row_major(); return data; } diff --git a/common/cuda_hip/base/device_matrix_data_kernels.hpp.inc b/common/cuda_hip/base/device_matrix_data_kernels.hpp.inc index f8feabee314..9f051db3968 100644 --- a/common/cuda_hip/base/device_matrix_data_kernels.hpp.inc +++ b/common/cuda_hip/base/device_matrix_data_kernels.hpp.inc @@ -9,7 +9,7 @@ void remove_zeros(std::shared_ptr exec, { using device_value_type = device_type; auto value_ptr = as_device_type(values.get_const_data()); - auto size = values.get_num_elems(); + auto size = values.get_size(); // count nonzeros auto nnz = thrust::count_if( thrust_policy(exec), value_ptr, value_ptr + size, @@ -47,7 +47,7 @@ void sum_duplicates(std::shared_ptr exec, size_type, array& values, array& row_idxs, array& col_idxs) { - const auto size = values.get_num_elems(); + const auto size = values.get_size(); const auto rows = row_idxs.get_const_data(); const auto cols = col_idxs.get_const_data(); auto iota = thrust::make_counting_iterator(size_type{}); @@ -92,8 +92,8 @@ void sort_row_major(std::shared_ptr exec, auto it = thrust::make_zip_iterator( thrust::make_tuple(data.get_row_idxs(), data.get_col_idxs())); auto vals = as_device_type(data.get_values()); - thrust::sort_by_key(thrust_policy(exec), it, it + data.get_num_elems(), - vals); + thrust::sort_by_key(thrust_policy(exec), it, + it + data.get_num_stored_elements(), vals); } GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE( diff --git a/common/cuda_hip/base/kernel_launch_reduction.hpp.inc b/common/cuda_hip/base/kernel_launch_reduction.hpp.inc index 03027643244..4740a227af3 100644 --- a/common/cuda_hip/base/kernel_launch_reduction.hpp.inc +++ b/common/cuda_hip/base/kernel_launch_reduction.hpp.inc @@ -102,7 +102,7 @@ void run_kernel_reduction_cached(std::shared_ptr exec, ceildiv(size, block_size), exec->get_num_warps() * oversubscription); if (num_blocks > 1) { const auto required_storage = sizeof(ValueType) * num_blocks; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } generic_kernel_reduction_1d<< exec, exec->get_num_warps() * oversubscription); if (num_blocks > 1) { const auto required_storage = sizeof(ValueType) * num_blocks; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } generic_kernel_reduction_2d<< @@ -413,7 +413,7 @@ void run_kernel_row_reduction_cached( if (rows * cols > resources && rows < cols) { const auto col_blocks = ceildiv(rows * cols, resources); const auto required_storage = sizeof(ValueType) * col_blocks * rows; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } const auto num_blocks = @@ -484,7 +484,7 @@ void run_kernel_col_reduction_cached( as_device_type(result), map_to_device(args)...); } else { const auto required_storage = sizeof(ValueType) * row_blocks * cols; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } // no need to guard this kernel, as cols > warp_size, row_blocks > 1 diff --git a/common/cuda_hip/distributed/matrix_kernels.hpp.inc b/common/cuda_hip/distributed/matrix_kernels.hpp.inc index ad74e6690b9..523c7801b19 100644 --- a/common/cuda_hip/distributed/matrix_kernels.hpp.inc +++ b/common/cuda_hip/distributed/matrix_kernels.hpp.inc @@ -52,7 +52,7 @@ void build_local_nonlocal( col_partition->get_range_starting_indices(); const auto num_row_ranges = row_partition->get_num_ranges(); const auto num_col_ranges = col_partition->get_num_ranges(); - const auto num_input_elements = input.get_num_elems(); + const auto num_input_elements = input.get_num_stored_elements(); // precompute the row and column range id of each input element auto input_row_idxs = input.get_const_row_idxs(); @@ -62,7 +62,7 @@ void build_local_nonlocal( row_range_bounds + num_row_ranges + 1, input_row_idxs, input_row_idxs + num_input_elements, row_range_ids.get_data()); - array col_range_ids{exec, input.get_num_elems()}; + array col_range_ids{exec, input.get_num_stored_elements()}; thrust::upper_bound(thrust_policy(exec), col_range_bounds + 1, col_range_bounds + num_col_ranges + 1, input_col_idxs, input_col_idxs + num_input_elements, @@ -128,8 +128,8 @@ void build_local_nonlocal( return thrust::make_tuple(local_row, local_col, input.val); }); thrust::copy_if( - thrust_policy(exec), local_it, local_it + input.get_num_elems(), - range_ids_it, + thrust_policy(exec), local_it, + local_it + input.get_num_stored_elements(), range_ids_it, thrust::make_zip_iterator(thrust::make_tuple(local_row_idxs.get_data(), local_col_idxs.get_data(), local_values.get_data())), @@ -157,8 +157,8 @@ void build_local_nonlocal( input.col_range); }); thrust::copy_if( - thrust_policy(exec), non_local_it, non_local_it + input.get_num_elems(), - range_ids_it, + thrust_policy(exec), non_local_it, + non_local_it + input.get_num_stored_elements(), range_ids_it, thrust::make_zip_iterator(thrust::make_tuple( non_local_row_idxs.get_data(), non_local_global_col_idxs.get_data(), non_local_values.get_data(), non_local_col_part_ids.get_data(), diff --git a/common/cuda_hip/distributed/partition_helpers_kernels.hpp.inc b/common/cuda_hip/distributed/partition_helpers_kernels.hpp.inc index 0434d8797f0..be71bad2057 100644 --- a/common/cuda_hip/distributed/partition_helpers_kernels.hpp.inc +++ b/common/cuda_hip/distributed/partition_helpers_kernels.hpp.inc @@ -8,7 +8,7 @@ void sort_by_range_start( array& range_start_ends, array& part_ids) { - auto num_ranges = range_start_ends.get_num_elems() / 2; + auto num_ranges = range_start_ends.get_size() / 2; auto strided_indices = thrust::make_transform_iterator( thrust::make_counting_iterator(0), [] __host__ __device__(const int i) { return 2 * i; }); diff --git a/common/cuda_hip/distributed/vector_kernels.hpp.inc b/common/cuda_hip/distributed/vector_kernels.hpp.inc index 29ffff5dc62..3f53e01aff8 100644 --- a/common/cuda_hip/distributed/vector_kernels.hpp.inc +++ b/common/cuda_hip/distributed/vector_kernels.hpp.inc @@ -16,12 +16,12 @@ void build_local( const auto* part_ids = partition->get_part_ids(); const auto num_ranges = partition->get_num_ranges(); - array range_id{exec, input.get_num_elems()}; - thrust::upper_bound(thrust_policy(exec), range_bounds + 1, - range_bounds + num_ranges + 1, - input.get_const_row_idxs(), - input.get_const_row_idxs() + input.get_num_elems(), - range_id.get_data(), thrust::less()); + array range_id{exec, input.get_num_stored_elements()}; + thrust::upper_bound( + thrust_policy(exec), range_bounds + 1, range_bounds + num_ranges + 1, + input.get_const_row_idxs(), + input.get_const_row_idxs() + input.get_num_stored_elements(), + range_id.get_data(), thrust::less()); // write values with local rows into the local matrix at the correct index // this needs the following iterators: @@ -57,10 +57,10 @@ void build_local( [part_ids, local_part] __host__ __device__(const size_type rid) { return part_ids[rid] == local_part; }; - thrust::scatter_if(thrust_policy(exec), input.get_const_values(), - input.get_const_values() + input.get_num_elems(), - flat_idx_it, range_id.get_data(), - local_mtx->get_values(), is_local_row); + thrust::scatter_if( + thrust_policy(exec), input.get_const_values(), + input.get_const_values() + input.get_num_stored_elements(), flat_idx_it, + range_id.get_data(), local_mtx->get_values(), is_local_row); } GKO_INSTANTIATE_FOR_EACH_VALUE_AND_LOCAL_GLOBAL_INDEX_TYPE( diff --git a/common/cuda_hip/factorization/cholesky_kernels.hpp.inc b/common/cuda_hip/factorization/cholesky_kernels.hpp.inc index ec40646ace5..9d0110ea523 100644 --- a/common/cuda_hip/factorization/cholesky_kernels.hpp.inc +++ b/common/cuda_hip/factorization/cholesky_kernels.hpp.inc @@ -219,7 +219,7 @@ void build_children_from_parents( std::shared_ptr exec, gko::factorization::elimination_forest& forest) { - const auto num_rows = forest.parents.get_num_elems(); + const auto num_rows = forest.parents.get_size(); // build COO representation of the tree array col_idx_array{exec, num_rows}; const auto col_idxs = col_idx_array.get_data(); diff --git a/common/cuda_hip/matrix/csr_kernels.hpp.inc b/common/cuda_hip/matrix/csr_kernels.hpp.inc index a8369058d6c..0d846741537 100644 --- a/common/cuda_hip/matrix/csr_kernels.hpp.inc +++ b/common/cuda_hip/matrix/csr_kernels.hpp.inc @@ -979,7 +979,7 @@ void convert_to_fbcsr(std::shared_ptr exec, source->get_size()[0], in_row_idxs.get_data()); auto block_row_ptrs = block_row_ptr_array.get_data(); - auto num_block_rows = block_row_ptr_array.get_num_elems() - 1; + auto num_block_rows = block_row_ptr_array.get_size() - 1; if (nnz == 0) { components::fill_array(exec, block_row_ptrs, num_block_rows + 1, IndexType{}); @@ -1032,7 +1032,7 @@ void convert_to_fbcsr(std::shared_ptr exec, }); // build row pointers from row indices components::convert_idxs_to_ptrs(exec, block_row_idx_array.get_const_data(), - block_row_idx_array.get_num_elems(), + block_row_idx_array.get_size(), num_block_rows, block_row_ptrs); // fill in values components::fill_array(exec, block_value_array.get_data(), diff --git a/common/cuda_hip/matrix/fbcsr_kernels.hpp.inc b/common/cuda_hip/matrix/fbcsr_kernels.hpp.inc index 9f2e203aac4..c3303a24549 100644 --- a/common/cuda_hip/matrix/fbcsr_kernels.hpp.inc +++ b/common/cuda_hip/matrix/fbcsr_kernels.hpp.inc @@ -131,10 +131,10 @@ void fill_in_matrix_data(std::shared_ptr exec, array& block_value_array) { using tuple_type = thrust::tuple; - const auto nnz = data.get_num_elems(); + const auto nnz = data.get_num_stored_elements(); const auto bs = block_size; auto block_row_ptrs = block_row_ptr_array.get_data(); - auto num_block_rows = block_row_ptr_array.get_num_elems() - 1; + auto num_block_rows = block_row_ptr_array.get_size() - 1; if (nnz == 0) { components::fill_array(exec, block_row_ptrs, num_block_rows + 1, IndexType{}); @@ -187,7 +187,7 @@ void fill_in_matrix_data(std::shared_ptr exec, }); // build row pointers from row indices components::convert_idxs_to_ptrs(exec, block_row_idx_array.get_const_data(), - block_row_idx_array.get_num_elems(), + block_row_idx_array.get_size(), num_block_rows, block_row_ptrs); // fill in values components::fill_array(exec, block_value_array.get_data(), diff --git a/common/cuda_hip/preconditioner/jacobi_kernels.hpp.inc b/common/cuda_hip/preconditioner/jacobi_kernels.hpp.inc index 344d086744a..0120f54e20c 100644 --- a/common/cuda_hip/preconditioner/jacobi_kernels.hpp.inc +++ b/common/cuda_hip/preconditioner/jacobi_kernels.hpp.inc @@ -240,13 +240,13 @@ void initialize_precisions(std::shared_ptr exec, array& precisions) { const auto block_size = default_num_warps * config::warp_size; - const auto grid_size = min( - default_grid_size, - static_cast(ceildiv(precisions.get_num_elems(), block_size))); + const auto grid_size = + min(default_grid_size, + static_cast(ceildiv(precisions.get_size(), block_size))); if (grid_size > 0) { duplicate_array<<get_stream()>>>( - source.get_const_data(), source.get_num_elems(), - precisions.get_data(), precisions.get_num_elems()); + source.get_const_data(), source.get_size(), precisions.get_data(), + precisions.get_size()); } } diff --git a/common/cuda_hip/solver/multigrid_kernels.hpp.inc b/common/cuda_hip/solver/multigrid_kernels.hpp.inc index 346b0a9426d..d86e738d835 100644 --- a/common/cuda_hip/solver/multigrid_kernels.hpp.inc +++ b/common/cuda_hip/solver/multigrid_kernels.hpp.inc @@ -155,7 +155,7 @@ void kcycle_check_stop(std::shared_ptr exec, const ValueType rel_tol, bool& is_stop) { gko::array dis_stop(exec, 1); - components::fill_array(exec, dis_stop.get_data(), dis_stop.get_num_elems(), + components::fill_array(exec, dis_stop.get_data(), dis_stop.get_size(), true); const auto nrhs = new_norm->get_size()[1]; const auto grid = ceildiv(nrhs, default_block_size); diff --git a/common/unified/base/device_matrix_data_kernels.cpp b/common/unified/base/device_matrix_data_kernels.cpp index 75f7693fdd4..31b1aa00233 100644 --- a/common/unified/base/device_matrix_data_kernels.cpp +++ b/common/unified/base/device_matrix_data_kernels.cpp @@ -28,8 +28,8 @@ void soa_to_aos(std::shared_ptr exec, [] GKO_KERNEL(auto i, auto rows, auto cols, auto vals, auto out) { out[i] = {rows[i], cols[i], vals[i]}; }, - in.get_num_elems(), in.get_const_row_idxs(), in.get_const_col_idxs(), - in.get_const_values(), out); + in.get_num_stored_elements(), in.get_const_row_idxs(), + in.get_const_col_idxs(), in.get_const_values(), out); } GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE( @@ -48,7 +48,7 @@ void aos_to_soa(std::shared_ptr exec, cols[i] = in[i].column; vals[i] = unpack_member(in[i].value); }, - in.get_num_elems(), in, out.get_row_idxs(), out.get_col_idxs(), + in.get_size(), in, out.get_row_idxs(), out.get_col_idxs(), out.get_values()); } diff --git a/common/unified/base/index_set_kernels.cpp b/common/unified/base/index_set_kernels.cpp index 120540371b3..cab9b3dd4e2 100644 --- a/common/unified/base/index_set_kernels.cpp +++ b/common/unified/base/index_set_kernels.cpp @@ -33,7 +33,7 @@ void compute_validity(std::shared_ptr exec, validity_array[elem] = local_indices[elem] != invalid_index(); }, - local_indices->get_num_elems(), *local_indices, *validity_array); + local_indices->get_size(), *local_indices, *validity_array); } GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE( diff --git a/common/unified/components/reduce_array_kernels.cpp b/common/unified/components/reduce_array_kernels.cpp index 745e790c77d..3cb26bfd025 100644 --- a/common/unified/components/reduce_array_kernels.cpp +++ b/common/unified/components/reduce_array_kernels.cpp @@ -32,8 +32,8 @@ void reduce_add_array(std::shared_ptr exec, [] GKO_KERNEL(auto i, auto arr, auto result) { return i == 0 ? (arr[i] + result[0]) : arr[i]; }, - GKO_KERNEL_REDUCE_SUM(ValueType), result.get_data(), - arr.get_num_elems(), arr, result); + GKO_KERNEL_REDUCE_SUM(ValueType), result.get_data(), arr.get_size(), + arr, result); } GKO_INSTANTIATE_FOR_EACH_TEMPLATE_TYPE(GKO_DECLARE_REDUCE_ADD_ARRAY_KERNEL); diff --git a/common/unified/distributed/partition_helpers_kernels.cpp b/common/unified/distributed/partition_helpers_kernels.cpp index bc491e01c9c..3446bcc70fe 100644 --- a/common/unified/distributed/partition_helpers_kernels.cpp +++ b/common/unified/distributed/partition_helpers_kernels.cpp @@ -21,7 +21,7 @@ void check_consecutive_ranges(std::shared_ptr exec, bool& result) { array result_uint32{exec, 1}; - auto num_ranges = range_start_ends.get_num_elems() / 2; + auto num_ranges = range_start_ends.get_size() / 2; // need additional guard because DPCPP doesn't return the initial value for // empty inputs if (num_ranges > 1) { @@ -60,7 +60,7 @@ void compress_ranges(std::shared_ptr exec, } offsets[i + 1] = start_ends[2 * i + 1]; }, - range_offsets.get_num_elems() - 1, range_start_ends.get_const_data(), + range_offsets.get_size() - 1, range_start_ends.get_const_data(), range_offsets.get_data()); } diff --git a/common/unified/distributed/partition_kernels.cpp b/common/unified/distributed/partition_kernels.cpp index d2b1822d0f9..3ed4173890e 100644 --- a/common/unified/distributed/partition_kernels.cpp +++ b/common/unified/distributed/partition_kernels.cpp @@ -29,8 +29,8 @@ void count_ranges(std::shared_ptr exec, auto prev_part = i == 0 ? comm_index_type{-1} : mapping[i - 1]; return cur_part != prev_part ? 1 : 0; }, - GKO_KERNEL_REDUCE_SUM(size_type), result.get_data(), - mapping.get_num_elems(), mapping); + GKO_KERNEL_REDUCE_SUM(size_type), result.get_data(), mapping.get_size(), + mapping); num_ranges = exec->copy_val_to_host(result.get_const_data()); } @@ -52,8 +52,8 @@ void build_from_contiguous(std::shared_ptr exec, bounds[i + 1] = ranges[i + 1]; ids[i] = uses_mapping ? mapping[i] : i; }, - ranges.get_num_elems() - 1, ranges, part_id_mapping, range_bounds, - part_ids, part_id_mapping.get_num_elems() > 0); + ranges.get_size() - 1, ranges, part_id_mapping, range_bounds, part_ids, + part_id_mapping.get_size() > 0); } GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(GKO_PARTITION_BUILD_FROM_CONTIGUOUS); @@ -65,7 +65,7 @@ void build_from_mapping(std::shared_ptr exec, GlobalIndexType* range_bounds, comm_index_type* part_ids) { - array range_starting_index{exec, mapping.get_num_elems() + 1}; + array range_starting_index{exec, mapping.get_size() + 1}; run_kernel( exec, [] GKO_KERNEL(auto i, auto mapping, auto range_starting_index) { @@ -74,9 +74,9 @@ void build_from_mapping(std::shared_ptr exec, const auto cur_part = mapping[i]; range_starting_index[i] = cur_part != prev_part ? 1 : 0; }, - mapping.get_num_elems(), mapping, range_starting_index); + mapping.get_size(), mapping, range_starting_index); components::prefix_sum_nonnegative(exec, range_starting_index.get_data(), - mapping.get_num_elems() + 1); + mapping.get_size() + 1); run_kernel( exec, [] GKO_KERNEL(auto i, auto size, auto mapping, @@ -94,7 +94,7 @@ void build_from_mapping(std::shared_ptr exec, } } }, - mapping.get_num_elems() + 1, mapping.get_num_elems(), mapping, + mapping.get_size() + 1, mapping.get_size(), mapping, range_starting_index, range_bounds, part_ids); } @@ -114,9 +114,9 @@ void build_ranges_from_global_size(std::shared_ptr exec, [] GKO_KERNEL(auto i, auto size_per_part, auto rest, auto ranges) { ranges[i] = size_per_part + (i < rest ? 1 : 0); }, - ranges.get_num_elems() - 1, size_per_part, rest, ranges.get_data()); + ranges.get_size() - 1, size_per_part, rest, ranges.get_data()); components::prefix_sum_nonnegative(exec, ranges.get_data(), - ranges.get_num_elems()); + ranges.get_size()); } GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(GKO_PARTITION_BUILD_FROM_GLOBAL_SIZE); diff --git a/common/unified/matrix/dense_kernels.template.cpp b/common/unified/matrix/dense_kernels.template.cpp index 3d527a9e695..10f5657b2be 100644 --- a/common/unified/matrix/dense_kernels.template.cpp +++ b/common/unified/matrix/dense_kernels.template.cpp @@ -63,7 +63,7 @@ void fill_in_matrix_data(std::shared_ptr exec, [] GKO_KERNEL(auto i, auto row, auto col, auto val, auto output) { output(row[i], col[i]) = val[i]; }, - data.get_num_elems(), data.get_const_row_idxs(), + data.get_num_stored_elements(), data.get_const_row_idxs(), data.get_const_col_idxs(), data.get_const_values(), output); } diff --git a/common/unified/matrix/diagonal_kernels.cpp b/common/unified/matrix/diagonal_kernels.cpp index 365e1627145..3190c9ec69b 100644 --- a/common/unified/matrix/diagonal_kernels.cpp +++ b/common/unified/matrix/diagonal_kernels.cpp @@ -92,7 +92,7 @@ void fill_in_matrix_data(std::shared_ptr exec, output[row[i]] = val[i]; } }, - data.get_num_elems(), data.get_const_row_idxs(), + data.get_num_stored_elements(), data.get_const_row_idxs(), data.get_const_col_idxs(), data.get_const_values(), output->get_values()); } diff --git a/common/unified/matrix/ell_kernels.cpp b/common/unified/matrix/ell_kernels.cpp index 3a517de1b91..3e37f7e1030 100644 --- a/common/unified/matrix/ell_kernels.cpp +++ b/common/unified/matrix/ell_kernels.cpp @@ -35,7 +35,7 @@ void compute_max_row_nnz(std::shared_ptr exec, return row_ptrs[i + 1] - row_ptrs[i]; }, GKO_KERNEL_REDUCE_MAX(size_type), result.get_data(), - row_ptrs.get_num_elems() - 1, row_ptrs); + row_ptrs.get_size() - 1, row_ptrs); max_nnz = exec->copy_val_to_host(result.get_const_data()); } diff --git a/common/unified/matrix/hybrid_kernels.cpp b/common/unified/matrix/hybrid_kernels.cpp index 303ebad6e3a..a5be2aa0543 100644 --- a/common/unified/matrix/hybrid_kernels.cpp +++ b/common/unified/matrix/hybrid_kernels.cpp @@ -30,9 +30,9 @@ void compute_coo_row_ptrs(std::shared_ptr exec, coo_row_ptrs[i] = max(int64{}, static_cast(row_nnz[i]) - static_cast(ell_lim)); }, - row_nnz.get_num_elems(), row_nnz, ell_lim, coo_row_ptrs); + row_nnz.get_size(), row_nnz, ell_lim, coo_row_ptrs); components::prefix_sum_nonnegative(exec, coo_row_ptrs, - row_nnz.get_num_elems() + 1); + row_nnz.get_size() + 1); } @@ -44,7 +44,7 @@ void compute_row_nnz(std::shared_ptr exec, [] GKO_KERNEL(auto i, auto row_ptrs, auto row_nnzs) { row_nnzs[i] = row_ptrs[i + 1] - row_ptrs[i]; }, - row_ptrs.get_num_elems() - 1, row_ptrs, row_nnzs); + row_ptrs.get_size() - 1, row_ptrs, row_nnzs); } diff --git a/common/unified/matrix/sellp_kernels.cpp b/common/unified/matrix/sellp_kernels.cpp index e0af346e459..13921f11804 100644 --- a/common/unified/matrix/sellp_kernels.cpp +++ b/common/unified/matrix/sellp_kernels.cpp @@ -30,7 +30,7 @@ void compute_slice_sets(std::shared_ptr exec, size_type stride_factor, size_type* slice_sets, size_type* slice_lengths) { - const auto num_rows = row_ptrs.get_num_elems() - 1; + const auto num_rows = row_ptrs.get_size() - 1; const auto num_slices = static_cast(ceildiv(num_rows, slice_size)); run_kernel_row_reduction( diff --git a/common/unified/multigrid/pgm_kernels.cpp b/common/unified/multigrid/pgm_kernels.cpp index 1214504421e..eae82d17b9d 100644 --- a/common/unified/multigrid/pgm_kernels.cpp +++ b/common/unified/multigrid/pgm_kernels.cpp @@ -43,8 +43,7 @@ void match_edge(std::shared_ptr exec, agg_vals[neighbor] = tidx; } }, - agg.get_num_elems(), strongest_neighbor.get_const_data(), - agg.get_data()); + agg.get_size(), strongest_neighbor.get_const_data(), agg.get_data()); } GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(GKO_DECLARE_PGM_MATCH_EDGE_KERNEL); @@ -57,8 +56,8 @@ void count_unagg(std::shared_ptr exec, array d_result(exec, 1); run_kernel_reduction( exec, [] GKO_KERNEL(auto i, auto array) { return array[i] == -1; }, - GKO_KERNEL_REDUCE_SUM(IndexType), d_result.get_data(), - agg.get_num_elems(), agg); + GKO_KERNEL_REDUCE_SUM(IndexType), d_result.get_data(), agg.get_size(), + agg); *num_unagg = exec->copy_val_to_host(d_result.get_const_data()); } @@ -70,7 +69,7 @@ template void renumber(std::shared_ptr exec, array& agg, IndexType* num_agg) { - const auto num = agg.get_num_elems(); + const auto num = agg.get_size(); array agg_map(exec, num + 1); run_kernel( exec, @@ -84,7 +83,7 @@ void renumber(std::shared_ptr exec, num, agg.get_const_data(), agg_map.get_data()); components::prefix_sum_nonnegative(exec, agg_map.get_data(), - agg_map.get_num_elems()); + agg_map.get_size()); run_kernel( exec, @@ -214,7 +213,7 @@ void find_strongest_neighbor( strongest_neighbor[row] = row; } }, - agg.get_num_elems(), weight_mtx->get_const_row_ptrs(), + agg.get_size(), weight_mtx->get_const_row_ptrs(), weight_mtx->get_const_col_idxs(), weight_mtx->get_const_values(), diag->get_const_values(), agg.get_data(), strongest_neighbor.get_data()); @@ -230,8 +229,8 @@ void assign_to_exist_agg(std::shared_ptr exec, array& agg, array& intermediate_agg) { - const auto num = agg.get_num_elems(); - if (intermediate_agg.get_num_elems() > 0) { + const auto num = agg.get_size(); + if (intermediate_agg.get_size() > 0) { // deterministic kernel run_kernel( exec, diff --git a/common/unified/preconditioner/jacobi_kernels.cpp b/common/unified/preconditioner/jacobi_kernels.cpp index 67a93d57c41..9962c2b7000 100644 --- a/common/unified/preconditioner/jacobi_kernels.cpp +++ b/common/unified/preconditioner/jacobi_kernels.cpp @@ -31,7 +31,7 @@ void scalar_conj(std::shared_ptr exec, [] GKO_KERNEL(auto elem, auto diag, auto conj_diag) { conj_diag[elem] = conj(diag[elem]); }, - diag.get_num_elems(), diag, conj_diag); + diag.get_size(), diag, conj_diag); } GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_JACOBI_SCALAR_CONJ_KERNEL); @@ -46,7 +46,7 @@ void invert_diagonal(std::shared_ptr exec, [] GKO_KERNEL(auto elem, auto diag, auto inv_diag) { inv_diag[elem] = safe_divide(one(diag[elem]), diag[elem]); }, - diag.get_num_elems(), diag, inv_diag); + diag.get_size(), diag, inv_diag); } GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_JACOBI_INVERT_DIAGONAL_KERNEL); diff --git a/common/unified/solver/ir_kernels.cpp b/common/unified/solver/ir_kernels.cpp index a2b05397e8f..aa6f244e12c 100644 --- a/common/unified/solver/ir_kernels.cpp +++ b/common/unified/solver/ir_kernels.cpp @@ -24,7 +24,7 @@ void initialize(std::shared_ptr exec, { run_kernel( exec, [] GKO_KERNEL(auto i, auto stop) { stop[i].reset(); }, - stop_status->get_num_elems(), *stop_status); + stop_status->get_size(), *stop_status); } diff --git a/core/base/array.cpp b/core/base/array.cpp index 1c3f8f91ae1..8afe5bbd0ee 100644 --- a/core/base/array.cpp +++ b/core/base/array.cpp @@ -62,14 +62,14 @@ template void array::fill(const ValueType value) { this->get_executor()->run(array_kernels::make_fill_array( - this->get_data(), this->get_num_elems(), value)); + this->get_data(), this->get_size(), value)); } template void reduce_add(const array& input_arr, array& result) { - GKO_ASSERT(result.get_num_elems() == 1); + GKO_ASSERT(result.get_size() == 1); auto exec = input_arr.get_executor(); exec->run(array_kernels::make_reduce_add_array(input_arr, result)); } diff --git a/core/base/batch_multi_vector.cpp b/core/base/batch_multi_vector.cpp index 1b1c2dc8583..8a5a1e55354 100644 --- a/core/base/batch_multi_vector.cpp +++ b/core/base/batch_multi_vector.cpp @@ -128,7 +128,7 @@ MultiVector::create_const( template void MultiVector::fill(ValueType value) { - GKO_ASSERT(this->values_.get_num_elems() > 0); + GKO_ASSERT(this->values_.get_size() > 0); this->values_.fill(value); } diff --git a/core/base/batch_utilities.hpp b/core/base/batch_utilities.hpp index a907dcca28d..2095b2696c7 100644 --- a/core/base/batch_utilities.hpp +++ b/core/base/batch_utilities.hpp @@ -128,13 +128,13 @@ void assert_same_sparsity_in_batched_data( } auto num_nnz = data.at(0).nonzeros.size(); auto base_data = data.at(0); - base_data.ensure_row_major_order(); + base_data.sort_row_major(); for (int b = 1; b < data.size(); ++b) { if (data[b].nonzeros.size() != num_nnz) { GKO_NOT_IMPLEMENTED; } auto temp_data = data.at(b); - temp_data.ensure_row_major_order(); + temp_data.sort_row_major(); for (int nnz = 0; nnz < num_nnz; ++nnz) { if (temp_data.nonzeros.at(nnz).row != base_data.nonzeros.at(nnz).row || diff --git a/core/base/device_matrix_data.cpp b/core/base/device_matrix_data.cpp index 7e663e389e0..c8dedd56d3c 100644 --- a/core/base/device_matrix_data.cpp +++ b/core/base/device_matrix_data.cpp @@ -54,7 +54,7 @@ matrix_data device_matrix_data::copy_to_host() const { const auto exec = values_.get_executor(); - const auto nnz = this->get_num_elems(); + const auto nnz = this->get_num_stored_elements(); matrix_data result{this->get_size()}; result.nonzeros.resize(nnz); auto host_view = diff --git a/core/base/index_set.cpp b/core/base/index_set.cpp index e75e608ae23..239534b1051 100644 --- a/core/base/index_set.cpp +++ b/core/base/index_set.cpp @@ -36,7 +36,7 @@ void index_set::populate_subsets( const gko::array& indices, const bool is_sorted) { auto exec = this->get_executor(); - this->num_stored_indices_ = indices.get_num_elems(); + this->num_stored_indices_ = indices.get_size(); exec->run(idx_set::make_populate_subsets( this->index_space_size_, &indices, &this->subsets_begin_, &this->subsets_end_, &this->superset_cumulative_indices_, is_sorted)); @@ -83,7 +83,7 @@ array index_set::to_global_indices() const auto exec = this->get_executor(); auto num_elems = exec->copy_val_to_host( this->superset_cumulative_indices_.get_const_data() + - this->superset_cumulative_indices_.get_num_elems() - 1); + this->superset_cumulative_indices_.get_size() - 1); auto decomp_indices = gko::array(exec, num_elems); exec->run(idx_set::make_to_global_indices( this->get_num_subsets(), this->get_subsets_begin(), @@ -99,14 +99,13 @@ array index_set::map_local_to_global( const array& local_indices, const bool is_sorted) const { auto exec = this->get_executor(); - auto global_indices = - gko::array(exec, local_indices.get_num_elems()); + auto global_indices = gko::array(exec, local_indices.get_size()); GKO_ASSERT(this->get_num_subsets() >= 1); exec->run(idx_set::make_local_to_global( this->get_num_subsets(), this->get_subsets_begin(), this->get_superset_indices(), - static_cast(local_indices.get_num_elems()), + static_cast(local_indices.get_size()), local_indices.get_const_data(), global_indices.get_data(), is_sorted)); return global_indices; } @@ -117,15 +116,14 @@ array index_set::map_global_to_local( const array& global_indices, const bool is_sorted) const { auto exec = this->get_executor(); - auto local_indices = - gko::array(exec, global_indices.get_num_elems()); + auto local_indices = gko::array(exec, global_indices.get_size()); GKO_ASSERT(this->get_num_subsets() >= 1); exec->run(idx_set::make_global_to_local( this->index_space_size_, this->get_num_subsets(), this->get_subsets_begin(), this->get_subsets_end(), this->get_superset_indices(), - static_cast(local_indices.get_num_elems()), + static_cast(local_indices.get_size()), global_indices.get_const_data(), local_indices.get_data(), is_sorted)); return local_indices; } diff --git a/core/base/mtx_io.cpp b/core/base/mtx_io.cpp index 61767da4ca4..7130d55aed7 100644 --- a/core/base/mtx_io.cpp +++ b/core/base/mtx_io.cpp @@ -70,7 +70,7 @@ class mtx_io { std::istringstream dimensions_stream(parsed_header.dimensions_line); auto data = parsed_header.layout->read_data( dimensions_stream, is, parsed_header.entry, parsed_header.modifier); - data.ensure_row_major_order(); + data.sort_row_major(); return data; } @@ -840,7 +840,7 @@ matrix_data read_binary_convert(std::istream& is, result.nonzeros[i].column = column; } // sort the entries - result.ensure_row_major_order(); + result.sort_row_major(); return result; } diff --git a/core/components/disjoint_sets.hpp b/core/components/disjoint_sets.hpp index 6e52e2f6991..58fa6a1acff 100644 --- a/core/components/disjoint_sets.hpp +++ b/core/components/disjoint_sets.hpp @@ -138,7 +138,7 @@ class disjoint_sets { * * @return the number of elements represented in this data structure. */ - IndexType get_size() const { return parents_.get_num_elems(); } + IndexType get_size() const { return parents_.get_size(); } private: const IndexType& parent(IndexType x) const diff --git a/core/distributed/matrix.cpp b/core/distributed/matrix.cpp index c6f823e4a4a..57ec74a6549 100644 --- a/core/distributed/matrix.cpp +++ b/core/distributed/matrix.cpp @@ -157,7 +157,7 @@ void Matrix::read_distributed( static_cast(row_partition->get_part_size(local_part)); const auto num_local_cols = static_cast(col_partition->get_part_size(local_part)); - const auto num_non_local_cols = non_local_to_global_.get_num_elems(); + const auto num_non_local_cols = non_local_to_global_.get_size(); device_matrix_data local_data{ exec, dim<2>{num_local_rows, num_local_cols}, std::move(local_row_idxs), std::move(local_col_idxs), std::move(local_values)}; diff --git a/core/distributed/partition.cpp b/core/distributed/partition.cpp index 7249ad72cef..1820634d44b 100644 --- a/core/distributed/partition.cpp +++ b/core/distributed/partition.cpp @@ -51,16 +51,16 @@ Partition::build_from_contiguous( std::shared_ptr exec, const array& ranges, const array& part_ids) { - GKO_ASSERT(part_ids.get_num_elems() == 0 || - part_ids.get_num_elems() + 1 == ranges.get_num_elems()); + GKO_ASSERT(part_ids.get_size() == 0 || + part_ids.get_size() + 1 == ranges.get_size()); array empty(exec); auto local_ranges = make_temporary_clone(exec, &ranges); auto local_part_ids = make_temporary_clone( - exec, part_ids.get_num_elems() > 0 ? &part_ids : &empty); + exec, part_ids.get_size() > 0 ? &part_ids : &empty); auto result = Partition::create( - exec, static_cast(ranges.get_num_elems() - 1), - ranges.get_num_elems() - 1); + exec, static_cast(ranges.get_size() - 1), + ranges.get_size() - 1); exec->run(partition::make_build_from_contiguous( *local_ranges, *local_part_ids, result->offsets_.get_data(), result->part_ids_.get_data())); diff --git a/core/distributed/partition_helpers.cpp b/core/distributed/partition_helpers.cpp index a0fceb8ee04..b8bc1a2405e 100644 --- a/core/distributed/partition_helpers.cpp +++ b/core/distributed/partition_helpers.cpp @@ -65,7 +65,7 @@ build_partition_from_local_range(std::shared_ptr exec, // make_sort_by_range_start array part_ids(exec, comm.size()); exec->run(components::make_fill_seq_array(part_ids.get_data(), - part_ids.get_num_elems())); + part_ids.get_size())); exec->run(partition_helpers::make_sort_by_range_start(ranges_start_end, part_ids)); diff --git a/core/log/batch_logger.cpp b/core/log/batch_logger.cpp index 1be2659b21a..54f9c89219f 100644 --- a/core/log/batch_logger.cpp +++ b/core/log/batch_logger.cpp @@ -20,13 +20,13 @@ void BatchConvergence::on_batch_solver_completed( const array& iteration_count, const array>& residual_norm) const { - if (this->iteration_count_.get_num_elems() == 0) { - this->iteration_count_ = gko::array( - iteration_count.get_executor(), iteration_count.get_num_elems()); + if (this->iteration_count_.get_size() == 0) { + this->iteration_count_ = gko::array(iteration_count.get_executor(), + iteration_count.get_size()); } - if (this->residual_norm_.get_num_elems() == 0) { + if (this->residual_norm_.get_size() == 0) { this->residual_norm_ = gko::array>( - residual_norm.get_executor(), residual_norm.get_num_elems()); + residual_norm.get_executor(), residual_norm.get_size()); } this->iteration_count_ = iteration_count; this->residual_norm_ = residual_norm; diff --git a/core/log/convergence.cpp b/core/log/convergence.cpp index 81f43feeff8..a59b2904ad5 100644 --- a/core/log/convergence.cpp +++ b/core/log/convergence.cpp @@ -61,7 +61,7 @@ void Convergence::on_iteration_complete( array tmp(status->get_executor()->get_master(), *status); this->convergence_status_ = true; - for (int i = 0; i < status->get_num_elems(); i++) { + for (int i = 0; i < status->get_size(); i++) { if (!tmp.get_data()[i].has_converged()) { this->convergence_status_ = false; break; diff --git a/core/matrix/csr.cpp b/core/matrix/csr.cpp index 8745413e8c1..2a56f43f813 100644 --- a/core/matrix/csr.cpp +++ b/core/matrix/csr.cpp @@ -448,7 +448,7 @@ void Csr::read(device_mat_data&& data) const auto row_idxs = std::move(arrays.row_idxs); auto local_row_idxs = make_temporary_clone(exec, &row_idxs); exec->run(csr::make_convert_idxs_to_ptrs(local_row_idxs->get_const_data(), - local_row_idxs->get_num_elems(), + local_row_idxs->get_size(), size[0], this->get_row_ptrs())); this->make_srow(); } @@ -805,7 +805,7 @@ Csr::create_submatrix( { using Mat = Csr; auto exec = this->get_executor(); - if (!row_index_set.get_num_elems() || !col_index_set.get_num_elems()) { + if (!row_index_set.get_size() || !col_index_set.get_size()) { return Mat::create(exec); } if (row_index_set.is_contiguous() && col_index_set.is_contiguous()) { diff --git a/core/matrix/dense.cpp b/core/matrix/dense.cpp index 267f4b3a491..d87a64459b2 100644 --- a/core/matrix/dense.cpp +++ b/core/matrix/dense.cpp @@ -546,7 +546,7 @@ Dense& Dense::operator=(const Dense& other) // matrix on the array to avoid special-casing cross-executor copies auto exec_this_view = Dense{exec, this->get_size(), - make_array_view(exec, exec_values_array->get_num_elems(), + make_array_view(exec, exec_values_array->get_size(), exec_values_array->get_data()), this->get_stride()}; exec->run(dense::make_copy(&other, &exec_this_view)); @@ -1261,7 +1261,7 @@ void Dense::row_gather_impl(const array* row_idxs, Dense* row_collection) const { auto exec = this->get_executor(); - dim<2> expected_dim{row_idxs->get_num_elems(), this->get_size()[1]}; + dim<2> expected_dim{row_idxs->get_size(), this->get_size()[1]}; GKO_ASSERT_EQUAL_DIMENSIONS(expected_dim, row_collection); exec->run(dense::make_row_gather( @@ -1277,7 +1277,7 @@ void Dense::row_gather_impl(const Dense* alpha, Dense* row_collection) const { auto exec = this->get_executor(); - dim<2> expected_dim{row_idxs->get_num_elems(), this->get_size()[1]}; + dim<2> expected_dim{row_idxs->get_size(), this->get_size()[1]}; GKO_ASSERT_EQUAL_DIMENSIONS(expected_dim, row_collection); exec->run(dense::make_advanced_row_gather( @@ -1498,7 +1498,7 @@ std::unique_ptr> Dense::row_gather( const array* row_idxs) const { auto exec = this->get_executor(); - dim<2> out_dim{row_idxs->get_num_elems(), this->get_size()[1]}; + dim<2> out_dim{row_idxs->get_size(), this->get_size()[1]}; auto result = Dense::create(exec, out_dim); this->row_gather(row_idxs, result); return result; @@ -1509,7 +1509,7 @@ std::unique_ptr> Dense::row_gather( const array* row_idxs) const { auto exec = this->get_executor(); - dim<2> out_dim{row_idxs->get_num_elems(), this->get_size()[1]}; + dim<2> out_dim{row_idxs->get_size(), this->get_size()[1]}; auto result = Dense::create(exec, out_dim); this->row_gather(row_idxs, result); return result; diff --git a/core/matrix/ell.cpp b/core/matrix/ell.cpp index c8d94fb2f65..f0291f499a0 100644 --- a/core/matrix/ell.cpp +++ b/core/matrix/ell.cpp @@ -86,9 +86,9 @@ Ell& Ell::operator=( auto exec_this_view = Ell{exec, this->get_size(), - make_array_view(exec, exec_values_array->get_num_elems(), + make_array_view(exec, exec_values_array->get_size(), exec_values_array->get_data()), - make_array_view(exec, exec_cols_array->get_num_elems(), + make_array_view(exec, exec_cols_array->get_size(), exec_cols_array->get_data()), this->get_num_stored_elements_per_row(), this->get_stride()}; @@ -244,7 +244,7 @@ void Ell::read(const device_mat_data& data) array row_ptrs(exec, data.get_size()[0] + 1); auto local_data = make_temporary_clone(exec, &data); exec->run(ell::make_convert_idxs_to_ptrs( - local_data->get_const_row_idxs(), local_data->get_num_elems(), + local_data->get_const_row_idxs(), local_data->get_num_stored_elements(), data.get_size()[0], row_ptrs.get_data())); size_type max_nnz{}; exec->run(ell::make_compute_max_row_nnz(row_ptrs, max_nnz)); diff --git a/core/matrix/hybrid.cpp b/core/matrix/hybrid.cpp index c8c8f4927a1..78bd3087735 100644 --- a/core/matrix/hybrid.cpp +++ b/core/matrix/hybrid.cpp @@ -233,8 +233,8 @@ void Hybrid::read(const device_mat_data& data) auto local_data = make_temporary_clone(exec, &data); array row_ptrs{exec, num_rows + 1}; exec->run(hybrid::make_convert_idxs_to_ptrs( - local_data->get_const_row_idxs(), local_data->get_num_elems(), num_rows, - row_ptrs.get_data())); + local_data->get_const_row_idxs(), local_data->get_num_stored_elements(), + num_rows, row_ptrs.get_data())); array row_nnz{exec, data.get_size()[0]}; exec->run(hybrid::make_compute_row_nnz(row_ptrs, row_nnz.get_data())); size_type ell_max_nnz{}; diff --git a/core/matrix/permutation.cpp b/core/matrix/permutation.cpp index 04bafaaa92a..b7ddec25bf6 100644 --- a/core/matrix/permutation.cpp +++ b/core/matrix/permutation.cpp @@ -106,7 +106,7 @@ Permutation::create_const( mask_type enabled_permute) { GKO_ASSERT_EQ(enabled_permute, row_permute); - GKO_ASSERT_EQ(size, perm_idxs.get_num_elems()); + GKO_ASSERT_EQ(size, perm_idxs.get_size()); return create_const(std::move(exec), std::move(perm_idxs)); } @@ -135,8 +135,7 @@ Permutation::Permutation(std::shared_ptr exec, template Permutation::Permutation(std::shared_ptr exec, array permutation_indices) - : EnableLinOp(exec, - dim<2>{permutation_indices.get_num_elems()}), + : EnableLinOp(exec, dim<2>{permutation_indices.get_size()}), permutation_{exec, std::move(permutation_indices)} {} diff --git a/core/matrix/scaled_permutation.cpp b/core/matrix/scaled_permutation.cpp index f1dc11dec37..3819ffe10bb 100644 --- a/core/matrix/scaled_permutation.cpp +++ b/core/matrix/scaled_permutation.cpp @@ -39,13 +39,12 @@ template ScaledPermutation::ScaledPermutation( std::shared_ptr exec, array scaling_factors, array permutation_indices) - : EnableLinOp(exec, - dim<2>{scaling_factors.get_num_elems(), - scaling_factors.get_num_elems()}), + : EnableLinOp( + exec, dim<2>{scaling_factors.get_size(), scaling_factors.get_size()}), scale_{exec, std::move(scaling_factors)}, permutation_{exec, std::move(permutation_indices)} { - GKO_ASSERT_EQ(scale_.get_num_elems(), permutation_.get_num_elems()); + GKO_ASSERT_EQ(scale_.get_size(), permutation_.get_size()); } diff --git a/core/matrix/sellp.cpp b/core/matrix/sellp.cpp index 43ad6c6417f..43bf6cd3b88 100644 --- a/core/matrix/sellp.cpp +++ b/core/matrix/sellp.cpp @@ -209,14 +209,14 @@ void Sellp::read(const device_mat_data& data) this->set_size(size); array row_ptrs{exec, size[0] + 1}; auto local_data = make_temporary_clone(exec, &data); - exec->run(sellp::make_convert_idxs_to_ptrs(local_data->get_const_row_idxs(), - local_data->get_num_elems(), - size[0], row_ptrs.get_data())); + exec->run(sellp::make_convert_idxs_to_ptrs( + local_data->get_const_row_idxs(), local_data->get_num_stored_elements(), + size[0], row_ptrs.get_data())); exec->run(sellp::make_compute_slice_sets( row_ptrs, this->get_slice_size(), this->get_stride_factor(), slice_sets_.get_data(), slice_lengths_.get_data())); - const auto total_cols = exec->copy_val_to_host( - slice_sets_.get_data() + slice_sets_.get_num_elems() - 1); + const auto total_cols = exec->copy_val_to_host(slice_sets_.get_data() + + slice_sets_.get_size() - 1); values_.resize_and_reset(total_cols * slice_size_); col_idxs_.resize_and_reset(total_cols * slice_size_); exec->run(sellp::make_fill_in_matrix_data(*local_data, diff --git a/core/matrix/sparsity_csr.cpp b/core/matrix/sparsity_csr.cpp index 3592c09ae34..ff7015a3f2e 100644 --- a/core/matrix/sparsity_csr.cpp +++ b/core/matrix/sparsity_csr.cpp @@ -187,8 +187,8 @@ void SparsityCsr::read(device_mat_data&& data) const auto row_idxs = std::move(arrays.row_idxs); auto local_row_idxs = make_temporary_clone(exec, &row_idxs); exec->run(sparsity_csr::make_convert_idxs_to_ptrs( - local_row_idxs->get_const_data(), local_row_idxs->get_num_elems(), - size[0], this->get_row_ptrs())); + local_row_idxs->get_const_data(), local_row_idxs->get_size(), size[0], + this->get_row_ptrs())); } diff --git a/core/multigrid/fixed_coarsening.cpp b/core/multigrid/fixed_coarsening.cpp index e598e183d79..57edc3b61a8 100644 --- a/core/multigrid/fixed_coarsening.cpp +++ b/core/multigrid/fixed_coarsening.cpp @@ -60,8 +60,8 @@ void FixedCoarsening::generate() } GKO_ASSERT(parameters_.coarse_rows.get_data() != nullptr); - GKO_ASSERT(parameters_.coarse_rows.get_num_elems() > 0); - size_type coarse_dim = parameters_.coarse_rows.get_num_elems(); + GKO_ASSERT(parameters_.coarse_rows.get_size() > 0); + size_type coarse_dim = parameters_.coarse_rows.get_size(); auto fine_dim = system_matrix_->get_size()[0]; auto restrict_op = share( diff --git a/core/multigrid/pgm.cpp b/core/multigrid/pgm.cpp index cd08b4ed553..3713431d6fc 100644 --- a/core/multigrid/pgm.cpp +++ b/core/multigrid/pgm.cpp @@ -59,7 +59,7 @@ void agg_to_restrict(std::shared_ptr exec, IndexType num_agg, const gko::array& agg, IndexType* row_ptrs, IndexType* col_idxs) { - const IndexType num = agg.get_num_elems(); + const IndexType num = agg.get_size(); gko::array row_idxs(exec, agg); exec->run(pgm::make_fill_seq_array(col_idxs, num)); // sort the pair (int, agg) to (row_idxs, col_idxs) @@ -139,7 +139,7 @@ void Pgm::generate() this->set_fine_op(pgm_op_shared_ptr); } // Initial agg = -1 - exec->run(pgm::make_fill_array(agg_.get_data(), agg_.get_num_elems(), + exec->run(pgm::make_fill_array(agg_.get_data(), agg_.get_size(), -one())); IndexType num_unagg = num_rows; IndexType num_unagg_prev = num_rows; @@ -189,7 +189,7 @@ void Pgm::generate() // prolong_row_gather is the lightway implementation for prolongation auto prolong_row_gather = share(matrix::RowGatherer::create( exec, gko::dim<2>{fine_dim, coarse_dim})); - exec->copy_from(exec, agg_.get_num_elems(), agg_.get_const_data(), + exec->copy_from(exec, agg_.get_size(), agg_.get_const_data(), prolong_row_gather->get_row_idxs()); auto restrict_sparsity = share(matrix::SparsityCsr::create( diff --git a/core/preconditioner/jacobi.cpp b/core/preconditioner/jacobi.cpp index c1d0b7944f3..df6b9c23634 100644 --- a/core/preconditioner/jacobi.cpp +++ b/core/preconditioner/jacobi.cpp @@ -221,7 +221,7 @@ std::unique_ptr Jacobi::transpose() const res->set_size(this->get_size()); res->storage_scheme_ = storage_scheme_; res->num_blocks_ = num_blocks_; - res->blocks_.resize_and_reset(blocks_.get_num_elems()); + res->blocks_.resize_and_reset(blocks_.get_size()); res->conditioning_ = conditioning_; res->parameters_ = parameters_; if (parameters_.max_block_size == 1) { @@ -247,7 +247,7 @@ std::unique_ptr Jacobi::conj_transpose() const res->set_size(this->get_size()); res->storage_scheme_ = storage_scheme_; res->num_blocks_ = num_blocks_; - res->blocks_.resize_and_reset(blocks_.get_num_elems()); + res->blocks_.resize_and_reset(blocks_.get_size()); res->conditioning_ = conditioning_; res->parameters_ = parameters_; if (parameters_.max_block_size == 1) { @@ -299,7 +299,7 @@ void Jacobi::generate(const LinOp* system_matrix, auto temp = make_array_view(diag_vt->get_executor(), diag_vt->get_size()[0], diag_vt->get_values()); - this->blocks_ = array(exec, temp.get_num_elems()); + this->blocks_ = array(exec, temp.get_size()); exec->run(jacobi::make_invert_diagonal(temp, this->blocks_)); this->num_blocks_ = diag_vt->get_size()[0]; } else { @@ -320,7 +320,7 @@ void Jacobi::generate(const LinOp* system_matrix, gko::array(exec, {all_block_opt}); } array tmp( - exec, parameters_.block_pointers.get_num_elems() - 1); + exec, parameters_.block_pointers.get_size() - 1); exec->run(jacobi::make_initialize_precisions(precisions, tmp)); precisions = std::move(tmp); conditioning_.resize_and_reset(num_blocks_); diff --git a/core/reorder/scaled_reordered.cpp b/core/reorder/scaled_reordered.cpp index 8a260d0ecd2..4b0a7c534ea 100644 --- a/core/reorder/scaled_reordered.cpp +++ b/core/reorder/scaled_reordered.cpp @@ -38,7 +38,7 @@ void ScaledReordered::apply_impl(const LinOp* b, cache_.intermediate); std::swap(cache_.inner_x, cache_.intermediate); } - if (permutation_array_.get_num_elems() > 0) { + if (permutation_array_.get_size() > 0) { cache_.inner_b->row_permute(&permutation_array_, cache_.intermediate); std::swap(cache_.inner_b, cache_.intermediate); @@ -52,7 +52,7 @@ void ScaledReordered::apply_impl(const LinOp* b, inner_operator_->apply(cache_.inner_b, cache_.inner_x); // Permute and scale the solution vector back. - if (permutation_array_.get_num_elems() > 0) { + if (permutation_array_.get_size() > 0) { cache_.inner_x->inverse_row_permute(&permutation_array_, cache_.intermediate); std::swap(cache_.inner_x, cache_.intermediate); diff --git a/core/solver/cb_gmres.cpp b/core/solver/cb_gmres.cpp index 050edeff5fc..66377d237d2 100644 --- a/core/solver/cb_gmres.cpp +++ b/core/solver/cb_gmres.cpp @@ -279,7 +279,7 @@ void CbGmres::apply_dense_impl( array fully_converged_rhs(exec->get_master(), num_rhs); array host_stop_status( this->get_executor()->get_master(), stop_status); - for (size_type i = 0; i < stop_encountered_rhs.get_num_elems(); ++i) { + for (size_type i = 0; i < stop_encountered_rhs.get_size(); ++i) { stop_encountered_rhs.get_data()[i] = false; fully_converged_rhs.get_data()[i] = false; } @@ -318,7 +318,7 @@ void CbGmres::apply_dense_impl( if (one_changed || all_changed) { host_stop_status = stop_status; bool host_array_changed{false}; - for (size_type i = 0; i < host_stop_status.get_num_elems(); + for (size_type i = 0; i < host_stop_status.get_size(); ++i) { auto local_status = host_stop_status.get_data() + i; // Ignore all actually converged ones! @@ -350,8 +350,8 @@ void CbGmres::apply_dense_impl( forced_iterations = 0; } else { - for (size_type i = 0; - i < stop_encountered_rhs.get_num_elems(); ++i) { + for (size_type i = 0; i < stop_encountered_rhs.get_size(); + ++i) { stop_encountered_rhs.get_data()[i] = false; } } diff --git a/core/solver/cb_gmres_accessor.hpp b/core/solver/cb_gmres_accessor.hpp index 1c616e32db5..d77e4198cef 100644 --- a/core/solver/cb_gmres_accessor.hpp +++ b/core/solver/cb_gmres_accessor.hpp @@ -77,7 +77,7 @@ class Range3dHelper { { array h_scale{exec->get_master(), krylov_dim[0] * krylov_dim[2]}; - for (size_type i = 0; i < h_scale.get_num_elems(); ++i) { + for (size_type i = 0; i < h_scale.get_size(); ++i) { h_scale.get_data()[i] = one(); } scale_ = h_scale; diff --git a/core/test/base/array.cpp b/core/test/base/array.cpp index e8dc9fa0a74..56ed407d1e5 100644 --- a/core/test/base/array.cpp +++ b/core/test/base/array.cpp @@ -33,7 +33,7 @@ class Array : public ::testing::Test { static void assert_equal_to_original_x(gko::array& a, bool check_zero = true) { - ASSERT_EQ(a.get_num_elems(), 2); + ASSERT_EQ(a.get_size(), 2); if (check_zero) EXPECT_EQ(a.get_data()[0], T{5}); EXPECT_EQ(a.get_data()[1], T{2}); if (check_zero) EXPECT_EQ(a.get_const_data()[0], T{5}); @@ -52,7 +52,7 @@ TYPED_TEST(Array, CanBeCreatedWithoutAnExecutor) gko::array a; ASSERT_EQ(a.get_executor(), nullptr); - ASSERT_EQ(a.get_num_elems(), 0); + ASSERT_EQ(a.get_size(), 0); } @@ -60,7 +60,7 @@ TYPED_TEST(Array, CanBeEmpty) { gko::array a(this->exec); - ASSERT_EQ(a.get_num_elems(), 0); + ASSERT_EQ(a.get_size(), 0); } @@ -78,7 +78,7 @@ TYPED_TEST(Array, CanBeCreatedFromExistingData) gko::array a{this->exec, 3, new TypeParam[3], std::default_delete{}}; - EXPECT_EQ(a.get_num_elems(), 3); + EXPECT_EQ(a.get_size(), 3); } @@ -87,7 +87,7 @@ TYPED_TEST(Array, CanBeCreatedFromDataOnExecutor) gko::array a{this->exec, 3, this->exec->template alloc(3)}; - EXPECT_EQ(a.get_num_elems(), 3); + EXPECT_EQ(a.get_size(), 3); } @@ -114,7 +114,7 @@ TYPED_TEST(Array, CanBeCreatedFromInitializerList) } -TYPED_TEST(Array, KnowsItsSize) { ASSERT_EQ(this->x.get_num_elems(), 2); } +TYPED_TEST(Array, KnowsItsSize) { ASSERT_EQ(this->x.get_size(), 2); } TYPED_TEST(Array, ReturnsValidDataPtr) @@ -177,7 +177,7 @@ TYPED_TEST(Array, MoveConstructedFromArrayExecutorlessIsEmpty) a = std::move(this->x); ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -186,7 +186,7 @@ TYPED_TEST(Array, MoveConstructedFromArraySameExecutorIsEmpty) gko::array a{this->exec, std::move(this->x)}; ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -196,7 +196,7 @@ TYPED_TEST(Array, MoveConstructedFromArrayDifferentExecutorIsEmpty) std::move(this->x)}; ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -230,7 +230,7 @@ TYPED_TEST(Array, CanBeCopiedFromExecutorlessArray) this->x = a; ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -263,7 +263,7 @@ TYPED_TEST(Array, CanBeMovedFromExecutorlessArray) this->x = std::move(a); ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -274,7 +274,7 @@ TYPED_TEST(Array, MovedFromArrayExecutorlessIsEmpty) a = std::move(this->x); ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -285,7 +285,7 @@ TYPED_TEST(Array, MovedFromArraySameExecutorIsEmpty) a = std::move(this->x); ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -296,7 +296,7 @@ TYPED_TEST(Array, MovedFromArrayDifferentExecutorIsEmpty) a = std::move(this->x); ASSERT_EQ(this->x.get_executor(), this->exec); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); } @@ -353,7 +353,7 @@ TYPED_TEST(Array, CanCreateTemporaryOutputCloneOnDifferentExecutors) tmp_clone->get_data()[1] = 5; // there is no reliable way to check the memory is uninitialized - ASSERT_EQ(tmp_clone->get_num_elems(), this->x.get_num_elems()); + ASSERT_EQ(tmp_clone->get_size(), this->x.get_size()); ASSERT_EQ(tmp_clone->get_executor(), other); ASSERT_EQ(this->x.get_executor(), this->exec); ASSERT_EQ(this->x.get_data()[0], TypeParam{5}); @@ -368,7 +368,7 @@ TYPED_TEST(Array, CanBeCleared) { this->x.clear(); - ASSERT_EQ(this->x.get_num_elems(), 0); + ASSERT_EQ(this->x.get_size(), 0); ASSERT_EQ(this->x.get_data(), nullptr); ASSERT_EQ(this->x.get_const_data(), nullptr); } @@ -394,7 +394,7 @@ TYPED_TEST(Array, ViewCannotBeResized) auto view = gko::make_array_view(this->exec, 3, data); EXPECT_THROW(view.resize_and_reset(1), gko::NotSupported); - EXPECT_EQ(view.get_num_elems(), 3); + EXPECT_EQ(view.get_size(), 3); ASSERT_EQ(view.get_data()[0], TypeParam{1}); } @@ -423,7 +423,7 @@ TYPED_TEST(Array, CustomDeleterCannotBeResized) this->exec, 3, data, my_null_deleter{}); EXPECT_THROW(view_custom_deleter.resize_and_reset(1), gko::NotSupported); - EXPECT_EQ(view_custom_deleter.get_num_elems(), 3); + EXPECT_EQ(view_custom_deleter.get_size(), 3); ASSERT_EQ(view_custom_deleter.get_data()[0], TypeParam{1}); } @@ -459,7 +459,7 @@ TYPED_TEST(Array, ViewModifiesOriginalData) EXPECT_EQ(data[0], TypeParam{5}); EXPECT_EQ(data[1], TypeParam{4}); EXPECT_EQ(data[2], TypeParam{2}); - ASSERT_EQ(view.get_num_elems(), 3); + ASSERT_EQ(view.get_size(), 3); } @@ -474,9 +474,9 @@ TYPED_TEST(Array, CopyArrayToArray) EXPECT_EQ(array.get_data()[1], TypeParam{4}); EXPECT_EQ(array.get_data()[2], TypeParam{2}); EXPECT_EQ(array.get_data()[3], TypeParam{1}); - EXPECT_EQ(array.get_num_elems(), 4); + EXPECT_EQ(array.get_size(), 4); EXPECT_NE(array.get_data(), array2.get_data()); - ASSERT_EQ(array2.get_num_elems(), 4); + ASSERT_EQ(array2.get_size(), 4); } @@ -495,8 +495,8 @@ TYPED_TEST(Array, CopyViewToView) EXPECT_EQ(data[0], TypeParam{5}); EXPECT_EQ(data[1], TypeParam{4}); EXPECT_EQ(data[2], TypeParam{2}); - EXPECT_EQ(view.get_num_elems(), 3); - EXPECT_EQ(view2.get_num_elems(), 3); + EXPECT_EQ(view.get_size(), 3); + EXPECT_EQ(view2.get_size(), 3); EXPECT_EQ(view2.get_data()[0], TypeParam{2}); ASSERT_THROW(view2 = view_size4, gko::OutOfBoundsError); } @@ -515,8 +515,8 @@ TYPED_TEST(Array, CopyViewToArray) EXPECT_EQ(array.get_data()[1], TypeParam{2}); EXPECT_EQ(array.get_data()[2], TypeParam{3}); EXPECT_EQ(array.get_data()[3], TypeParam{4}); - EXPECT_EQ(array.get_num_elems(), 4); - ASSERT_EQ(view.get_num_elems(), 4); + EXPECT_EQ(array.get_size(), 4); + ASSERT_EQ(view.get_size(), 4); } @@ -532,8 +532,8 @@ TYPED_TEST(Array, CopyArrayToView) EXPECT_EQ(data[0], TypeParam{5}); EXPECT_EQ(data[1], TypeParam{4}); EXPECT_EQ(data[2], TypeParam{3}); - EXPECT_EQ(view.get_num_elems(), 3); - EXPECT_EQ(array_size2.get_num_elems(), 2); + EXPECT_EQ(view.get_size(), 3); + EXPECT_EQ(array_size2.get_size(), 2); ASSERT_THROW(view = array_size4, gko::OutOfBoundsError); } @@ -551,9 +551,9 @@ TYPED_TEST(Array, MoveArrayToArray) EXPECT_EQ(array.get_data()[1], TypeParam{4}); EXPECT_EQ(array.get_data()[2], TypeParam{2}); EXPECT_EQ(array.get_data()[3], TypeParam{1}); - EXPECT_EQ(array.get_num_elems(), 4); + EXPECT_EQ(array.get_size(), 4); EXPECT_EQ(array2.get_data(), nullptr); - ASSERT_EQ(array2.get_num_elems(), 0); + ASSERT_EQ(array2.get_size(), 0); } @@ -570,9 +570,9 @@ TYPED_TEST(Array, MoveViewToView) EXPECT_EQ(view.get_data()[0], TypeParam{5}); EXPECT_EQ(view.get_data()[1], TypeParam{4}); EXPECT_EQ(view.get_data()[2], TypeParam{2}); - EXPECT_EQ(view.get_num_elems(), 3); + EXPECT_EQ(view.get_size(), 3); EXPECT_EQ(view2.get_data(), nullptr); - EXPECT_EQ(view2.get_num_elems(), 0); + EXPECT_EQ(view2.get_size(), 0); EXPECT_NE(data, nullptr); EXPECT_EQ(data[0], TypeParam{1}); EXPECT_EQ(data[1], TypeParam{2}); @@ -594,13 +594,13 @@ TYPED_TEST(Array, MoveViewToArray) EXPECT_EQ(array.get_data()[1], TypeParam{2}); EXPECT_EQ(array.get_data()[2], TypeParam{3}); EXPECT_EQ(array.get_data()[3], TypeParam{4}); - EXPECT_EQ(array.get_num_elems(), 4); + EXPECT_EQ(array.get_size(), 4); EXPECT_EQ(data[0], TypeParam{1}); EXPECT_EQ(data[1], TypeParam{2}); EXPECT_EQ(data[2], TypeParam{3}); EXPECT_EQ(data[3], TypeParam{4}); EXPECT_EQ(view.get_data(), nullptr); - ASSERT_EQ(view.get_num_elems(), 0); + ASSERT_EQ(view.get_size(), 0); } @@ -617,27 +617,27 @@ TYPED_TEST(Array, MoveArrayToView) EXPECT_EQ(view.get_data()[0], TypeParam{5}); EXPECT_EQ(view.get_data()[1], TypeParam{4}); - EXPECT_EQ(view.get_num_elems(), 2); + EXPECT_EQ(view.get_size(), 2); EXPECT_NE(view.get_data(), data); EXPECT_EQ(view.get_data(), size2_ptr); EXPECT_NO_THROW(view = std::move(array_size4)); EXPECT_EQ(view.get_data(), size4_ptr); EXPECT_EQ(array_size2.get_data(), nullptr); - ASSERT_EQ(array_size2.get_num_elems(), 0); + ASSERT_EQ(array_size2.get_size(), 0); } TYPED_TEST(Array, AsView) { auto ptr = this->x.get_data(); - auto size = this->x.get_num_elems(); + auto size = this->x.get_size(); auto exec = this->x.get_executor(); auto view = this->x.as_view(); ASSERT_EQ(ptr, this->x.get_data()); ASSERT_EQ(ptr, view.get_data()); - ASSERT_EQ(size, this->x.get_num_elems()); - ASSERT_EQ(size, view.get_num_elems()); + ASSERT_EQ(size, this->x.get_size()); + ASSERT_EQ(size, view.get_size()); ASSERT_EQ(exec, this->x.get_executor()); ASSERT_EQ(exec, view.get_executor()); ASSERT_TRUE(this->x.is_owning()); @@ -648,14 +648,14 @@ TYPED_TEST(Array, AsView) TYPED_TEST(Array, AsConstView) { auto ptr = this->x.get_data(); - auto size = this->x.get_num_elems(); + auto size = this->x.get_size(); auto exec = this->x.get_executor(); auto view = this->x.as_const_view(); ASSERT_EQ(ptr, this->x.get_data()); ASSERT_EQ(ptr, view.get_const_data()); - ASSERT_EQ(size, this->x.get_num_elems()); - ASSERT_EQ(size, view.get_num_elems()); + ASSERT_EQ(size, this->x.get_size()); + ASSERT_EQ(size, view.get_size()); ASSERT_EQ(exec, this->x.get_executor()); ASSERT_EQ(exec, view.get_executor()); ASSERT_TRUE(this->x.is_owning()); @@ -666,7 +666,7 @@ TYPED_TEST(Array, AsConstView) TYPED_TEST(Array, ArrayConstCastWorksOnView) { auto ptr = this->x.get_data(); - auto size = this->x.get_num_elems(); + auto size = this->x.get_size(); auto exec = this->x.get_executor(); auto const_view = this->x.as_const_view(); auto view = gko::detail::array_const_cast(std::move(const_view)); @@ -674,12 +674,12 @@ TYPED_TEST(Array, ArrayConstCastWorksOnView) "wrong return type"); ASSERT_EQ(nullptr, const_view.get_const_data()); - ASSERT_EQ(0, const_view.get_num_elems()); + ASSERT_EQ(0, const_view.get_size()); ASSERT_EQ(exec, const_view.get_executor()); ASSERT_EQ(ptr, this->x.get_data()); ASSERT_EQ(ptr, view.get_const_data()); - ASSERT_EQ(size, this->x.get_num_elems()); - ASSERT_EQ(size, view.get_num_elems()); + ASSERT_EQ(size, this->x.get_size()); + ASSERT_EQ(size, view.get_size()); ASSERT_EQ(exec, this->x.get_executor()); ASSERT_EQ(exec, view.get_executor()); ASSERT_TRUE(this->x.is_owning()); diff --git a/core/test/matrix/batch_identity.cpp b/core/test/matrix/batch_identity.cpp index fa578420f41..9e479804f6d 100644 --- a/core/test/matrix/batch_identity.cpp +++ b/core/test/matrix/batch_identity.cpp @@ -53,7 +53,7 @@ class Identity : public ::testing::Test { std::unique_ptr> mvec; }; -TYPED_TEST_SUITE(Identity, gko::test::ValueTypes); +TYPED_TEST_SUITE(Identity, gko::test::ValueTypes, TypenameNameGenerator); TYPED_TEST(Identity, KnowsItsSizeAndValues) diff --git a/core/test/matrix/fbcsr.cpp b/core/test/matrix/fbcsr.cpp index a5ed4aa9f92..b89ba4a3baf 100644 --- a/core/test/matrix/fbcsr.cpp +++ b/core/test/matrix/fbcsr.cpp @@ -476,11 +476,11 @@ TYPED_TEST(Fbcsr, GeneratesCorrectMatrixData) using index_type = typename TestFixture::index_type; using MtxData = typename TestFixture::MtxData; MtxData refdata = this->fbsample.generate_matrix_data_with_explicit_zeros(); - refdata.ensure_row_major_order(); + refdata.sort_row_major(); MtxData data; this->mtx->write(data); - data.ensure_row_major_order(); + data.sort_row_major(); ASSERT_EQ(data.size, refdata.size); ASSERT_EQ(data.nonzeros.size(), refdata.nonzeros.size()); diff --git a/core/test/matrix/fbcsr_sample.hpp b/core/test/matrix/fbcsr_sample.hpp index dbf7aad8e92..4d7208b64c8 100644 --- a/core/test/matrix/fbcsr_sample.hpp +++ b/core/test/matrix/fbcsr_sample.hpp @@ -218,7 +218,7 @@ class FbcsrSample { mdata.nonzeros.push_back({2, 3, 0.0}); mdata.nonzeros.push_back({2, 5, 0.0}); mdata.nonzeros.push_back({3, 6, 0.0}); - mdata.ensure_row_major_order(); + mdata.sort_row_major(); return mdata; } diff --git a/core/test/solver/batch_bicgstab.cpp b/core/test/solver/batch_bicgstab.cpp index 5dbd207fd41..4480d160f04 100644 --- a/core/test/solver/batch_bicgstab.cpp +++ b/core/test/solver/batch_bicgstab.cpp @@ -54,7 +54,7 @@ class BatchBicgstab : public ::testing::Test { std::unique_ptr solver; }; -TYPED_TEST_SUITE(BatchBicgstab, gko::test::ValueTypes); +TYPED_TEST_SUITE(BatchBicgstab, gko::test::ValueTypes, TypenameNameGenerator); TYPED_TEST(BatchBicgstab, FactoryKnowsItsExecutor) diff --git a/core/test/solver/workspace.cpp b/core/test/solver/workspace.cpp index 790feecce3f..8edec2fc47b 100644 --- a/core/test/solver/workspace.cpp +++ b/core/test/solver/workspace.cpp @@ -107,7 +107,7 @@ TEST_F(Workspace, AnyArrayInitWorks) ASSERT_TRUE(array.template contains()); ASSERT_FALSE(array.template contains()); ASSERT_EQ(&array.template get(), &arr); - ASSERT_EQ(arr.get_num_elems(), 1); + ASSERT_EQ(arr.get_size(), 1); ASSERT_EQ(arr.get_executor(), exec); } @@ -132,8 +132,8 @@ TEST_F(Workspace, CanCreateArrays) auto& arr1 = ws.create_or_get_array(1, 2); auto& arr2 = ws.create_or_get_array(0, 3); - ASSERT_EQ(arr1.get_num_elems(), 2); - ASSERT_EQ(arr2.get_num_elems(), 3); + ASSERT_EQ(arr1.get_size(), 2); + ASSERT_EQ(arr2.get_size(), 3); ASSERT_EQ(arr1.get_executor(), exec); ASSERT_EQ(arr2.get_executor(), exec); } @@ -149,8 +149,8 @@ TEST_F(Workspace, CanReuseArrays) auto& arr1_reuse = ws.create_or_get_array(1, 2); auto& arr2_reuse = ws.create_or_get_array(0, 3); - ASSERT_EQ(arr1.get_num_elems(), 2); - ASSERT_EQ(arr2.get_num_elems(), 3); + ASSERT_EQ(arr1.get_size(), 2); + ASSERT_EQ(arr2.get_size(), 3); ASSERT_EQ(arr1.get_executor(), exec); ASSERT_EQ(arr2.get_executor(), exec); ASSERT_EQ(&arr1, &arr1_reuse); @@ -168,8 +168,8 @@ TEST_F(Workspace, CanResizeArrays) auto& arr1_reuse = ws.create_or_get_array(1, 4); auto& arr2_reuse = ws.create_or_get_array(0, 5); - ASSERT_EQ(arr1.get_num_elems(), 4); - ASSERT_EQ(arr2.get_num_elems(), 5); + ASSERT_EQ(arr1.get_size(), 4); + ASSERT_EQ(arr2.get_size(), 5); ASSERT_EQ(arr1.get_executor(), exec); ASSERT_EQ(arr2.get_executor(), exec); ASSERT_EQ(&arr1, &arr1_reuse); diff --git a/core/test/utils/array_generator_test.cpp b/core/test/utils/array_generator_test.cpp index 4421c467be3..2a90f842620 100644 --- a/core/test/utils/array_generator_test.cpp +++ b/core/test/utils/array_generator_test.cpp @@ -70,7 +70,7 @@ TYPED_TEST_SUITE(ArrayGenerator, gko::test::ValueTypes, TypenameNameGenerator); TYPED_TEST(ArrayGenerator, OutputHasCorrectSize) { - ASSERT_EQ(this->array.get_num_elems(), 500); + ASSERT_EQ(this->array.get_size(), 500); } @@ -82,14 +82,14 @@ TYPED_TEST(ArrayGenerator, OutputHasCorrectAverageAndDeviation) // check the real part this->template check_average_and_deviation( this->array.get_const_data(), - this->array.get_const_data() + this->array.get_num_elems(), 20.0, 5.0, + this->array.get_const_data() + this->array.get_size(), 20.0, 5.0, [](T& val) { return gko::real(val); }); // check the imag part when the type is complex if (!std::is_same>::value) { this->template check_average_and_deviation( this->array.get_const_data(), - this->array.get_const_data() + this->array.get_num_elems(), 20.0, - 5.0, [](T& val) { return gko::imag(val); }); + this->array.get_const_data() + this->array.get_size(), 20.0, 5.0, + [](T& val) { return gko::imag(val); }); } } diff --git a/core/test/utils/assertions.hpp b/core/test/utils/assertions.hpp index 195b467bc6f..e55f61ede20 100644 --- a/core/test/utils/assertions.hpp +++ b/core/test/utils/assertions.hpp @@ -481,8 +481,8 @@ ::testing::AssertionResult array_equal_impl( const std::string& first_expression, const std::string& second_expression, const array& first, const array& second) { - const auto num_elems1 = first.get_num_elems(); - const auto num_elems2 = second.get_num_elems(); + const auto num_elems1 = first.get_size(); + const auto num_elems2 = second.get_size(); if (num_elems1 != num_elems2) { auto fail = ::testing::AssertionFailure(); fail << "Array " << first_expression << " contains " << num_elems1 @@ -705,8 +705,8 @@ ::testing::AssertionResult batch_matrices_near( } for (size_type b = 0; b < first_data.size(); ++b) { - first_data[b].ensure_row_major_order(); - second_data[b].ensure_row_major_order(); + first_data[b].sort_row_major(); + second_data[b].sort_row_major(); } return detail::batch_matrices_near_impl( @@ -770,8 +770,8 @@ ::testing::AssertionResult matrices_near( first->write(first_data); second->write(second_data); - first_data.ensure_row_major_order(); - second_data.ensure_row_major_order(); + first_data.sort_row_major(); + second_data.sort_row_major(); return detail::matrices_near_impl( detail::remove_pointer_wrapper(first_expression), @@ -954,8 +954,8 @@ ::testing::AssertionResult matrices_equal_sparsity( first->write(first_data); second->write(second_data); - first_data.ensure_row_major_order(); - second_data.ensure_row_major_order(); + first_data.sort_row_major(); + second_data.sort_row_major(); // make sure if we write data to disk, it only contains ones. for (auto& entry : first_data.nonzeros) { entry.value = one(); diff --git a/core/test/utils/batch_helpers.hpp b/core/test/utils/batch_helpers.hpp index 716e675dc90..d1da63f0a7c 100644 --- a/core/test/utils/batch_helpers.hpp +++ b/core/test/utils/batch_helpers.hpp @@ -61,11 +61,11 @@ std::unique_ptr generate_random_batch_matrix( num_rows, num_cols, nonzero_dist, value_dist, engine, exec->get_master()); auto row_idxs = gko::array::const_view( - exec->get_master(), sp_mat.get_num_elems(), + exec->get_master(), sp_mat.get_num_stored_elements(), sp_mat.get_const_row_idxs()) .copy_to_array(); auto col_idxs = gko::array::const_view( - exec->get_master(), sp_mat.get_num_elems(), + exec->get_master(), sp_mat.get_num_stored_elements(), sp_mat.get_const_col_idxs()) .copy_to_array(); @@ -158,17 +158,17 @@ std::unique_ptr generate_diag_dominant_batch_matrix( if (is_hermitian) { gko::utils::make_hpd(data); } - data.ensure_row_major_order(); + data.sort_row_major(); auto soa_data = gko::device_matrix_data::create_from_host( exec->get_master(), data); auto row_idxs = gko::array::const_view( - exec->get_master(), soa_data.get_num_elems(), + exec->get_master(), soa_data.get_num_stored_elements(), soa_data.get_const_row_idxs()) .copy_to_array(); auto col_idxs = gko::array::const_view( - exec->get_master(), soa_data.get_num_elems(), + exec->get_master(), soa_data.get_num_stored_elements(), soa_data.get_const_col_idxs()) .copy_to_array(); diff --git a/core/test/utils/fb_matrix_generator.hpp b/core/test/utils/fb_matrix_generator.hpp index 2e5006dea0c..d7cda80fceb 100644 --- a/core/test/utils/fb_matrix_generator.hpp +++ b/core/test/utils/fb_matrix_generator.hpp @@ -83,7 +83,7 @@ std::unique_ptr generate_random_matrix_with_diag( }); } - data.ensure_row_major_order(); + data.sort_row_major(); // convert to the correct matrix type auto result = MatrixType::create(exec, std::forward(args)...); diff --git a/core/test/utils/matrix_generator.hpp b/core/test/utils/matrix_generator.hpp index c7292736d03..83a9b61915c 100644 --- a/core/test/utils/matrix_generator.hpp +++ b/core/test/utils/matrix_generator.hpp @@ -58,14 +58,14 @@ matrix_data fill_random_matrix_data( auto host_row_indices = make_temporary_clone(host_exec, &row_indices); auto host_col_indices = make_temporary_clone(host_exec, &col_indices); - for (int nnz = 0; nnz < row_indices.get_num_elems(); ++nnz) { + for (int nnz = 0; nnz < row_indices.get_size(); ++nnz) { data.nonzeros.emplace_back( host_row_indices->get_const_data()[nnz], host_col_indices->get_const_data()[nnz], detail::get_rand_value(value_dist, engine)); } - data.ensure_row_major_order(); + data.sort_row_major(); return data; } @@ -143,7 +143,7 @@ matrix_data generate_random_matrix_data( } } - data.ensure_row_major_order(); + data.sort_row_major(); return data; } @@ -204,8 +204,8 @@ std::unique_ptr fill_random_matrix( using value_type = typename MatrixType::value_type; using index_type = IndexType; - GKO_ASSERT(row_idxs.get_num_elems() == col_idxs.get_num_elems()); - GKO_ASSERT(row_idxs.get_num_elems() <= (num_rows * num_cols)); + GKO_ASSERT(row_idxs.get_size() == col_idxs.get_size()); + GKO_ASSERT(row_idxs.get_size() <= (num_rows * num_cols)); auto result = MatrixType::create(exec, std::forward(args)...); result->read(fill_random_matrix_data( num_rows, num_cols, row_idxs, col_idxs, @@ -378,7 +378,7 @@ matrix_data generate_random_triangular_matrix_data( } } - data.ensure_row_major_order(); + data.sort_row_major(); return data; } diff --git a/core/utils/matrix_utils.hpp b/core/utils/matrix_utils.hpp index 505ec39cb70..0d385691eda 100644 --- a/core/utils/matrix_utils.hpp +++ b/core/utils/matrix_utils.hpp @@ -85,7 +85,7 @@ void make_unit_diagonal(matrix_data& data) for (gko::int64 i = 0; i < num_diags; i++) { data.nonzeros.emplace_back(i, i, one()); } - data.ensure_row_major_order(); + data.sort_row_major(); } @@ -194,7 +194,7 @@ void make_diag_dominant(matrix_data& data, } } } - data.ensure_row_major_order(); + data.sort_row_major(); } diff --git a/cuda/preconditioner/jacobi_generate_kernel.cu b/cuda/preconditioner/jacobi_generate_kernel.cu index aa3075a2aa4..729a8164395 100644 --- a/cuda/preconditioner/jacobi_generate_kernel.cu +++ b/cuda/preconditioner/jacobi_generate_kernel.cu @@ -51,7 +51,7 @@ void generate(std::shared_ptr exec, array& block_precisions, const array& block_pointers, array& blocks) { - components::fill_array(exec, blocks.get_data(), blocks.get_num_elems(), + components::fill_array(exec, blocks.get_data(), blocks.get_size(), zero()); select_generate( compiled_kernels(), diff --git a/cuda/solver/cb_gmres_kernels.cu b/cuda/solver/cb_gmres_kernels.cu index b5beda4e89b..2ff8db5734f 100644 --- a/cuda/solver/cb_gmres_kernels.cu +++ b/cuda/solver/cb_gmres_kernels.cu @@ -400,10 +400,10 @@ void arnoldi(std::shared_ptr exec, { increase_final_iteration_numbers_kernel<<< static_cast( - ceildiv(final_iter_nums->get_num_elems(), default_block_size)), + ceildiv(final_iter_nums->get_size(), default_block_size)), default_block_size, 0, exec->get_stream()>>>( as_device_type(final_iter_nums->get_data()), - stop_status->get_const_data(), final_iter_nums->get_num_elems()); + stop_status->get_const_data(), final_iter_nums->get_size()); finish_arnoldi_CGS(exec, next_krylov_basis, krylov_bases, hessenberg_iter, buffer_iter, arnoldi_norm, iter, stop_status->get_const_data(), reorth_status->get_data(), diff --git a/cuda/stop/criterion_kernels.cu b/cuda/stop/criterion_kernels.cu index 81cbcb5dd5a..d23a7ddf172 100644 --- a/cuda/stop/criterion_kernels.cu +++ b/cuda/stop/criterion_kernels.cu @@ -45,11 +45,11 @@ void set_all_statuses(std::shared_ptr exec, array* stop_status) { const auto block_size = default_block_size; - const auto grid_size = ceildiv(stop_status->get_num_elems(), block_size); + const auto grid_size = ceildiv(stop_status->get_size(), block_size); if (grid_size > 0) { set_all_statuses<<get_stream()>>>( - stop_status->get_num_elems(), stoppingId, setFinalized, + stop_status->get_size(), stoppingId, setFinalized, as_device_type(stop_status->get_data())); } } diff --git a/cuda/test/base/array.cpp b/cuda/test/base/array.cpp index d09fd8e65bf..c6df0937429 100644 --- a/cuda/test/base/array.cpp +++ b/cuda/test/base/array.cpp @@ -25,7 +25,7 @@ class Array : public CudaTestFixture { static void assert_equal_to_original_x(gko::array& a) { - ASSERT_EQ(a.get_num_elems(), 2); + ASSERT_EQ(a.get_size(), 2); EXPECT_EQ(a.get_data()[0], T{5}); EXPECT_EQ(a.get_data()[1], T{2}); EXPECT_EQ(a.get_const_data()[0], T{5}); diff --git a/cuda/test/base/kernel_launch.cu b/cuda/test/base/kernel_launch.cu index 7e525f91cfa..f43fe606809 100644 --- a/cuda/test/base/kernel_launch.cu +++ b/cuda/test/base/kernel_launch.cu @@ -111,7 +111,7 @@ void run1d(std::shared_ptr exec, size_type dim, int* data) TEST_F(KernelLaunch, Runs1D) { - run1d(exec, zero_array.get_num_elems(), zero_array.get_data()); + run1d(exec, zero_array.get_size(), zero_array.get_data()); GKO_ASSERT_ARRAY_EQ(zero_array, iota_array); } @@ -132,7 +132,7 @@ void run1d(std::shared_ptr exec, gko::array& data) d[i] = 0; } }, - data.get_num_elems(), data, data.get_const_data(), move_only_val); + data.get_size(), data, data.get_const_data(), move_only_val); } TEST_F(KernelLaunch, Runs1DArray) diff --git a/dpcpp/base/device_matrix_data_kernels.dp.cpp b/dpcpp/base/device_matrix_data_kernels.dp.cpp index c762b5d7de6..1021df376d4 100644 --- a/dpcpp/base/device_matrix_data_kernels.dp.cpp +++ b/dpcpp/base/device_matrix_data_kernels.dp.cpp @@ -29,7 +29,7 @@ void remove_zeros(std::shared_ptr exec, array& col_idxs) { using nonzero_type = matrix_data_entry; - auto size = values.get_num_elems(); + auto size = values.get_size(); auto policy = onedpl_policy(exec); auto nnz = std::count_if( policy, values.get_const_data(), values.get_const_data() + size, @@ -65,7 +65,7 @@ void sum_duplicates(std::shared_ptr exec, size_type, array& col_idxs) { using nonzero_type = matrix_data_entry; - auto size = values.get_num_elems(); + auto size = values.get_size(); if (size == 0) { return; } @@ -111,7 +111,7 @@ void sort_row_major(std::shared_ptr exec, auto policy = onedpl_policy(exec); auto input_it = oneapi::dpl::make_zip_iterator( data.get_row_idxs(), data.get_col_idxs(), data.get_values()); - std::sort(policy, input_it, input_it + data.get_num_elems(), + std::sort(policy, input_it, input_it + data.get_num_stored_elements(), [](auto a, auto b) { return std::tie(std::get<0>(a), std::get<1>(a)) < std::tie(std::get<0>(b), std::get<1>(b)); diff --git a/dpcpp/base/kernel_launch_reduction.dp.hpp b/dpcpp/base/kernel_launch_reduction.dp.hpp index d3c3d9cd565..43cdbfdd25e 100644 --- a/dpcpp/base/kernel_launch_reduction.dp.hpp +++ b/dpcpp/base/kernel_launch_reduction.dp.hpp @@ -147,7 +147,7 @@ void run_kernel_reduction_impl(std::shared_ptr exec, auto queue = exec->get_queue(); if (num_workgroups > 1) { const auto required_storage = sizeof(ValueType) * num_workgroups; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } queue->submit([&](sycl::handler& cgh) { @@ -194,7 +194,7 @@ void run_kernel_reduction_impl(std::shared_ptr exec, auto queue = exec->get_queue(); if (num_workgroups > 1) { const auto required_storage = sizeof(ValueType) * num_workgroups; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } queue->submit([&](sycl::handler& cgh) { @@ -498,7 +498,7 @@ void run_generic_col_reduction_small(syn::value_list, }); } else { const auto required_storage = sizeof(ValueType) * row_blocks * cols; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } queue->submit([&](sycl::handler& cgh) { @@ -544,7 +544,7 @@ void run_kernel_row_reduction_stage1(std::shared_ptr exec, if (rows * cols > resources && rows < cols) { const auto col_blocks = ceildiv(rows * cols, resources); const auto required_storage = sizeof(ValueType) * col_blocks * rows; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } generic_kernel_row_reduction_2d( @@ -617,7 +617,7 @@ void run_kernel_col_reduction_stage1(std::shared_ptr exec, }); } else { const auto required_storage = sizeof(ValueType) * row_blocks * cols; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } queue->submit([&](sycl::handler& cgh) { diff --git a/dpcpp/distributed/partition_helpers_kernels.dp.cpp b/dpcpp/distributed/partition_helpers_kernels.dp.cpp index e6313c66e9b..ad43a15656c 100644 --- a/dpcpp/distributed/partition_helpers_kernels.dp.cpp +++ b/dpcpp/distributed/partition_helpers_kernels.dp.cpp @@ -48,7 +48,7 @@ void sort_by_range_start( { auto policy = oneapi::dpl::execution::make_device_policy(*exec->get_queue()); - auto num_ranges = range_start_ends.get_num_elems() / 2; + auto num_ranges = range_start_ends.get_size() / 2; auto start_it = oneapi::dpl::make_permutation_iterator( range_start_ends.get_data(), stride{}); diff --git a/dpcpp/preconditioner/jacobi_generate_kernel.dp.cpp b/dpcpp/preconditioner/jacobi_generate_kernel.dp.cpp index eb763f85009..23e73909357 100644 --- a/dpcpp/preconditioner/jacobi_generate_kernel.dp.cpp +++ b/dpcpp/preconditioner/jacobi_generate_kernel.dp.cpp @@ -51,7 +51,7 @@ void generate(std::shared_ptr exec, array& block_precisions, const array& block_pointers, array& blocks) { - components::fill_array(exec, blocks.get_data(), blocks.get_num_elems(), + components::fill_array(exec, blocks.get_data(), blocks.get_size(), zero()); select_generate( compiled_kernels(), diff --git a/dpcpp/preconditioner/jacobi_kernels.dp.cpp b/dpcpp/preconditioner/jacobi_kernels.dp.cpp index 44352ff2539..a99cedb20e6 100644 --- a/dpcpp/preconditioner/jacobi_kernels.dp.cpp +++ b/dpcpp/preconditioner/jacobi_kernels.dp.cpp @@ -369,13 +369,13 @@ void initialize_precisions(std::shared_ptr exec, array& precisions) { const auto block_size = default_num_warps * config::warp_size; - const auto grid_size = min( - default_grid_size, - static_cast(ceildiv(precisions.get_num_elems(), block_size))); + const auto grid_size = + min(default_grid_size, + static_cast(ceildiv(precisions.get_size(), block_size))); if (grid_size > 0) { duplicate_array(grid_size, block_size, 0, exec->get_queue(), - source.get_const_data(), source.get_num_elems(), - precisions.get_data(), precisions.get_num_elems()); + source.get_const_data(), source.get_size(), + precisions.get_data(), precisions.get_size()); } } diff --git a/dpcpp/solver/cb_gmres_kernels.dp.cpp b/dpcpp/solver/cb_gmres_kernels.dp.cpp index 469db2bd1a6..063499f0dcb 100644 --- a/dpcpp/solver/cb_gmres_kernels.dp.cpp +++ b/dpcpp/solver/cb_gmres_kernels.dp.cpp @@ -1230,9 +1230,9 @@ void arnoldi(std::shared_ptr exec, { increase_final_iteration_numbers_kernel( static_cast( - ceildiv(final_iter_nums->get_num_elems(), default_block_size)), + ceildiv(final_iter_nums->get_size(), default_block_size)), default_block_size, 0, exec->get_queue(), final_iter_nums->get_data(), - stop_status->get_const_data(), final_iter_nums->get_num_elems()); + stop_status->get_const_data(), final_iter_nums->get_size()); finish_arnoldi_CGS(exec, next_krylov_basis, krylov_bases, hessenberg_iter, buffer_iter, arnoldi_norm, iter, stop_status->get_const_data(), reorth_status->get_data(), diff --git a/dpcpp/stop/criterion_kernels.dp.cpp b/dpcpp/stop/criterion_kernels.dp.cpp index 70ee507be77..a5d798f0674 100644 --- a/dpcpp/stop/criterion_kernels.dp.cpp +++ b/dpcpp/stop/criterion_kernels.dp.cpp @@ -26,7 +26,7 @@ void set_all_statuses(std::shared_ptr exec, uint8 stoppingId, bool setFinalized, array* stop_status) { - auto size = stop_status->get_num_elems(); + auto size = stop_status->get_size(); stopping_status* __restrict__ stop_status_ptr = stop_status->get_data(); exec->get_queue()->submit([&](sycl::handler& cgh) { cgh.parallel_for(sycl::range<1>{size}, [=](sycl::id<1> idx_id) { diff --git a/dpcpp/test/base/kernel_launch.dp.cpp b/dpcpp/test/base/kernel_launch.dp.cpp index 4030266633f..d1ae8f5bc46 100644 --- a/dpcpp/test/base/kernel_launch.dp.cpp +++ b/dpcpp/test/base/kernel_launch.dp.cpp @@ -116,7 +116,7 @@ TEST_F(KernelLaunch, Runs1D) static_assert(is_same::value, "dummy"); d[i] = i; }, - zero_array.get_num_elems(), zero_array.get_data(), move_only_val); + zero_array.get_size(), zero_array.get_data(), move_only_val); GKO_ASSERT_ARRAY_EQ(zero_array, iota_array); } @@ -137,7 +137,7 @@ TEST_F(KernelLaunch, Runs1DArray) d[i] = 0; } }, - zero_array.get_num_elems(), zero_array, zero_array.get_const_data(), + zero_array.get_size(), zero_array, zero_array.get_const_data(), move_only_val); GKO_ASSERT_ARRAY_EQ(zero_array, iota_array); diff --git a/dpcpp/test/preconditioner/jacobi_kernels.dp.cpp b/dpcpp/test/preconditioner/jacobi_kernels.dp.cpp index 52de10981a2..c1b0077d14f 100644 --- a/dpcpp/test/preconditioner/jacobi_kernels.dp.cpp +++ b/dpcpp/test/preconditioner/jacobi_kernels.dp.cpp @@ -83,7 +83,7 @@ class Jacobi : public ::testing::Test { } gko::array block_ptrs(ref, block_pointers); gko::array block_prec(ref, block_precisions); - if (block_prec.get_num_elems() == 0) { + if (block_prec.get_size() == 0) { bj_factory = Bj::build() .with_max_block_size(max_block_size) .with_block_pointers(block_ptrs) diff --git a/examples/kokkos_assembly/kokkos_assembly.cpp b/examples/kokkos_assembly/kokkos_assembly.cpp index 75aea97555e..9f1bab73b82 100644 --- a/examples/kokkos_assembly/kokkos_assembly.cpp +++ b/examples/kokkos_assembly/kokkos_assembly.cpp @@ -3,13 +3,15 @@ // SPDX-License-Identifier: BSD-3-Clause #include +#include #include #include #include + + #include -#include // Creates a stencil matrix in CSR format for the given number of discretization @@ -27,14 +29,18 @@ void generate_stencil_matrix(gko::matrix::Csr* matrix) discretization_points * 3); // Create Kokkos views on Ginkgo data. - Kokkos::View v_row_idxs(md.get_row_idxs(), md.get_num_elems()); - Kokkos::View v_col_idxs(md.get_col_idxs(), md.get_num_elems()); - Kokkos::View v_values(md.get_values(), md.get_num_elems()); + Kokkos::View v_row_idxs(md.get_row_idxs(), + md.get_num_stored_elements()); + Kokkos::View v_col_idxs(md.get_col_idxs(), + md.get_num_stored_elements()); + Kokkos::View v_values(md.get_values(), + md.get_num_stored_elements()); // Create the matrix entries. This also creates zero entries for the // first and second row to handle all rows uniformly. Kokkos::parallel_for( - "generate_stencil_matrix", md.get_num_elems(), KOKKOS_LAMBDA(int i) { + "generate_stencil_matrix", md.get_num_stored_elements(), + KOKKOS_LAMBDA(int i) { const ValueType coefs[] = {-1, 2, -1}; auto ofs = static_cast((i % 3) - 1); auto row = static_cast(i / 3); diff --git a/examples/par-ilu-convergence/par-ilu-convergence.cpp b/examples/par-ilu-convergence/par-ilu-convergence.cpp index e604c9dfd54..fb753431db1 100644 --- a/examples/par-ilu-convergence/par-ilu-convergence.cpp +++ b/examples/par-ilu-convergence/par-ilu-convergence.cpp @@ -2,9 +2,6 @@ // // SPDX-License-Identifier: BSD-3-Clause -#include - - #include #include #include @@ -13,6 +10,9 @@ #include +#include + + const std::map()>> executors{ {"reference", [] { return gko::ReferenceExecutor::create(); }}, @@ -53,8 +53,8 @@ double compute_ilu_residual_norm( gko::matrix_data mtx_data; residual->write(residual_data); mtx->write(mtx_data); - residual_data.ensure_row_major_order(); - mtx_data.ensure_row_major_order(); + residual_data.sort_row_major(); + mtx_data.sort_row_major(); auto it = mtx_data.nonzeros.begin(); double residual_norm{}; for (auto entry : residual_data.nonzeros) { diff --git a/hip/preconditioner/jacobi_generate_kernel.hip.cpp b/hip/preconditioner/jacobi_generate_kernel.hip.cpp index 06b3394df8a..8cce75f006f 100644 --- a/hip/preconditioner/jacobi_generate_kernel.hip.cpp +++ b/hip/preconditioner/jacobi_generate_kernel.hip.cpp @@ -67,7 +67,7 @@ void generate(std::shared_ptr exec, array& block_precisions, const array& block_pointers, array& blocks) { - components::fill_array(exec, blocks.get_data(), blocks.get_num_elems(), + components::fill_array(exec, blocks.get_data(), blocks.get_size(), zero()); select_generate( compiled_kernels(), diff --git a/hip/solver/cb_gmres_kernels.hip.cpp b/hip/solver/cb_gmres_kernels.hip.cpp index 3f930e72122..fbc3a599ebf 100644 --- a/hip/solver/cb_gmres_kernels.hip.cpp +++ b/hip/solver/cb_gmres_kernels.hip.cpp @@ -404,10 +404,10 @@ void arnoldi(std::shared_ptr exec, { increase_final_iteration_numbers_kernel<<< static_cast( - ceildiv(final_iter_nums->get_num_elems(), default_block_size)), + ceildiv(final_iter_nums->get_size(), default_block_size)), default_block_size, 0, exec->get_stream()>>>( as_device_type(final_iter_nums->get_data()), - stop_status->get_const_data(), final_iter_nums->get_num_elems()); + stop_status->get_const_data(), final_iter_nums->get_size()); finish_arnoldi_CGS(exec, next_krylov_basis, krylov_bases, hessenberg_iter, buffer_iter, arnoldi_norm, iter, stop_status->get_const_data(), reorth_status->get_data(), diff --git a/hip/stop/criterion_kernels.hip.cpp b/hip/stop/criterion_kernels.hip.cpp index f7b875655ba..63504838046 100644 --- a/hip/stop/criterion_kernels.hip.cpp +++ b/hip/stop/criterion_kernels.hip.cpp @@ -44,11 +44,11 @@ void set_all_statuses(std::shared_ptr exec, uint8 stoppingId, bool setFinalized, array* stop_status) { const auto block_size = default_block_size; - const auto grid_size = ceildiv(stop_status->get_num_elems(), block_size); + const auto grid_size = ceildiv(stop_status->get_size(), block_size); if (grid_size > 0) { set_all_statuses<<get_stream()>>>( - stop_status->get_num_elems(), stoppingId, setFinalized, + stop_status->get_size(), stoppingId, setFinalized, as_device_type(stop_status->get_data())); } } diff --git a/hip/test/base/kernel_launch.hip.cpp b/hip/test/base/kernel_launch.hip.cpp index 6f0ce86455d..c0e1f23892d 100644 --- a/hip/test/base/kernel_launch.hip.cpp +++ b/hip/test/base/kernel_launch.hip.cpp @@ -111,7 +111,7 @@ void run1d(std::shared_ptr exec, size_type dim, int* data) TEST_F(KernelLaunch, Runs1D) { - run1d(exec, zero_array.get_num_elems(), zero_array.get_data()); + run1d(exec, zero_array.get_size(), zero_array.get_data()); GKO_ASSERT_ARRAY_EQ(zero_array, iota_array); } @@ -132,7 +132,7 @@ void run1d(std::shared_ptr exec, gko::array& data) d[i] = 0; } }, - data.get_num_elems(), data, data.get_const_data(), move_only_val); + data.get_size(), data, data.get_const_data(), move_only_val); } TEST_F(KernelLaunch, Runs1DArray) diff --git a/hip/test/components/cooperative_groups.hip.cpp b/hip/test/components/cooperative_groups.hip.cpp index 3358389439e..5be6a83545f 100644 --- a/hip/test/components/cooperative_groups.hip.cpp +++ b/hip/test/components/cooperative_groups.hip.cpp @@ -266,7 +266,7 @@ TEST_F(CooperativeGroups, ShuffleSumDouble) gko::array value(ref, config::warp_size); gko::array answer(ref, config::warp_size); gko::array dvalue(exec); - for (int i = 0; i < value.get_num_elems(); i++) { + for (int i = 0; i < value.get_size(); i++) { value.get_data()[i] = x_dbl; answer.get_data()[i] = value.get_data()[i] * (1 << num); } @@ -289,7 +289,7 @@ TEST_F(CooperativeGroups, ShuffleSumComplexDouble) gko::array> value(ref, config::warp_size); gko::array> answer(ref, config::warp_size); gko::array> dvalue(exec); - for (int i = 0; i < value.get_num_elems(); i++) { + for (int i = 0; i < value.get_size(); i++) { value.get_data()[i] = std::complex{x_dbl, x_dbl}; answer.get_data()[i] = std::complex{x_dbl * (1 << num), x_dbl * (1 << num)}; diff --git a/include/ginkgo/core/base/array.hpp b/include/ginkgo/core/base/array.hpp index 928d7f5a26b..1e9c209bddc 100644 --- a/include/ginkgo/core/base/array.hpp +++ b/include/ginkgo/core/base/array.hpp @@ -62,12 +62,12 @@ class const_array_view { * Constructs an array view from existing data. * * @param exec the executor in whose memory space the data resides. - * @param num_elems the number of elements in this array view. + * @param size the number of elements in this array view. * @param data a pointer to the first element of this array view. */ - const_array_view(std::shared_ptr exec, size_type num_elems, + const_array_view(std::shared_ptr exec, size_type size, const ValueType* data) - : exec_{std::move(exec)}, num_elems_{num_elems}, data_{data} + : exec_{std::move(exec)}, size_{size}, data_{data} {} /* @@ -82,9 +82,9 @@ class const_array_view { * to guaranteed RVO. */ const_array_view(const_array_view&& other) - : const_array_view{other.exec_, other.num_elems_, other.data_} + : const_array_view{other.exec_, other.size_, other.data_} { - other.num_elems_ = 0; + other.size_ = 0; other.data_ = nullptr; } @@ -93,7 +93,15 @@ class const_array_view { * * @return the number of elements in the array view */ - size_type get_num_elems() const noexcept { return num_elems_; } + size_type get_size() const noexcept { return size_; } + + /** + * Returns the number of elements in the array view. + * + * @return the number of elements in the array view + */ + GKO_DEPRECATED("use get_size() instead") + size_type get_num_elems() const noexcept { return get_size(); } /** * Returns a constant pointer to the first element of this array view. @@ -126,7 +134,7 @@ class const_array_view { private: std::shared_ptr exec_; - size_type num_elems_; + size_type size_; const ValueType* data_; }; @@ -187,9 +195,7 @@ class array { * the executor of the source array. */ array() noexcept - : num_elems_(0), - data_(nullptr, default_deleter{nullptr}), - exec_(nullptr) + : size_(0), data_(nullptr, default_deleter{nullptr}), exec_(nullptr) {} /** @@ -198,7 +204,7 @@ class array { * @param exec the Executor where the array data is allocated */ explicit array(std::shared_ptr exec) noexcept - : num_elems_(0), + : size_(0), data_(nullptr, default_deleter{exec}), exec_(std::move(exec)) {} @@ -207,16 +213,16 @@ class array { * Creates an array on the specified Executor. * * @param exec the Executor where the array data will be allocated - * @param num_elems the amount of memory (expressed as the number of - * `value_type` elements) allocated on the Executor + * @param size the amount of memory (expressed as the number of + * `value_type` elements) allocated on the Executor */ - array(std::shared_ptr exec, size_type num_elems) - : num_elems_(num_elems), + array(std::shared_ptr exec, size_type size) + : size_(size), data_(nullptr, default_deleter{exec}), exec_(std::move(exec)) { - if (num_elems > 0) { - data_.reset(exec_->alloc(num_elems)); + if (size > 0) { + data_.reset(exec_->alloc(size)); } } @@ -230,7 +236,7 @@ class array { * @tparam DeleterType type of the deleter * * @param exec executor where `data` is located - * @param num_elems number of elements in `data` + * @param size number of elements in `data` * @param data chunk of memory used to create the array * @param deleter the deleter used to free the memory * @@ -239,9 +245,9 @@ class array { * deallocate the memory using Executor::free() method */ template - array(std::shared_ptr exec, size_type num_elems, + array(std::shared_ptr exec, size_type size, value_type* data, DeleterType deleter) - : num_elems_{num_elems}, data_(data, deleter), exec_{exec} + : size_{size}, data_(data, deleter), exec_{exec} {} /** @@ -251,12 +257,12 @@ class array { * Executor::free method. * * @param exec executor where `data` is located - * @param num_elems number of elements in `data` + * @param size number of elements in `data` * @param data chunk of memory used to create the array */ - array(std::shared_ptr exec, size_type num_elems, + array(std::shared_ptr exec, size_type size, value_type* data) - : array(exec, num_elems, data, default_deleter{exec}) + : array(exec, size, data, default_deleter{exec}) {} /** @@ -352,15 +358,15 @@ class array { * `resize_and_reset` since it does not own the data it should resize. * * @param exec executor where `data` is located - * @param num_elems number of elements in `data` + * @param size number of elements in `data` * @param data chunk of memory used to create the array * * @return an array constructed from `data` */ - static array view(std::shared_ptr exec, size_type num_elems, + static array view(std::shared_ptr exec, size_type size, value_type* data) { - return array{exec, num_elems, data, view_deleter{}}; + return array{exec, size, data, view_deleter{}}; } /** @@ -371,16 +377,16 @@ class array { * `resize_and_reset` since it does not own the data it should resize. * * @param exec executor where `data` is located - * @param num_elems number of elements in `data` + * @param size number of elements in `data` * @param data chunk of memory used to create the array * * @return an array constructed from `data` */ static detail::const_array_view const_view( - std::shared_ptr exec, size_type num_elems, + std::shared_ptr exec, size_type size, const value_type* data) { - return {exec, num_elems, data}; + return {exec, size, data}; } /** @@ -389,8 +395,7 @@ class array { */ array as_view() { - return view(this->get_executor(), this->get_num_elems(), - this->get_data()); + return view(this->get_executor(), this->get_size(), this->get_data()); } /** @@ -399,7 +404,7 @@ class array { */ detail::const_array_view as_const_view() const { - return const_view(this->get_executor(), this->get_num_elems(), + return const_view(this->get_executor(), this->get_size(), this->get_const_data()); } @@ -434,12 +439,11 @@ class array { } if (this->is_owning()) { - this->resize_and_reset(other.get_num_elems()); + this->resize_and_reset(other.get_size()); } else { - GKO_ENSURE_COMPATIBLE_BOUNDS(other.get_num_elems(), - this->num_elems_); + GKO_ENSURE_COMPATIBLE_BOUNDS(other.get_size(), this->get_size()); } - exec_->copy_from(other.get_executor(), other.get_num_elems(), + exec_->copy_from(other.get_executor(), other.get_size(), other.get_const_data(), this->get_data()); return *this; } @@ -490,7 +494,7 @@ class array { // same device, only move the pointer data_ = std::exchange( other.data_, data_manager{nullptr, default_deleter{exec_}}); - num_elems_ = std::exchange(other.num_elems_, 0); + size_ = std::exchange(other.size_, 0); } else { // different device, copy the data *this = other; @@ -530,10 +534,9 @@ class array { } if (this->is_owning()) { - this->resize_and_reset(other.get_num_elems()); + this->resize_and_reset(other.get_size()); } else { - GKO_ENSURE_COMPATIBLE_BOUNDS(other.get_num_elems(), - this->num_elems_); + GKO_ENSURE_COMPATIBLE_BOUNDS(other.get_size(), this->get_size()); } array tmp{this->exec_}; const OtherValueType* source = other.get_const_data(); @@ -542,7 +545,7 @@ class array { tmp = other; source = tmp.get_const_data(); } - detail::convert_data(this->exec_, other.get_num_elems(), source, + detail::convert_data(this->exec_, other.get_size(), source, this->get_data()); return *this; } @@ -556,7 +559,7 @@ class array { */ void clear() noexcept { - num_elems_ = 0; + size_ = 0; data_.reset(nullptr); } @@ -569,12 +572,12 @@ class array { * * If the array is not assigned an executor, an exception will be thrown. * - * @param num_elems the amount of memory (expressed as the number of + * @param size the amount of memory (expressed as the number of * `value_type` elements) allocated on the Executor */ - void resize_and_reset(size_type num_elems) + void resize_and_reset(size_type size) { - if (num_elems == num_elems_) { + if (size == size_) { return; } if (exec_ == nullptr) { @@ -586,9 +589,9 @@ class array { "Non owning gko::array cannot be resized."); } - if (num_elems > 0 && this->is_owning()) { - num_elems_ = num_elems; - data_.reset(exec_->alloc(num_elems)); + if (size > 0 && this->is_owning()) { + size_ = size; + data_.reset(exec_->alloc(size)); } else { this->clear(); } @@ -606,7 +609,15 @@ class array { * * @return the number of elements in the array */ - size_type get_num_elems() const noexcept { return num_elems_; } + size_type get_size() const noexcept { return size_; } + + /** + * Returns the number of elements in the array. + * + * @return the number of elements in the array + */ + GKO_DEPRECATED("use get_size() instead") + size_type get_num_elems() const noexcept { return get_size(); } /** * Returns a pointer to the block of memory used to store the elements of @@ -679,7 +690,7 @@ class array { using data_manager = std::unique_ptr>; - size_type num_elems_; + size_type size_; data_manager data_; std::shared_ptr exec_; }; @@ -766,8 +777,7 @@ struct temporary_clone_helper> { if (copy_data) { return std::make_unique>(std::move(exec), *ptr); } else { - return std::make_unique>(std::move(exec), - ptr->get_num_elems()); + return std::make_unique>(std::move(exec), ptr->get_size()); } } }; @@ -828,7 +838,7 @@ template array array_const_cast(const_array_view view) { return array::view( - view.get_executor(), view.get_num_elems(), + view.get_executor(), view.get_size(), const_cast(view.get_const_data())); } @@ -836,9 +846,8 @@ array array_const_cast(const_array_view view) template array const_array_view::copy_to_array() const { - array result(this->get_executor(), this->get_num_elems()); - result.get_executor()->copy_from(this->get_executor(), - this->get_num_elems(), + array result(this->get_executor(), this->get_size()); + result.get_executor()->copy_from(this->get_executor(), this->get_size(), this->get_const_data(), result.get_data()); return result; } diff --git a/include/ginkgo/core/base/batch_multi_vector.hpp b/include/ginkgo/core/base/batch_multi_vector.hpp index 8dd13e84073..8e9885b95ba 100644 --- a/include/ginkgo/core/base/batch_multi_vector.hpp +++ b/include/ginkgo/core/base/batch_multi_vector.hpp @@ -184,7 +184,7 @@ class MultiVector */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** @@ -387,7 +387,7 @@ class MultiVector { // Ensure that the values array has the correct size auto num_elems = compute_num_elems(size); - GKO_ENSURE_IN_BOUNDS(num_elems, values_.get_num_elems() + 1); + GKO_ENSURE_IN_BOUNDS(num_elems, values_.get_size() + 1); } /** diff --git a/include/ginkgo/core/base/device_matrix_data.hpp b/include/ginkgo/core/base/device_matrix_data.hpp index 63499e0e6db..64c69ad36d3 100644 --- a/include/ginkgo/core/base/device_matrix_data.hpp +++ b/include/ginkgo/core/base/device_matrix_data.hpp @@ -80,8 +80,8 @@ class device_matrix_data { col_idxs_{exec, std::forward(col_idxs)}, values_{exec, std::forward(values)} { - GKO_ASSERT_EQ(values_.get_num_elems(), row_idxs_.get_num_elems()); - GKO_ASSERT_EQ(values_.get_num_elems(), col_idxs_.get_num_elems()); + GKO_ASSERT_EQ(values_.get_size(), row_idxs_.get_size()); + GKO_ASSERT_EQ(values_.get_size(), col_idxs_.get_size()); } /** @@ -147,7 +147,15 @@ class device_matrix_data { * * @return the number of stored elements of the matrix. */ - size_type get_num_elems() const { return values_.get_num_elems(); } + GKO_DEPRECATED("use get_num_stored_elements()") + size_type get_num_elems() const { return get_num_stored_elements(); } + + /** + * Returns the number of stored elements of the matrix. + * + * @return the number of stored elements of the matrix. + */ + size_type get_num_stored_elements() const { return values_.get_size(); } /** * Returns a pointer to the row index array @@ -256,7 +264,8 @@ struct temporary_clone_helper> { std::move(exec), *ptr); } else { return std::make_unique>( - std::move(exec), ptr->get_size(), ptr->get_num_elems()); + std::move(exec), ptr->get_size(), + ptr->get_num_stored_elements()); } } }; diff --git a/include/ginkgo/core/base/index_set.hpp b/include/ginkgo/core/base/index_set.hpp index 8a194df0508..5c76c99d0f3 100644 --- a/include/ginkgo/core/base/index_set.hpp +++ b/include/ginkgo/core/base/index_set.hpp @@ -116,7 +116,7 @@ class index_set { const bool is_sorted = false) : exec_(std::move(exec)), index_space_size_(size) { - GKO_ASSERT(index_space_size_ >= indices.get_num_elems()); + GKO_ASSERT(index_space_size_ >= indices.get_size()); this->populate_subsets(indices, is_sorted); } @@ -371,7 +371,7 @@ class index_set { */ index_type get_num_subsets() const { - return this->subsets_begin_.get_num_elems(); + return this->subsets_begin_.get_size(); } /** diff --git a/include/ginkgo/core/base/matrix_assembly_data.hpp b/include/ginkgo/core/base/matrix_assembly_data.hpp index d579ea12b7b..1c42e90fea2 100644 --- a/include/ginkgo/core/base/matrix_assembly_data.hpp +++ b/include/ginkgo/core/base/matrix_assembly_data.hpp @@ -152,7 +152,7 @@ class matrix_assembly_data { entry.first.second, entry.second}; }); - data.ensure_row_major_order(); + data.sort_row_major(); return data; } diff --git a/include/ginkgo/core/base/matrix_data.hpp b/include/ginkgo/core/base/matrix_data.hpp index e22f310e822..2d19534e6d7 100644 --- a/include/ginkgo/core/base/matrix_data.hpp +++ b/include/ginkgo/core/base/matrix_data.hpp @@ -232,7 +232,7 @@ struct matrix_data { } } } - this->ensure_row_major_order(); + this->sort_row_major(); } /** @@ -456,7 +456,7 @@ struct matrix_data { /** * Sorts the nonzero vector so the values follow row-major order. */ - void ensure_row_major_order() + void sort_row_major() { std::sort( begin(nonzeros), end(nonzeros), [](nonzero_type x, nonzero_type y) { @@ -464,6 +464,14 @@ struct matrix_data { }); } + /** + * Sorts the nonzero vector so the values follow row-major order. + */ + GKO_DEPRECATED("Use sort_row_major() instead") void ensure_row_major_order() + { + this->sort_row_major(); + } + /** * Remove entries with value zero from the matrix data. */ @@ -481,7 +489,7 @@ struct matrix_data { */ void sum_duplicates() { - ensure_row_major_order(); + this->sort_row_major(); std::vector new_nonzeros; if (!nonzeros.empty()) { new_nonzeros.emplace_back(nonzeros.front().row, diff --git a/include/ginkgo/core/distributed/partition.hpp b/include/ginkgo/core/distributed/partition.hpp index d003016935e..790272a1a7c 100644 --- a/include/ginkgo/core/distributed/partition.hpp +++ b/include/ginkgo/core/distributed/partition.hpp @@ -111,7 +111,7 @@ class Partition */ size_type get_num_ranges() const noexcept { - return offsets_.get_num_elems() - 1; + return offsets_.get_size() - 1; } /** diff --git a/include/ginkgo/core/log/batch_logger.hpp b/include/ginkgo/core/log/batch_logger.hpp index 01f7cfa4119..fb6d2cf37c5 100644 --- a/include/ginkgo/core/log/batch_logger.hpp +++ b/include/ginkgo/core/log/batch_logger.hpp @@ -54,7 +54,7 @@ struct log_data final { const size_type workspace_size = num_batch_items * (sizeof(real_type) + sizeof(int)); if (num_batch_items > 0 && !workspace.is_owning() && - workspace.get_num_elems() >= workspace_size) { + workspace.get_size() >= workspace_size) { iter_counts = array::view(exec, num_batch_items, reinterpret_cast(workspace.get_data())); diff --git a/include/ginkgo/core/matrix/batch_dense.hpp b/include/ginkgo/core/matrix/batch_dense.hpp index e5f7b2a719b..cd6f865dbf1 100644 --- a/include/ginkgo/core/matrix/batch_dense.hpp +++ b/include/ginkgo/core/matrix/batch_dense.hpp @@ -212,7 +212,7 @@ class Dense final : public EnableBatchLinOp>, */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** @@ -310,7 +310,7 @@ class Dense final : public EnableBatchLinOp>, { // Ensure that the values array has the correct size auto num_elems = compute_num_elems(size); - GKO_ENSURE_IN_BOUNDS(num_elems, values_.get_num_elems() + 1); + GKO_ENSURE_IN_BOUNDS(num_elems, values_.get_size() + 1); } void apply_impl(const MultiVector* b, diff --git a/include/ginkgo/core/matrix/batch_ell.hpp b/include/ginkgo/core/matrix/batch_ell.hpp index e1d8f4cc02a..ac4b5d11480 100644 --- a/include/ginkgo/core/matrix/batch_ell.hpp +++ b/include/ginkgo/core/matrix/batch_ell.hpp @@ -151,7 +151,7 @@ class Ell final */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** @@ -330,9 +330,8 @@ class Ell final // Ensure that the value and col_idxs arrays have the correct size auto num_elems = this->get_common_size()[0] * num_elems_per_row * this->get_num_batch_items(); - GKO_ASSERT_EQ(num_elems, values_.get_num_elems()); - GKO_ASSERT_EQ(this->get_num_elements_per_item(), - col_idxs_.get_num_elems()); + GKO_ASSERT_EQ(num_elems, values_.get_size()); + GKO_ASSERT_EQ(this->get_num_elements_per_item(), col_idxs_.get_size()); } void apply_impl(const MultiVector* b, diff --git a/include/ginkgo/core/matrix/coo.hpp b/include/ginkgo/core/matrix/coo.hpp index 42168ac0550..3b0b5395d82 100644 --- a/include/ginkgo/core/matrix/coo.hpp +++ b/include/ginkgo/core/matrix/coo.hpp @@ -175,7 +175,7 @@ class Coo : public EnableLinOp>, */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** @@ -316,8 +316,8 @@ class Coo : public EnableLinOp>, col_idxs_{exec, std::forward(col_idxs)}, row_idxs_{exec, std::forward(row_idxs)} { - GKO_ASSERT_EQ(values_.get_num_elems(), col_idxs_.get_num_elems()); - GKO_ASSERT_EQ(values_.get_num_elems(), row_idxs_.get_num_elems()); + GKO_ASSERT_EQ(values_.get_size(), col_idxs_.get_size()); + GKO_ASSERT_EQ(values_.get_size(), row_idxs_.get_size()); } /** diff --git a/include/ginkgo/core/matrix/csr.hpp b/include/ginkgo/core/matrix/csr.hpp index 1c24e11fa7c..39cc8dd4425 100644 --- a/include/ginkgo/core/matrix/csr.hpp +++ b/include/ginkgo/core/matrix/csr.hpp @@ -243,7 +243,7 @@ class Csr : public EnableLinOp>, row_ptrs_host = mtx_row_ptrs; row_ptrs = row_ptrs_host.get_const_data(); } - auto num_rows = mtx_row_ptrs.get_num_elems() - 1; + auto num_rows = mtx_row_ptrs.get_size() - 1; max_length_per_row_ = 0; for (size_type i = 0; i < num_rows; i++) { max_length_per_row_ = std::max(max_length_per_row_, @@ -409,7 +409,7 @@ class Csr : public EnableLinOp>, void process(const array& mtx_row_ptrs, array* mtx_srow) override { - auto nwarps = mtx_srow->get_num_elems(); + auto nwarps = mtx_srow->get_size(); if (nwarps > 0) { auto host_srow_exec = mtx_srow->get_executor()->get_master(); @@ -437,7 +437,7 @@ class Csr : public EnableLinOp>, for (size_type i = 0; i < nwarps; i++) { srow[i] = 0; } - const auto num_rows = mtx_row_ptrs.get_num_elems() - 1; + const auto num_rows = mtx_row_ptrs.get_size() - 1; const auto num_elems = row_ptrs[num_rows]; const auto bucket_divider = num_elems > 0 ? ceildiv(num_elems, warp_size_) : 1; @@ -624,7 +624,7 @@ class Csr : public EnableLinOp>, row_ptrs_host = mtx_row_ptrs; row_ptrs = row_ptrs_host.get_const_data(); } - const auto num_rows = mtx_row_ptrs.get_num_elems() - 1; + const auto num_rows = mtx_row_ptrs.get_size() - 1; if (row_ptrs[num_rows] > nnz_limit) { load_balance actual_strategy(nwarps_, warp_size_, cuda_strategy_, strategy_name_); @@ -925,7 +925,7 @@ class Csr : public EnableLinOp>, */ size_type get_num_srow_elements() const noexcept { - return srow_.get_num_elems(); + return srow_.get_size(); } /** @@ -935,7 +935,7 @@ class Csr : public EnableLinOp>, */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** Returns the strategy @@ -1160,8 +1160,8 @@ class Csr : public EnableLinOp>, srow_(exec), strategy_(strategy->copy()) { - GKO_ASSERT_EQ(values_.get_num_elems(), col_idxs_.get_num_elems()); - GKO_ASSERT_EQ(this->get_size()[0] + 1, row_ptrs_.get_num_elems()); + GKO_ASSERT_EQ(values_.get_size(), col_idxs_.get_size()); + GKO_ASSERT_EQ(this->get_size()[0] + 1, row_ptrs_.get_size()); this->make_srow(); } @@ -1316,7 +1316,7 @@ class Csr : public EnableLinOp>, */ void make_srow() { - srow_.resize_and_reset(strategy_->clac_size(values_.get_num_elems())); + srow_.resize_and_reset(strategy_->clac_size(values_.get_size())); strategy_->process(row_ptrs_, &srow_); } diff --git a/include/ginkgo/core/matrix/dense.hpp b/include/ginkgo/core/matrix/dense.hpp index 51c74ed2e8b..6f54cdb0654 100644 --- a/include/ginkgo/core/matrix/dense.hpp +++ b/include/ginkgo/core/matrix/dense.hpp @@ -629,7 +629,7 @@ class Dense * @param gather_indices pointer to an array containing row indices * from this matrix. It may contain duplicates. * @return Dense matrix on the same executor with the same number of - * columns and `gather_indices->get_num_elems()` rows containing + * columns and `gather_indices->get_size()` rows containing * the gathered rows from this matrix: * `output(i,j) = input(gather_indices(i), j)` */ @@ -650,7 +650,7 @@ class Dense * `row_collection(i,j) * = input(gather_indices(i), j)` * It must have the same number of columns as this - * matrix and `gather_indices->get_num_elems()` rows. + * matrix and `gather_indices->get_size()` rows. */ void row_gather(const array* gather_indices, ptr_param row_collection) const; @@ -672,7 +672,7 @@ class Dense * gathered rows: * `row_collection(i,j) = input(gather_indices(i), j)` * It must have the same number of columns as this - * matrix and `gather_indices->get_num_elems()` rows. + * matrix and `gather_indices->get_size()` rows. */ void row_gather(ptr_param alpha, const array* gather_indices, @@ -853,7 +853,7 @@ class Dense */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** @@ -1230,7 +1230,7 @@ class Dense { if (size[0] > 0 && size[1] > 0) { GKO_ENSURE_IN_BOUNDS((size[0] - 1) * stride + size[1] - 1, - values_.get_num_elems()); + values_.get_size()); } } diff --git a/include/ginkgo/core/matrix/diagonal.hpp b/include/ginkgo/core/matrix/diagonal.hpp index bd7e6b11f77..02fd6c0aa98 100644 --- a/include/ginkgo/core/matrix/diagonal.hpp +++ b/include/ginkgo/core/matrix/diagonal.hpp @@ -224,7 +224,7 @@ class Diagonal : EnableLinOp(exec, dim<2>(size)), values_{exec, std::forward(values)} { - GKO_ENSURE_IN_BOUNDS(size - 1, values_.get_num_elems()); + GKO_ENSURE_IN_BOUNDS(size - 1, values_.get_size()); } void apply_impl(const LinOp* b, LinOp* x) const override; diff --git a/include/ginkgo/core/matrix/ell.hpp b/include/ginkgo/core/matrix/ell.hpp index fde99c8047d..a0e089f5c29 100644 --- a/include/ginkgo/core/matrix/ell.hpp +++ b/include/ginkgo/core/matrix/ell.hpp @@ -174,7 +174,7 @@ class Ell : public EnableLinOp>, */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** @@ -354,9 +354,9 @@ class Ell : public EnableLinOp>, stride_{stride} { GKO_ASSERT_EQ(num_stored_elements_per_row_ * stride_, - values_.get_num_elems()); + values_.get_size()); GKO_ASSERT_EQ(num_stored_elements_per_row_ * stride_, - col_idxs_.get_num_elems()); + col_idxs_.get_size()); } /** diff --git a/include/ginkgo/core/matrix/fbcsr.hpp b/include/ginkgo/core/matrix/fbcsr.hpp index c5fd5156591..fb159a1bffe 100644 --- a/include/ginkgo/core/matrix/fbcsr.hpp +++ b/include/ginkgo/core/matrix/fbcsr.hpp @@ -272,7 +272,7 @@ class Fbcsr : public EnableLinOp>, */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** @@ -280,7 +280,7 @@ class Fbcsr : public EnableLinOp>, */ size_type get_num_stored_blocks() const noexcept { - return col_idxs_.get_num_elems(); + return col_idxs_.get_size(); } /** @@ -423,9 +423,8 @@ class Fbcsr : public EnableLinOp>, col_idxs_{exec, std::forward(col_idxs)}, row_ptrs_{exec, std::forward(row_ptrs)} { - GKO_ASSERT_EQ(values_.get_num_elems(), - col_idxs_.get_num_elems() * bs_ * bs_); - GKO_ASSERT_EQ(this->get_size()[0] / bs_ + 1, row_ptrs_.get_num_elems()); + GKO_ASSERT_EQ(values_.get_size(), col_idxs_.get_size() * bs_ * bs_); + GKO_ASSERT_EQ(this->get_size()[0] / bs_ + 1, row_ptrs_.get_size()); } void apply_impl(const LinOp* b, LinOp* x) const override; diff --git a/include/ginkgo/core/matrix/hybrid.hpp b/include/ginkgo/core/matrix/hybrid.hpp index 389fa66f155..b155ecbd4c7 100644 --- a/include/ginkgo/core/matrix/hybrid.hpp +++ b/include/ginkgo/core/matrix/hybrid.hpp @@ -115,7 +115,7 @@ class Hybrid size_type* coo_nnz) { array ref_row_nnz(row_nnz.get_executor()->get_master(), - row_nnz.get_num_elems()); + row_nnz.get_size()); ref_row_nnz = row_nnz; ell_num_stored_elements_per_row_ = this->compute_ell_num_stored_elements_per_row(&ref_row_nnz); @@ -164,7 +164,7 @@ class Hybrid { size_type coo_nnz = 0; auto row_nnz_val = row_nnz.get_const_data(); - for (size_type i = 0; i < row_nnz.get_num_elems(); i++) { + for (size_type i = 0; i < row_nnz.get_size(); i++) { if (row_nnz_val[i] > ell_num_stored_elements_per_row_) { coo_nnz += row_nnz_val[i] - ell_num_stored_elements_per_row_; @@ -235,7 +235,7 @@ class Hybrid array* row_nnz) const override { auto row_nnz_val = row_nnz->get_data(); - auto num_rows = row_nnz->get_num_elems(); + auto num_rows = row_nnz->get_size(); if (num_rows == 0) { return 0; } @@ -276,7 +276,7 @@ class Hybrid size_type compute_ell_num_stored_elements_per_row( array* row_nnz) const override { - auto num_rows = row_nnz->get_num_elems(); + auto num_rows = row_nnz->get_size(); auto ell_cols = strategy_.compute_ell_num_stored_elements_per_row(row_nnz); return std::min(ell_cols, diff --git a/include/ginkgo/core/matrix/permutation.hpp b/include/ginkgo/core/matrix/permutation.hpp index 5c25a4c2596..7a2ba75e1d0 100644 --- a/include/ginkgo/core/matrix/permutation.hpp +++ b/include/ginkgo/core/matrix/permutation.hpp @@ -250,7 +250,7 @@ class Permutation : public EnableLinOp>, : Permutation{exec, array{exec, std::forward( permutation_indices)}} { - GKO_ASSERT_EQ(size[0], permutation_.get_num_elems()); + GKO_ASSERT_EQ(size[0], permutation_.get_size()); GKO_ASSERT_IS_SQUARE_MATRIX(size); } @@ -264,7 +264,7 @@ class Permutation : public EnableLinOp>, permutation_indices)}} { GKO_ASSERT_EQ(enabled_permute, row_permute); - GKO_ASSERT_EQ(size[0], permutation_.get_num_elems()); + GKO_ASSERT_EQ(size[0], permutation_.get_size()); GKO_ASSERT_IS_SQUARE_MATRIX(size); } diff --git a/include/ginkgo/core/matrix/row_gatherer.hpp b/include/ginkgo/core/matrix/row_gatherer.hpp index 6540f82cf8f..8c8ca76c2d8 100644 --- a/include/ginkgo/core/matrix/row_gatherer.hpp +++ b/include/ginkgo/core/matrix/row_gatherer.hpp @@ -128,7 +128,7 @@ class RowGatherer : public EnableLinOp>, : EnableLinOp(exec, size), row_idxs_{exec, std::forward(row_idxs)} { - GKO_ASSERT_EQ(size[0], row_idxs_.get_num_elems()); + GKO_ASSERT_EQ(size[0], row_idxs_.get_size()); } void apply_impl(const LinOp* in, LinOp* out) const override; diff --git a/include/ginkgo/core/matrix/sellp.hpp b/include/ginkgo/core/matrix/sellp.hpp index 2aff3e3e928..bcc2bb234b6 100644 --- a/include/ginkgo/core/matrix/sellp.hpp +++ b/include/ginkgo/core/matrix/sellp.hpp @@ -203,7 +203,7 @@ class Sellp : public EnableLinOp>, */ size_type get_total_cols() const noexcept { - return values_.get_num_elems() / slice_size_; + return values_.get_size() / slice_size_; } /** @@ -213,7 +213,7 @@ class Sellp : public EnableLinOp>, */ size_type get_num_stored_elements() const noexcept { - return values_.get_num_elems(); + return values_.get_size(); } /** diff --git a/include/ginkgo/core/matrix/sparsity_csr.hpp b/include/ginkgo/core/matrix/sparsity_csr.hpp index 2f6c4b22030..0e4f0677899 100644 --- a/include/ginkgo/core/matrix/sparsity_csr.hpp +++ b/include/ginkgo/core/matrix/sparsity_csr.hpp @@ -184,10 +184,7 @@ class SparsityCsr * * @return the number of elements explicitly stored in the matrix */ - size_type get_num_nonzeros() const noexcept - { - return col_idxs_.get_num_elems(); - } + size_type get_num_nonzeros() const noexcept { return col_idxs_.get_size(); } /** * Creates a constant (immutable) SparsityCsr matrix from constant arrays. @@ -287,7 +284,7 @@ class SparsityCsr row_ptrs_{exec, std::forward(row_ptrs)}, value_{exec, {value}} { - GKO_ASSERT_EQ(this->get_size()[0] + 1, row_ptrs_.get_num_elems()); + GKO_ASSERT_EQ(this->get_size()[0] + 1, row_ptrs_.get_size()); } /** diff --git a/include/ginkgo/core/preconditioner/jacobi.hpp b/include/ginkgo/core/preconditioner/jacobi.hpp index c9dfee39963..713a0ae6279 100644 --- a/include/ginkgo/core/preconditioner/jacobi.hpp +++ b/include/ginkgo/core/preconditioner/jacobi.hpp @@ -260,7 +260,7 @@ class Jacobi : public EnableLinOp>, */ size_type get_num_stored_elements() const noexcept { - return blocks_.get_num_elems(); + return blocks_.get_size(); } void convert_to(matrix::Dense* result) const override; @@ -379,13 +379,13 @@ class Jacobi : public EnableLinOp>, storage_optimization_type( const array& block_wise_opt) - : is_block_wise{block_wise_opt.get_num_elems() > 0}, + : is_block_wise{block_wise_opt.get_size() > 0}, block_wise{block_wise_opt} {} storage_optimization_type( array&& block_wise_opt) - : is_block_wise{block_wise_opt.get_num_elems() > 0}, + : is_block_wise{block_wise_opt.get_size() > 0}, block_wise{std::move(block_wise_opt)} {} @@ -529,10 +529,10 @@ class Jacobi : public EnableLinOp>, parameters_{factory->get_parameters()}, storage_scheme_{this->compute_storage_scheme( parameters_.max_block_size, parameters_.max_block_stride)}, - num_blocks_{parameters_.block_pointers.get_num_elems() - 1}, + num_blocks_{parameters_.block_pointers.get_size() - 1}, blocks_(factory->get_executor(), storage_scheme_.compute_storage_space( - parameters_.block_pointers.get_num_elems() - 1)), + parameters_.block_pointers.get_size() - 1)), conditioning_(factory->get_executor()) { parameters_.block_pointers.set_executor(this->get_executor()); diff --git a/include/ginkgo/core/solver/workspace.hpp b/include/ginkgo/core/solver/workspace.hpp index 91e5b41cdbf..fa0cd648a1a 100644 --- a/include/ginkgo/core/solver/workspace.hpp +++ b/include/ginkgo/core/solver/workspace.hpp @@ -146,7 +146,7 @@ class workspace { array& create_or_get_array(int array_id, size_type size) { auto& result = init_or_get_array(array_id); - if (result.get_num_elems() != size) { + if (result.get_size() != size) { result.resize_and_reset(size); } return result; diff --git a/omp/base/device_matrix_data_kernels.cpp b/omp/base/device_matrix_data_kernels.cpp index d88c5226c15..43627a51f18 100644 --- a/omp/base/device_matrix_data_kernels.cpp +++ b/omp/base/device_matrix_data_kernels.cpp @@ -27,7 +27,7 @@ void remove_zeros(std::shared_ptr exec, array& values, array& row_idxs, array& col_idxs) { - const auto size = values.get_num_elems(); + const auto size = values.get_size(); const auto num_threads = omp_get_max_threads(); const auto per_thread = static_cast(ceildiv(size, num_threads)); vector partial_counts(num_threads, {exec}); @@ -81,11 +81,11 @@ void sum_duplicates(std::shared_ptr exec, size_type num_rows, array& values, array& row_idxs, array& col_idxs) { - const auto size = values.get_num_elems(); + const auto size = values.get_size(); array row_ptrs_array{exec, num_rows + 1}; array out_row_ptrs_array{exec, num_rows + 1}; components::convert_idxs_to_ptrs(exec, row_idxs.get_const_data(), - row_idxs.get_num_elems(), num_rows, + row_idxs.get_size(), num_rows, row_ptrs_array.get_data()); const auto row_ptrs = row_ptrs_array.get_const_data(); const auto out_row_ptrs = out_row_ptrs_array.get_data(); @@ -138,10 +138,10 @@ template void sort_row_major(std::shared_ptr exec, device_matrix_data& data) { - array> tmp{exec, - data.get_num_elems()}; + array> tmp{ + exec, data.get_num_stored_elements()}; soa_to_aos(exec, data, tmp); - std::sort(tmp.get_data(), tmp.get_data() + tmp.get_num_elems()); + std::sort(tmp.get_data(), tmp.get_data() + tmp.get_size()); aos_to_soa(exec, tmp, data); } diff --git a/omp/base/index_set_kernels.cpp b/omp/base/index_set_kernels.cpp index ccef5c2a9c0..29fb238afb4 100644 --- a/omp/base/index_set_kernels.cpp +++ b/omp/base/index_set_kernels.cpp @@ -66,7 +66,7 @@ void populate_subsets(std::shared_ptr exec, array* subset_end, array* superset_indices, const bool is_sorted) { - auto num_indices = indices->get_num_elems(); + auto num_indices = indices->get_size(); auto tmp_indices = gko::array(*indices); // Sort the indices if not sorted. if (!is_sorted) { diff --git a/omp/base/kernel_launch_reduction.hpp b/omp/base/kernel_launch_reduction.hpp index f97535b32bc..045e68189f7 100644 --- a/omp/base/kernel_launch_reduction.hpp +++ b/omp/base/kernel_launch_reduction.hpp @@ -40,7 +40,7 @@ void run_kernel_reduction_impl(std::shared_ptr exec, const auto work_per_thread = ceildiv(ssize, std::max(num_threads, 1)); const auto required_storage = sizeof(ValueType) * num_threads; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } const auto partial = reinterpret_cast(tmp.get_data()); @@ -80,7 +80,7 @@ void run_kernel_reduction_sized_impl(syn::value_list, const auto num_threads = std::min(omp_get_max_threads(), rows); const auto work_per_thread = ceildiv(rows, std::max(num_threads, 1)); const auto required_storage = sizeof(ValueType) * num_threads; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } const auto partial = reinterpret_cast(tmp.get_data()); @@ -216,7 +216,7 @@ void run_kernel_row_reduction_impl(std::shared_ptr exec, const auto temp_elems_per_row = num_threads; const auto required_storage = sizeof(ValueType) * rows * temp_elems_per_row; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } const auto partial = reinterpret_cast(tmp.get_data()); @@ -321,7 +321,7 @@ void run_kernel_col_reduction_sized_impl( const auto rows_per_thread = ceildiv(rows, std::max(reduction_size, 1)); const auto required_storage = sizeof(ValueType) * cols * reduction_size; - if (tmp.get_num_elems() < required_storage) { + if (tmp.get_size() < required_storage) { tmp.resize_and_reset(required_storage); } const auto partial = reinterpret_cast(tmp.get_data()); diff --git a/omp/distributed/matrix_kernels.cpp b/omp/distributed/matrix_kernels.cpp index 2a2217e56ce..6a5a3f50d17 100644 --- a/omp/distributed/matrix_kernels.cpp +++ b/omp/distributed/matrix_kernels.cpp @@ -83,7 +83,7 @@ void build_local_nonlocal( vector local_entries(exec); auto num_threads = static_cast(omp_get_max_threads()); - auto num_input = input.get_num_elems(); + auto num_input = input.get_num_stored_elements(); auto size_per_thread = (num_input + num_threads - 1) / num_threads; std::vector local_entry_offsets(num_threads, 0); std::vector non_local_entry_offsets(num_threads, 0); @@ -203,8 +203,7 @@ void build_local_nonlocal( // build local-to-global map for non-local columns non_local_to_global.resize_and_reset(num_non_local_cols); - std::fill_n(non_local_to_global.get_data(), - non_local_to_global.get_num_elems(), + std::fill_n(non_local_to_global.get_data(), non_local_to_global.get_size(), invalid_index()); for (const auto& key_value : non_local_global_to_local) { const auto global_idx = key_value.first; diff --git a/omp/distributed/partition_helpers_kernels.cpp b/omp/distributed/partition_helpers_kernels.cpp index 4ee08744c95..c313aa121fa 100644 --- a/omp/distributed/partition_helpers_kernels.cpp +++ b/omp/distributed/partition_helpers_kernels.cpp @@ -21,7 +21,7 @@ void sort_by_range_start( array& part_ids) { auto part_ids_d = part_ids.get_data(); - auto num_parts = part_ids.get_num_elems(); + auto num_parts = part_ids.get_size(); auto start_it = detail::make_permute_iterator( range_start_ends.get_data(), [](const auto i) { return 2 * i; }); auto end_it = detail::make_permute_iterator( diff --git a/omp/distributed/vector_kernels.cpp b/omp/distributed/vector_kernels.cpp index 51d5b35ff5c..d071852d11d 100644 --- a/omp/distributed/vector_kernels.cpp +++ b/omp/distributed/vector_kernels.cpp @@ -49,7 +49,7 @@ void build_local( size_type range_id_hint = 0; #pragma omp parallel for firstprivate(range_id_hint) - for (size_type i = 0; i < input.get_num_elems(); ++i) { + for (size_type i = 0; i < input.get_num_stored_elements(); ++i) { auto range_id = find_range(row_idxs[i], range_id_hint); range_id_hint = range_id; auto part_id = range_parts[range_id]; diff --git a/omp/matrix/csr_kernels.cpp b/omp/matrix/csr_kernels.cpp index d00c1b6b222..eaaba2d277d 100644 --- a/omp/matrix/csr_kernels.cpp +++ b/omp/matrix/csr_kernels.cpp @@ -626,7 +626,7 @@ void convert_to_fbcsr(std::shared_ptr exec, value_vec[value_vec.size() - bs * bs + local_row + local_col * bs] = entry.value; } - while (block_row < static_cast(row_ptrs.get_num_elems() - 1)) { + while (block_row < static_cast(row_ptrs.get_size() - 1)) { // we finished row block_row, so store its end pointer out_row_ptrs[block_row + 1] = col_idx_vec.size(); ++block_row; diff --git a/omp/matrix/fbcsr_kernels.cpp b/omp/matrix/fbcsr_kernels.cpp index f9bdd435136..652cb074475 100644 --- a/omp/matrix/fbcsr_kernels.cpp +++ b/omp/matrix/fbcsr_kernels.cpp @@ -134,9 +134,9 @@ void fill_in_matrix_data(std::shared_ptr exec, array& col_idxs, array& values) { array> block_ordered{ - exec, data.get_num_elems()}; + exec, data.get_num_stored_elements()}; components::soa_to_aos(exec, data, block_ordered); - const auto in_nnz = data.get_num_elems(); + const auto in_nnz = data.get_num_stored_elements(); auto block_ordered_ptr = block_ordered.get_data(); std::sort( block_ordered_ptr, block_ordered_ptr + in_nnz, @@ -170,7 +170,7 @@ void fill_in_matrix_data(std::shared_ptr exec, value_vec[value_vec.size() - block_size * block_size + local_row + local_col * block_size] = entry.value; } - while (block_row < static_cast(row_ptrs.get_num_elems() - 1)) { + while (block_row < static_cast(row_ptrs.get_size() - 1)) { // we finished row block_row, so store its end pointer row_ptrs_ptr[block_row + 1] = col_idx_vec.size(); ++block_row; diff --git a/omp/preconditioner/jacobi_kernels.cpp b/omp/preconditioner/jacobi_kernels.cpp index 19126f93f86..981749393d7 100644 --- a/omp/preconditioner/jacobi_kernels.cpp +++ b/omp/preconditioner/jacobi_kernels.cpp @@ -42,8 +42,8 @@ void initialize_precisions(std::shared_ptr exec, const array& source, array& precisions) { - const auto source_size = source.get_num_elems(); - for (auto i = 0u; i < precisions.get_num_elems(); ++i) { + const auto source_size = source.get_size(); + for (auto i = 0u; i < precisions.get_size(); ++i) { precisions.get_data()[i] = source.get_const_data()[i % source_size]; } } diff --git a/omp/solver/cb_gmres_kernels.cpp b/omp/solver/cb_gmres_kernels.cpp index 957897ec736..1eb1a935e44 100644 --- a/omp/solver/cb_gmres_kernels.cpp +++ b/omp/solver/cb_gmres_kernels.cpp @@ -430,7 +430,7 @@ void arnoldi(std::shared_ptr exec, array*) { #pragma omp parallel for - for (size_type i = 0; i < final_iter_nums->get_num_elems(); ++i) { + for (size_type i = 0; i < final_iter_nums->get_size(); ++i) { final_iter_nums->get_data()[i] += (1 - static_cast( stop_status->get_const_data()[i].has_stopped())); diff --git a/omp/stop/criterion_kernels.cpp b/omp/stop/criterion_kernels.cpp index aa7d41a032e..c324ec68123 100644 --- a/omp/stop/criterion_kernels.cpp +++ b/omp/stop/criterion_kernels.cpp @@ -23,7 +23,7 @@ void set_all_statuses(std::shared_ptr exec, uint8 stoppingId, bool setFinalized, array* stop_status) { #pragma omp parallel for - for (int i = 0; i < stop_status->get_num_elems(); i++) { + for (int i = 0; i < stop_status->get_size(); i++) { stop_status->get_data()[i].stop(stoppingId, setFinalized); } } diff --git a/omp/stop/residual_norm_kernels.cpp b/omp/stop/residual_norm_kernels.cpp index fde67bbc441..ddeb01a84a1 100644 --- a/omp/stop/residual_norm_kernels.cpp +++ b/omp/stop/residual_norm_kernels.cpp @@ -47,7 +47,7 @@ void residual_norm(std::shared_ptr exec, // But it's parallel so does it matter? bool local_all_converged = true; #pragma omp parallel for reduction(&& : local_all_converged) - for (size_type i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_type i = 0; i < stop_status->get_size(); ++i) { if (!stop_status->get_const_data()[i].has_stopped()) { local_all_converged = false; } @@ -92,7 +92,7 @@ void implicit_residual_norm( // But it's parallel so does it matter? bool local_all_converged = true; #pragma omp parallel for reduction(&& : local_all_converged) - for (size_type i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_type i = 0; i < stop_status->get_size(); ++i) { if (!stop_status->get_const_data()[i].has_stopped()) { local_all_converged = false; } diff --git a/omp/test/base/index_set.cpp b/omp/test/base/index_set.cpp index 9f5e6764e61..9b39292f365 100644 --- a/omp/test/base/index_set.cpp +++ b/omp/test/base/index_set.cpp @@ -91,8 +91,7 @@ TYPED_TEST(index_set, PopulateSubsetsIsEquivalentToReferenceForUnsortedInput) TYPED_TEST(index_set, PopulateSubsetsIsEquivalentToReferenceForSortedInput) { auto rand_arr = this->setup_random_indices(512); - std::sort(rand_arr.get_data(), - rand_arr.get_data() + rand_arr.get_num_elems()); + std::sort(rand_arr.get_data(), rand_arr.get_data() + rand_arr.get_size()); auto ref_begin_comp = gko::array{this->ref}; auto ref_end_comp = gko::array{this->ref}; auto ref_superset_comp = gko::array{this->ref}; @@ -158,23 +157,23 @@ TYPED_TEST(index_set, GetGlobalIndicesIsEquivalentToReference) omp_idx_set.get_superset_indices() + omp_idx_set.get_num_subsets()}; auto ref_local_arr = - gko::array{this->ref, rand_global_arr.get_num_elems()}; + gko::array{this->ref, rand_global_arr.get_size()}; gko::kernels::reference::idx_set::global_to_local( this->ref, TypeParam(520), ref_idx_set.get_num_subsets(), ref_idx_set.get_subsets_begin(), ref_idx_set.get_subsets_end(), ref_idx_set.get_superset_indices(), - static_cast(rand_global_arr.get_num_elems()), + static_cast(rand_global_arr.get_size()), rand_global_arr.get_const_data(), ref_local_arr.get_data(), false); auto omp_local_arr = - gko::array{this->omp, rand_global_arr.get_num_elems()}; + gko::array{this->omp, rand_global_arr.get_size()}; gko::kernels::omp::idx_set::global_to_local( this->omp, TypeParam(520), omp_idx_set.get_num_subsets(), omp_idx_set.get_subsets_begin(), omp_idx_set.get_subsets_end(), omp_idx_set.get_superset_indices(), - static_cast(rand_global_arr.get_num_elems()), + static_cast(rand_global_arr.get_size()), rand_global_arr.get_const_data(), omp_local_arr.get_data(), false); - ASSERT_EQ(rand_global_arr.get_num_elems(), omp_local_arr.get_num_elems()); + ASSERT_EQ(rand_global_arr.get_size(), omp_local_arr.get_size()); GKO_ASSERT_ARRAY_EQ(ref_local_arr, omp_local_arr); } @@ -205,21 +204,21 @@ TYPED_TEST(index_set, GetLocalIndicesIsEquivalentToReference) omp_idx_set.get_superset_indices() + omp_idx_set.get_num_subsets()}; auto ref_global_arr = - gko::array{this->ref, rand_local_arr.get_num_elems()}; + gko::array{this->ref, rand_local_arr.get_size()}; gko::kernels::reference::idx_set::local_to_global( this->ref, ref_idx_set.get_num_subsets(), ref_idx_set.get_subsets_begin(), ref_idx_set.get_superset_indices(), - static_cast(rand_local_arr.get_num_elems()), + static_cast(rand_local_arr.get_size()), rand_local_arr.get_const_data(), ref_global_arr.get_data(), false); auto omp_global_arr = - gko::array{this->omp, rand_local_arr.get_num_elems()}; + gko::array{this->omp, rand_local_arr.get_size()}; gko::kernels::omp::idx_set::local_to_global( this->omp, omp_idx_set.get_num_subsets(), omp_idx_set.get_subsets_begin(), omp_idx_set.get_superset_indices(), - static_cast(rand_local_arr.get_num_elems()), + static_cast(rand_local_arr.get_size()), rand_local_arr.get_const_data(), omp_global_arr.get_data(), false); - ASSERT_EQ(rand_local_arr.get_num_elems(), omp_global_arr.get_num_elems()); + ASSERT_EQ(rand_local_arr.get_size(), omp_global_arr.get_size()); GKO_ASSERT_ARRAY_EQ(ref_global_arr, omp_global_arr); } diff --git a/omp/test/base/kernel_launch.cpp b/omp/test/base/kernel_launch.cpp index 8e6c5d5dca4..bf63405d66e 100644 --- a/omp/test/base/kernel_launch.cpp +++ b/omp/test/base/kernel_launch.cpp @@ -102,7 +102,7 @@ TEST_F(KernelLaunch, Runs1D) static_assert(is_same::value, "dummy"); d[i] = i; }, - zero_array.get_num_elems(), zero_array.get_data(), move_only_val); + zero_array.get_size(), zero_array.get_data(), move_only_val); GKO_ASSERT_ARRAY_EQ(zero_array, iota_array); } @@ -123,7 +123,7 @@ TEST_F(KernelLaunch, Runs1DArray) d[i] = 0; } }, - zero_array.get_num_elems(), zero_array, zero_array.get_const_data(), + zero_array.get_size(), zero_array, zero_array.get_const_data(), move_only_val); GKO_ASSERT_ARRAY_EQ(zero_array, iota_array); diff --git a/reference/base/device_matrix_data_kernels.cpp b/reference/base/device_matrix_data_kernels.cpp index 9af40b47622..35c1adb23dd 100644 --- a/reference/base/device_matrix_data_kernels.cpp +++ b/reference/base/device_matrix_data_kernels.cpp @@ -25,7 +25,7 @@ void soa_to_aos(std::shared_ptr exec, const device_matrix_data& in, array>& out) { - for (size_type i = 0; i < in.get_num_elems(); i++) { + for (size_type i = 0; i < in.get_num_stored_elements(); i++) { out.get_data()[i] = {in.get_const_row_idxs()[i], in.get_const_col_idxs()[i], in.get_const_values()[i]}; @@ -41,7 +41,7 @@ void aos_to_soa(std::shared_ptr exec, const array>& in, device_matrix_data& out) { - for (size_type i = 0; i < in.get_num_elems(); i++) { + for (size_type i = 0; i < in.get_size(); i++) { const auto entry = in.get_const_data()[i]; out.get_row_idxs()[i] = entry.row; out.get_col_idxs()[i] = entry.column; @@ -58,7 +58,7 @@ void remove_zeros(std::shared_ptr exec, array& values, array& row_idxs, array& col_idxs) { - auto size = values.get_num_elems(); + auto size = values.get_size(); auto nnz = static_cast( std::count_if(values.get_const_data(), values.get_const_data() + size, is_nonzero)); @@ -92,7 +92,7 @@ void sum_duplicates(std::shared_ptr exec, size_type, { auto row = invalid_index(); auto col = invalid_index(); - const auto size = values.get_num_elems(); + const auto size = values.get_size(); size_type count_unique{}; for (size_type i = 0; i < size; i++) { const auto new_row = row_idxs.get_const_data()[i]; @@ -138,10 +138,10 @@ template void sort_row_major(std::shared_ptr exec, device_matrix_data& data) { - array> tmp{exec, - data.get_num_elems()}; + array> tmp{ + exec, data.get_num_stored_elements()}; soa_to_aos(exec, data, tmp); - std::sort(tmp.get_data(), tmp.get_data() + tmp.get_num_elems()); + std::sort(tmp.get_data(), tmp.get_data() + tmp.get_size()); aos_to_soa(exec, tmp, data); } diff --git a/reference/base/index_set_kernels.cpp b/reference/base/index_set_kernels.cpp index 7a13620eaa0..2d57f1f0fab 100644 --- a/reference/base/index_set_kernels.cpp +++ b/reference/base/index_set_kernels.cpp @@ -42,7 +42,7 @@ void compute_validity(std::shared_ptr exec, const array* local_indices, array* validity_array) { - auto num_elems = local_indices->get_num_elems(); + auto num_elems = local_indices->get_size(); for (size_type i = 0; i < num_elems; ++i) { validity_array->get_data()[i] = local_indices->get_const_data()[i] != invalid_index(); @@ -82,7 +82,7 @@ void populate_subsets(std::shared_ptr exec, array* subset_end, array* superset_indices, const bool is_sorted) { - auto num_indices = indices->get_num_elems(); + auto num_indices = indices->get_size(); auto tmp_indices = gko::array(*indices); // Sort the indices if not sorted. if (!is_sorted) { diff --git a/reference/components/reduce_array_kernels.cpp b/reference/components/reduce_array_kernels.cpp index e98943016c4..c14c87738ec 100644 --- a/reference/components/reduce_array_kernels.cpp +++ b/reference/components/reduce_array_kernels.cpp @@ -18,9 +18,9 @@ template void reduce_add_array(std::shared_ptr exec, const array& arr, array& val) { - val.get_data()[0] = std::accumulate( - arr.get_const_data(), arr.get_const_data() + arr.get_num_elems(), - val.get_const_data()[0]); + val.get_data()[0] = std::accumulate(arr.get_const_data(), + arr.get_const_data() + arr.get_size(), + val.get_const_data()[0]); } GKO_INSTANTIATE_FOR_EACH_TEMPLATE_TYPE(GKO_DECLARE_REDUCE_ADD_ARRAY_KERNEL); diff --git a/reference/distributed/matrix_kernels.cpp b/reference/distributed/matrix_kernels.cpp index 52d2db0523d..ccbe182ca93 100644 --- a/reference/distributed/matrix_kernels.cpp +++ b/reference/distributed/matrix_kernels.cpp @@ -68,7 +68,7 @@ void build_local_nonlocal( vector non_local_entries(exec); size_type row_range_id = 0; size_type col_range_id = 0; - for (size_type i = 0; i < input.get_num_elems(); ++i) { + for (size_type i = 0; i < input.get_num_stored_elements(); ++i) { auto global_row = input_row_idxs[i]; row_range_id = find_range(global_row, row_partition, row_range_id); if (row_part_ids[row_range_id] == local_part) { diff --git a/reference/distributed/partition_helpers_kernels.cpp b/reference/distributed/partition_helpers_kernels.cpp index 077fb648729..f1f0bcc2a88 100644 --- a/reference/distributed/partition_helpers_kernels.cpp +++ b/reference/distributed/partition_helpers_kernels.cpp @@ -21,7 +21,7 @@ void sort_by_range_start( array& part_ids) { auto part_ids_d = part_ids.get_data(); - auto num_parts = part_ids.get_num_elems(); + auto num_parts = part_ids.get_size(); auto start_it = detail::make_permute_iterator( range_start_ends.get_data(), [](const auto i) { return 2 * i; }); auto end_it = detail::make_permute_iterator( @@ -42,7 +42,7 @@ void check_consecutive_ranges(std::shared_ptr exec, const array& range_start_ends, bool& result) { - auto num_parts = range_start_ends.get_num_elems() / 2; + auto num_parts = range_start_ends.get_size() / 2; auto start_it = detail::make_permute_iterator(range_start_ends.get_const_data() + 2, [](const auto i) { return 2 * i; }); @@ -70,7 +70,7 @@ void compress_ranges(std::shared_ptr exec, array& range_offsets) { range_offsets.get_data()[0] = range_start_ends.get_const_data()[0]; - for (int i = 0; i < range_offsets.get_num_elems() - 1; ++i) { + for (int i = 0; i < range_offsets.get_size() - 1; ++i) { range_offsets.get_data()[i + 1] = range_start_ends.get_const_data()[2 * i + 1]; } diff --git a/reference/distributed/partition_kernels.cpp b/reference/distributed/partition_kernels.cpp index a0c29dd88d1..fc409d8c2e7 100644 --- a/reference/distributed/partition_kernels.cpp +++ b/reference/distributed/partition_kernels.cpp @@ -16,7 +16,7 @@ void count_ranges(std::shared_ptr exec, { num_ranges = 0; comm_index_type prev_part{-1}; - for (size_type i = 0; i < mapping.get_num_elems(); i++) { + for (size_type i = 0; i < mapping.get_size(); i++) { auto cur_part = mapping.get_const_data()[i]; num_ranges += cur_part != prev_part; prev_part = cur_part; @@ -31,9 +31,9 @@ void build_from_contiguous(std::shared_ptr exec, GlobalIndexType* range_bounds, comm_index_type* part_ids) { - bool uses_mapping = part_id_mapping.get_num_elems() > 0; + bool uses_mapping = part_id_mapping.get_size() > 0; range_bounds[0] = 0; - for (comm_index_type i = 0; i < ranges.get_num_elems() - 1; i++) { + for (comm_index_type i = 0; i < ranges.get_size() - 1; i++) { auto end = ranges.get_const_data()[i + 1]; range_bounds[i + 1] = end; part_ids[i] = uses_mapping ? part_id_mapping.get_const_data()[i] : i; @@ -51,7 +51,7 @@ void build_from_mapping(std::shared_ptr exec, { size_type range_idx{}; comm_index_type range_part{-1}; - for (size_type i = 0; i < mapping.get_num_elems(); i++) { + for (size_type i = 0; i < mapping.get_size(); i++) { auto cur_part = mapping.get_const_data()[i]; if (cur_part != range_part) { range_bounds[range_idx] = i; @@ -60,8 +60,7 @@ void build_from_mapping(std::shared_ptr exec, range_part = cur_part; } } - range_bounds[range_idx] = - static_cast(mapping.get_num_elems()); + range_bounds[range_idx] = static_cast(mapping.get_size()); } GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(GKO_PARTITION_BUILD_FROM_MAPPING); diff --git a/reference/distributed/vector_kernels.cpp b/reference/distributed/vector_kernels.cpp index e1dbb36182b..f94c9b2f531 100644 --- a/reference/distributed/vector_kernels.cpp +++ b/reference/distributed/vector_kernels.cpp @@ -48,7 +48,7 @@ void build_local( }; size_type range_id_hint = 0; - for (size_type i = 0; i < input.get_num_elems(); ++i) { + for (size_type i = 0; i < input.get_num_stored_elements(); ++i) { auto range_id = find_range(row_idxs[i], range_id_hint); range_id_hint = range_id; auto part_id = range_parts[range_id]; diff --git a/reference/matrix/csr_kernels.cpp b/reference/matrix/csr_kernels.cpp index 07194e1f8ec..57971f18b04 100644 --- a/reference/matrix/csr_kernels.cpp +++ b/reference/matrix/csr_kernels.cpp @@ -506,7 +506,7 @@ void convert_to_fbcsr(std::shared_ptr exec, value_vec[value_vec.size() - bs * bs + local_row + local_col * bs] = entry.value; } - while (block_row < static_cast(row_ptrs.get_num_elems() - 1)) { + while (block_row < static_cast(row_ptrs.get_size() - 1)) { // we finished row block_row, so store its end pointer out_row_ptrs[block_row + 1] = col_idx_vec.size(); ++block_row; diff --git a/reference/matrix/dense_kernels.cpp b/reference/matrix/dense_kernels.cpp index 3df272f0845..89f7ae7661e 100644 --- a/reference/matrix/dense_kernels.cpp +++ b/reference/matrix/dense_kernels.cpp @@ -395,7 +395,7 @@ void fill_in_matrix_data(std::shared_ptr exec, const device_matrix_data& data, matrix::Dense* output) { - for (size_type i = 0; i < data.get_num_elems(); i++) { + for (size_type i = 0; i < data.get_num_stored_elements(); i++) { output->at(data.get_const_row_idxs()[i], data.get_const_col_idxs()[i]) = data.get_const_values()[i]; } diff --git a/reference/matrix/diagonal_kernels.cpp b/reference/matrix/diagonal_kernels.cpp index 2014842f41b..29e54588e4c 100644 --- a/reference/matrix/diagonal_kernels.cpp +++ b/reference/matrix/diagonal_kernels.cpp @@ -111,7 +111,7 @@ void fill_in_matrix_data(std::shared_ptr exec, const device_matrix_data& data, matrix::Diagonal* output) { - for (size_type i = 0; i < data.get_num_elems(); i++) { + for (size_type i = 0; i < data.get_num_stored_elements(); i++) { const auto row = data.get_const_row_idxs()[i]; if (row == data.get_const_col_idxs()[i]) { output->get_values()[row] = data.get_const_values()[i]; diff --git a/reference/matrix/ell_kernels.cpp b/reference/matrix/ell_kernels.cpp index f2c3ebf670f..db9c83a40eb 100644 --- a/reference/matrix/ell_kernels.cpp +++ b/reference/matrix/ell_kernels.cpp @@ -133,7 +133,7 @@ void compute_max_row_nnz(std::shared_ptr exec, { max_nnz = 0; const auto ptrs = row_ptrs.get_const_data(); - for (size_type i = 1; i < row_ptrs.get_num_elems(); i++) { + for (size_type i = 1; i < row_ptrs.get_size(); i++) { max_nnz = std::max(max_nnz, ptrs[i] - ptrs[i - 1]); } } diff --git a/reference/matrix/fbcsr_kernels.cpp b/reference/matrix/fbcsr_kernels.cpp index dc4e9cf317d..a917437a3e9 100644 --- a/reference/matrix/fbcsr_kernels.cpp +++ b/reference/matrix/fbcsr_kernels.cpp @@ -133,9 +133,9 @@ void fill_in_matrix_data(std::shared_ptr exec, array& col_idxs, array& values) { array> block_ordered{ - exec, data.get_num_elems()}; + exec, data.get_num_stored_elements()}; components::soa_to_aos(exec, data, block_ordered); - const auto in_nnz = data.get_num_elems(); + const auto in_nnz = data.get_num_stored_elements(); auto block_ordered_ptr = block_ordered.get_data(); std::stable_sort( block_ordered_ptr, block_ordered_ptr + in_nnz, @@ -169,7 +169,7 @@ void fill_in_matrix_data(std::shared_ptr exec, value_vec[value_vec.size() - block_size * block_size + local_row + local_col * block_size] = entry.value; } - while (block_row < static_cast(row_ptrs.get_num_elems() - 1)) { + while (block_row < static_cast(row_ptrs.get_size() - 1)) { // we finished row block_row, so store its end pointer row_ptrs_ptr[block_row + 1] = col_idx_vec.size(); ++block_row; diff --git a/reference/matrix/hybrid_kernels.cpp b/reference/matrix/hybrid_kernels.cpp index 3c230607707..e9399f2fcbc 100644 --- a/reference/matrix/hybrid_kernels.cpp +++ b/reference/matrix/hybrid_kernels.cpp @@ -33,7 +33,7 @@ void compute_coo_row_ptrs(std::shared_ptr exec, const array& row_nnz, size_type ell_lim, int64* coo_row_ptrs) { - for (size_type row = 0; row < row_nnz.get_num_elems(); row++) { + for (size_type row = 0; row < row_nnz.get_size(); row++) { if (row_nnz.get_const_data()[row] <= ell_lim) { coo_row_ptrs[row] = 0; } else { @@ -41,14 +41,14 @@ void compute_coo_row_ptrs(std::shared_ptr exec, } } components::prefix_sum_nonnegative(exec, coo_row_ptrs, - row_nnz.get_num_elems() + 1); + row_nnz.get_size() + 1); } void compute_row_nnz(std::shared_ptr exec, const array& row_ptrs, size_type* row_nnzs) { - for (size_type i = 0; i < row_ptrs.get_num_elems() - 1; i++) { + for (size_type i = 0; i < row_ptrs.get_size() - 1; i++) { row_nnzs[i] = row_ptrs.get_const_data()[i + 1] - row_ptrs.get_const_data()[i]; } diff --git a/reference/matrix/sellp_kernels.cpp b/reference/matrix/sellp_kernels.cpp index d1451a9f0c3..0b6d3adacab 100644 --- a/reference/matrix/sellp_kernels.cpp +++ b/reference/matrix/sellp_kernels.cpp @@ -108,7 +108,7 @@ void compute_slice_sets(std::shared_ptr exec, size_type stride_factor, size_type* slice_sets, size_type* slice_lengths) { - const auto num_rows = row_ptrs.get_num_elems() - 1; + const auto num_rows = row_ptrs.get_size() - 1; const auto num_slices = ceildiv(num_rows, slice_size); const auto row_ptrs_ptr = row_ptrs.get_const_data(); for (size_type slice = 0; slice < num_slices; slice++) { diff --git a/reference/multigrid/pgm_kernels.cpp b/reference/multigrid/pgm_kernels.cpp index eec17373558..cbb25c26063 100644 --- a/reference/multigrid/pgm_kernels.cpp +++ b/reference/multigrid/pgm_kernels.cpp @@ -43,7 +43,7 @@ void match_edge(std::shared_ptr exec, { auto agg_vals = agg.get_data(); auto strongest_neighbor_vals = strongest_neighbor.get_const_data(); - for (size_type i = 0; i < agg.get_num_elems(); i++) { + for (size_type i = 0; i < agg.get_size(); i++) { if (agg_vals[i] == -1) { auto neighbor = strongest_neighbor_vals[i]; // i < neighbor always holds when neighbor is not -1 @@ -65,7 +65,7 @@ void count_unagg(std::shared_ptr exec, const array& agg, IndexType* num_unagg) { IndexType unagg = 0; - for (size_type i = 0; i < agg.get_num_elems(); i++) { + for (size_type i = 0; i < agg.get_size(); i++) { unagg += (agg.get_const_data()[i] == -1); } *num_unagg = unagg; @@ -78,7 +78,7 @@ template void renumber(std::shared_ptr exec, array& agg, IndexType* num_agg) { - const auto num = agg.get_num_elems(); + const auto num = agg.get_size(); array agg_map(exec, num + 1); auto agg_vals = agg.get_data(); auto agg_map_vals = agg_map.get_data(); @@ -172,7 +172,7 @@ void find_strongest_neighbor( const auto col_idxs = weight_mtx->get_const_col_idxs(); const auto vals = weight_mtx->get_const_values(); const auto diag_vals = diag->get_const_values(); - for (size_type row = 0; row < agg.get_num_elems(); row++) { + for (size_type row = 0; row < agg.get_size(); row++) { auto max_weight_unagg = zero(); auto max_weight_agg = zero(); IndexType strongest_unagg = -1; @@ -227,11 +227,11 @@ void assign_to_exist_agg(std::shared_ptr exec, const auto col_idxs = weight_mtx->get_const_col_idxs(); const auto vals = weight_mtx->get_const_values(); const auto agg_const_val = agg.get_const_data(); - auto agg_val = (intermediate_agg.get_num_elems() > 0) + auto agg_val = (intermediate_agg.get_size() > 0) ? intermediate_agg.get_data() : agg.get_data(); const auto diag_vals = diag->get_const_values(); - for (IndexType row = 0; row < agg.get_num_elems(); row++) { + for (IndexType row = 0; row < agg.get_size(); row++) { if (agg_const_val[row] != -1) { continue; } @@ -258,7 +258,7 @@ void assign_to_exist_agg(std::shared_ptr exec, } } - if (intermediate_agg.get_num_elems() > 0) { + if (intermediate_agg.get_size() > 0) { // Copy the intermediate_agg to agg agg = intermediate_agg; } diff --git a/reference/preconditioner/jacobi_kernels.cpp b/reference/preconditioner/jacobi_kernels.cpp index 3847be36e29..12c91e0931f 100644 --- a/reference/preconditioner/jacobi_kernels.cpp +++ b/reference/preconditioner/jacobi_kernels.cpp @@ -458,8 +458,8 @@ void initialize_precisions(std::shared_ptr exec, const array& source, array& precisions) { - const auto source_size = source.get_num_elems(); - for (auto i = 0u; i < precisions.get_num_elems(); ++i) { + const auto source_size = source.get_size(); + for (auto i = 0u; i < precisions.get_size(); ++i) { precisions.get_data()[i] = source.get_const_data()[i % source_size]; } } @@ -574,7 +574,7 @@ template void scalar_conj(std::shared_ptr exec, const array& diag, array& conj_diag) { - for (size_type i = 0; i < diag.get_num_elems(); ++i) { + for (size_type i = 0; i < diag.get_size(); ++i) { conj_diag.get_data()[i] = conj(diag.get_const_data()[i]); } } @@ -586,7 +586,7 @@ template void invert_diagonal(std::shared_ptr exec, const array& diag, array& inv_diag) { - for (size_type i = 0; i < diag.get_num_elems(); ++i) { + for (size_type i = 0; i < diag.get_size(); ++i) { auto diag_val = is_zero(diag.get_const_data()[i]) ? one() : diag.get_const_data()[i]; diff --git a/reference/solver/cb_gmres_kernels.cpp b/reference/solver/cb_gmres_kernels.cpp index 76f5bea864e..e24adfdae60 100644 --- a/reference/solver/cb_gmres_kernels.cpp +++ b/reference/solver/cb_gmres_kernels.cpp @@ -387,7 +387,7 @@ void arnoldi(std::shared_ptr exec, std::is_same::value, "ValueType must match arithmetic_type of accessor!"); - for (size_type i = 0; i < final_iter_nums->get_num_elems(); ++i) { + for (size_type i = 0; i < final_iter_nums->get_size(); ++i) { final_iter_nums->get_data()[i] += (1 - static_cast( stop_status->get_const_data()[i].has_stopped())); diff --git a/reference/solver/ir_kernels.cpp b/reference/solver/ir_kernels.cpp index 21931fac305..257c15df752 100644 --- a/reference/solver/ir_kernels.cpp +++ b/reference/solver/ir_kernels.cpp @@ -19,7 +19,7 @@ namespace ir { void initialize(std::shared_ptr exec, array* stop_status) { - for (size_type j = 0; j < stop_status->get_num_elems(); ++j) { + for (size_type j = 0; j < stop_status->get_size(); ++j) { stop_status->get_data()[j].reset(); } } diff --git a/reference/stop/criterion_kernels.cpp b/reference/stop/criterion_kernels.cpp index e8bcaf43c78..f524f3aeb97 100644 --- a/reference/stop/criterion_kernels.cpp +++ b/reference/stop/criterion_kernels.cpp @@ -23,7 +23,7 @@ void set_all_statuses(std::shared_ptr exec, uint8 stoppingId, bool setFinalized, array* stop_status) { - for (int i = 0; i < stop_status->get_num_elems(); i++) { + for (int i = 0; i < stop_status->get_size(); i++) { stop_status->get_data()[i].stop(stoppingId, setFinalized); } } diff --git a/reference/stop/residual_norm_kernels.cpp b/reference/stop/residual_norm_kernels.cpp index 7ad4b3938e0..abfe8fa1dfe 100644 --- a/reference/stop/residual_norm_kernels.cpp +++ b/reference/stop/residual_norm_kernels.cpp @@ -44,7 +44,7 @@ void residual_norm(std::shared_ptr exec, *one_changed = true; } } - for (size_type i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_type i = 0; i < stop_status->get_size(); ++i) { if (!stop_status->get_const_data()[i].has_stopped()) { *all_converged = false; break; @@ -84,7 +84,7 @@ void implicit_residual_norm( *one_changed = true; } } - for (size_type i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_type i = 0; i < stop_status->get_size(); ++i) { if (!stop_status->get_const_data()[i].has_stopped()) { *all_converged = false; break; diff --git a/reference/test/base/array.cpp b/reference/test/base/array.cpp index b33d01f8b2f..8e5ca6fcf44 100644 --- a/reference/test/base/array.cpp +++ b/reference/test/base/array.cpp @@ -40,7 +40,7 @@ TYPED_TEST(Array, CanBeFilledWithValue) { this->x.fill(TypeParam{42}); - ASSERT_EQ(this->x.get_num_elems(), 2); + ASSERT_EQ(this->x.get_size(), 2); ASSERT_EQ(this->x.get_data()[0], TypeParam{42}); ASSERT_EQ(this->x.get_data()[1], TypeParam{42}); ASSERT_EQ(this->x.get_const_data()[0], TypeParam{42}); diff --git a/reference/test/base/index_set.cpp b/reference/test/base/index_set.cpp index 3ec35aecb7e..6f4d7f82e99 100644 --- a/reference/test/base/index_set.cpp +++ b/reference/test/base/index_set.cpp @@ -164,7 +164,7 @@ TYPED_TEST(index_set, CanBeConstructedFromIndices) ASSERT_EQ(idx_set.get_size(), 10); ASSERT_EQ(idx_set.get_num_subsets(), 3); - ASSERT_EQ(idx_set.get_num_subsets(), begin_comp.get_num_elems()); + ASSERT_EQ(idx_set.get_num_subsets(), begin_comp.get_size()); auto num_subsets = idx_set.get_num_subsets(); this->assert_equal_arrays(num_subsets, idx_set.get_subsets_begin(), begin_comp.get_data()); @@ -200,7 +200,7 @@ TYPED_TEST(index_set, CanBeConstructedFromNonSortedIndices) ASSERT_EQ(idx_set.get_size(), 10); ASSERT_EQ(idx_set.get_num_subsets(), 3); - ASSERT_EQ(idx_set.get_num_subsets(), begin_comp.get_num_elems()); + ASSERT_EQ(idx_set.get_num_subsets(), begin_comp.get_size()); auto num_subsets = idx_set.get_num_subsets(); this->assert_equal_arrays(num_subsets, idx_set.get_subsets_begin(), begin_comp.get_data()); @@ -271,7 +271,7 @@ TYPED_TEST(index_set, CanGetGlobalIndexFromSortedArrays) auto idx_set_gidx = idx_set.map_local_to_global(lidx_arr, true); - this->assert_equal_arrays(gidx_arr.get_num_elems(), + this->assert_equal_arrays(gidx_arr.get_size(), idx_set_gidx.get_const_data(), gidx_arr.get_const_data()); } @@ -287,7 +287,7 @@ TYPED_TEST(index_set, CanGetGlobalIndexFromUnsortedArrays) auto idx_set_gidx = idx_set.map_local_to_global(lidx_arr); - this->assert_equal_arrays(gidx_arr.get_num_elems(), + this->assert_equal_arrays(gidx_arr.get_size(), idx_set_gidx.get_const_data(), gidx_arr.get_const_data()); } @@ -329,7 +329,7 @@ TYPED_TEST(index_set, CanGetLocalIndexFromSortedArrays) auto idx_set_lidx = idx_set.map_global_to_local(gidx_arr, true); - this->assert_equal_arrays(lidx_arr.get_num_elems(), + this->assert_equal_arrays(lidx_arr.get_size(), idx_set_lidx.get_const_data(), lidx_arr.get_const_data()); } @@ -345,7 +345,7 @@ TYPED_TEST(index_set, CanGetLocalIndexFromUnsortedArrays) auto idx_set_lidx = idx_set.map_global_to_local(gidx_arr); - this->assert_equal_arrays(lidx_arr.get_num_elems(), + this->assert_equal_arrays(lidx_arr.get_size(), idx_set_lidx.get_const_data(), lidx_arr.get_const_data()); } diff --git a/reference/test/components/precision_conversion_kernels.cpp b/reference/test/components/precision_conversion_kernels.cpp index 3766a694d1c..6b8860618b1 100644 --- a/reference/test/components/precision_conversion_kernels.cpp +++ b/reference/test/components/precision_conversion_kernels.cpp @@ -100,7 +100,7 @@ TEST_F(PrecisionConversion, ConvertsRealFromView) gko::array tmp{ref}; gko::array out{ref}; - tmp = gko::make_array_view(ref, vals.get_num_elems(), vals.get_data()); + tmp = gko::make_array_view(ref, vals.get_size(), vals.get_data()); out = tmp; GKO_ASSERT_ARRAY_EQ(vals, out); diff --git a/reference/test/distributed/partition_helpers_kernels.cpp b/reference/test/distributed/partition_helpers_kernels.cpp index 8cc28dc02e5..ba698b12a3f 100644 --- a/reference/test/distributed/partition_helpers_kernels.cpp +++ b/reference/test/distributed/partition_helpers_kernels.cpp @@ -104,7 +104,7 @@ TYPED_TEST(PartitionHelpers, CanCompressRanges) using itype = typename TestFixture::global_index_type; auto range_start_ends = this->default_range_start_ends; gko::array range_offsets{this->ref, - range_start_ends.get_num_elems() / 2 + 1}; + range_start_ends.get_size() / 2 + 1}; gko::array expected_range_offsets{this->ref, {0, 4, 7, 9, 11}}; gko::kernels::reference::partition_helpers::compress_ranges( diff --git a/reference/test/distributed/partition_kernels.cpp b/reference/test/distributed/partition_kernels.cpp index 4f965691a36..33e4fec0c29 100644 --- a/reference/test/distributed/partition_kernels.cpp +++ b/reference/test/distributed/partition_kernels.cpp @@ -68,7 +68,7 @@ TYPED_TEST(Partition, BuildsFromMapping) auto partition = part_type::build_from_mapping(this->ref, mapping, num_parts); - EXPECT_EQ(partition->get_size(), mapping.get_num_elems()); + EXPECT_EQ(partition->get_size(), mapping.get_size()); EXPECT_EQ(partition->get_num_ranges(), num_ranges); EXPECT_EQ(partition->get_num_parts(), num_parts); EXPECT_EQ(partition->get_num_empty_parts(), 0); @@ -93,7 +93,7 @@ TYPED_TEST(Partition, BuildsFromMappingWithEmptyParts) auto partition = part_type::build_from_mapping(this->ref, mapping, num_parts); - EXPECT_EQ(partition->get_size(), mapping.get_num_elems()); + EXPECT_EQ(partition->get_size(), mapping.get_size()); EXPECT_EQ(partition->get_num_ranges(), num_ranges); EXPECT_EQ(partition->get_num_parts(), num_parts); EXPECT_EQ(partition->get_num_empty_parts(), 2); @@ -115,10 +115,9 @@ TYPED_TEST(Partition, BuildsFromRanges) auto partition = part_type::build_from_contiguous(this->ref, ranges); - EXPECT_EQ(partition->get_size(), - ranges.get_data()[ranges.get_num_elems() - 1]); - EXPECT_EQ(partition->get_num_ranges(), ranges.get_num_elems() - 1); - EXPECT_EQ(partition->get_num_parts(), ranges.get_num_elems() - 1); + EXPECT_EQ(partition->get_size(), ranges.get_data()[ranges.get_size() - 1]); + EXPECT_EQ(partition->get_num_ranges(), ranges.get_size() - 1); + EXPECT_EQ(partition->get_num_parts(), ranges.get_size() - 1); EXPECT_EQ(partition->get_num_empty_parts(), 1); assert_equal_data(partition->get_range_bounds(), {0, 5, 5, 7, 9, 10}); assert_equal_data(partition->get_part_ids(), {0, 1, 2, 3, 4}); @@ -153,10 +152,9 @@ TYPED_TEST(Partition, BuildsFromRangesWithPartIds) auto partition = part_type::build_from_contiguous(this->ref, ranges, part_id); - EXPECT_EQ(partition->get_size(), - ranges.get_data()[ranges.get_num_elems() - 1]); - EXPECT_EQ(partition->get_num_ranges(), ranges.get_num_elems() - 1); - EXPECT_EQ(partition->get_num_parts(), ranges.get_num_elems() - 1); + EXPECT_EQ(partition->get_size(), ranges.get_data()[ranges.get_size() - 1]); + EXPECT_EQ(partition->get_num_ranges(), ranges.get_size() - 1); + EXPECT_EQ(partition->get_num_parts(), ranges.get_size() - 1); EXPECT_EQ(partition->get_num_empty_parts(), 1); assert_equal_data(partition->get_range_bounds(), {0, 5, 5, 7, 9, 10}); assert_equal_data(partition->get_part_ids(), {0, 4, 3, 1, 2}); diff --git a/reference/test/matrix/csr_kernels.cpp b/reference/test/matrix/csr_kernels.cpp index 4dc5830c4ec..473f1b5303e 100644 --- a/reference/test/matrix/csr_kernels.cpp +++ b/reference/test/matrix/csr_kernels.cpp @@ -2418,7 +2418,7 @@ TYPED_TEST(Csr, CanGetSubmatrix2) } -TYPED_TEST(Csr, CanGetSubmatrixWithindex_set) +TYPED_TEST(Csr, CanGetSubmatrixWithIndexSet) { using Vec = typename TestFixture::Vec; using Mtx = typename TestFixture::Mtx; @@ -2576,7 +2576,7 @@ class CsrLookup : public ::testing::Test { // row 3: very sparse data.nonzeros.emplace_back(3, 0, 1.0); data.nonzeros.emplace_back(3, 64, 1.0); - data.ensure_row_major_order(); + data.sort_row_major(); // 1000 as min-sentinel full_sizes = {0, 0, 1000, 1000, 0, 0}; bitmap_sizes = {0, 6, 4, 6, 2, 2}; diff --git a/reference/test/multigrid/pgm_kernels.cpp b/reference/test/multigrid/pgm_kernels.cpp index 864472f4550..d0bbabf57f8 100644 --- a/reference/test/multigrid/pgm_kernels.cpp +++ b/reference/test/multigrid/pgm_kernels.cpp @@ -206,8 +206,7 @@ TYPED_TEST(Pgm, CanBeCopied) auto copy_coarse = copy->get_coarse_op(); GKO_ASSERT_MTX_NEAR(gko::as(copy_mtx), this->mtx, 0.0); - this->assert_same_agg(copy_agg, this->agg.get_data(), - this->agg.get_num_elems()); + this->assert_same_agg(copy_agg, this->agg.get_data(), this->agg.get_size()); GKO_ASSERT_MTX_NEAR(gko::as(copy_coarse), this->coarse, 0.0); } @@ -224,8 +223,7 @@ TYPED_TEST(Pgm, CanBeMoved) auto copy_coarse = copy->get_coarse_op(); GKO_ASSERT_MTX_NEAR(gko::as(copy_mtx), this->mtx, 0.0); - this->assert_same_agg(copy_agg, this->agg.get_data(), - this->agg.get_num_elems()); + this->assert_same_agg(copy_agg, this->agg.get_data(), this->agg.get_size()); GKO_ASSERT_MTX_NEAR(gko::as(copy_coarse), this->coarse, 0.0); } @@ -241,7 +239,7 @@ TYPED_TEST(Pgm, CanBeCloned) GKO_ASSERT_MTX_NEAR(gko::as(clone_mtx), this->mtx, 0.0); this->assert_same_agg(clone_agg, this->agg.get_data(), - this->agg.get_num_elems()); + this->agg.get_size()); GKO_ASSERT_MTX_NEAR(gko::as(clone_coarse), this->coarse, 0.0); } diff --git a/reference/test/reorder/mc64_kernels.cpp b/reference/test/reorder/mc64_kernels.cpp index a9d2bdc315a..369fb12d506 100644 --- a/reference/test/reorder/mc64_kernels.cpp +++ b/reference/test/reorder/mc64_kernels.cpp @@ -136,8 +136,8 @@ class Mc64 : public ::testing::Test { void assert_array_near(const gko::array& a, const gko::array& b, std::string name) { - ASSERT_EQ(a.get_num_elems(), b.get_num_elems()); - for (gko::size_type i = 0; i < a.get_num_elems(); i++) { + ASSERT_EQ(a.get_size(), b.get_size()); + for (gko::size_type i = 0; i < a.get_size(); i++) { if (std::isfinite(a.get_const_data()[i]) || std::isfinite(b.get_const_data()[i])) { ASSERT_NEAR(a.get_const_data()[i], b.get_const_data()[i], diff --git a/reference/test/solver/batch_bicgstab_kernels.cpp b/reference/test/solver/batch_bicgstab_kernels.cpp index c484b03c852..4a957a9f0fb 100644 --- a/reference/test/solver/batch_bicgstab_kernels.cpp +++ b/reference/test/solver/batch_bicgstab_kernels.cpp @@ -70,7 +70,8 @@ class BatchBicgstab : public ::testing::Test { solve_lambda; }; -TYPED_TEST_SUITE(BatchBicgstab, gko::test::RealValueTypes); +TYPED_TEST_SUITE(BatchBicgstab, gko::test::RealValueTypes, + TypenameNameGenerator); TYPED_TEST(BatchBicgstab, SolvesStencilSystem) diff --git a/reference/test/solver/bicg_kernels.cpp b/reference/test/solver/bicg_kernels.cpp index 0dfe8dafb6f..161be7ea1b2 100644 --- a/reference/test/solver/bicg_kernels.cpp +++ b/reference/test/solver/bicg_kernels.cpp @@ -93,8 +93,7 @@ class Bicg : public ::testing::Test { small_stop = gko::array(exec, small_size[1]); stopped.stop(1); non_stopped.reset(); - std::fill_n(small_stop.get_data(), small_stop.get_num_elems(), - non_stopped); + std::fill_n(small_stop.get_data(), small_stop.get_size(), non_stopped); } std::shared_ptr exec; @@ -141,7 +140,7 @@ TYPED_TEST(Bicg, KernelInitialize) this->small_q2->fill(1); this->small_prev_rho->fill(0); this->small_rho->fill(1); - std::fill_n(this->small_stop.get_data(), this->small_stop.get_num_elems(), + std::fill_n(this->small_stop.get_data(), this->small_stop.get_size(), this->stopped); gko::kernels::reference::bicg::initialize( diff --git a/reference/test/solver/bicgstab_kernels.cpp b/reference/test/solver/bicgstab_kernels.cpp index 7522aa5c20d..688e7ed45dd 100644 --- a/reference/test/solver/bicgstab_kernels.cpp +++ b/reference/test/solver/bicgstab_kernels.cpp @@ -92,8 +92,7 @@ class Bicgstab : public ::testing::Test { stopped.stop(1, false); finalized.stop(1, true); non_stopped.reset(); - std::fill_n(small_stop.get_data(), small_stop.get_num_elems(), - non_stopped); + std::fill_n(small_stop.get_data(), small_stop.get_size(), non_stopped); } std::shared_ptr exec; @@ -145,7 +144,7 @@ TYPED_TEST(Bicgstab, KernelInitialize) this->small_beta->fill(0); this->small_gamma->fill(0); this->small_omega->fill(0); - std::fill_n(this->small_stop.get_data(), this->small_stop.get_num_elems(), + std::fill_n(this->small_stop.get_data(), this->small_stop.get_size(), this->stopped); gko::kernels::reference::bicgstab::initialize( diff --git a/reference/test/solver/cg_kernels.cpp b/reference/test/solver/cg_kernels.cpp index 22e8c0052f3..c4a5e9d9ee1 100644 --- a/reference/test/solver/cg_kernels.cpp +++ b/reference/test/solver/cg_kernels.cpp @@ -85,8 +85,7 @@ class Cg : public ::testing::Test { small_stop = gko::array(exec, small_size[1]); stopped.stop(1); non_stopped.reset(); - std::fill_n(small_stop.get_data(), small_stop.get_num_elems(), - non_stopped); + std::fill_n(small_stop.get_data(), small_stop.get_size(), non_stopped); } std::shared_ptr exec; @@ -123,7 +122,7 @@ TYPED_TEST(Cg, KernelInitialize) this->small_q->fill(1); this->small_prev_rho->fill(0); this->small_rho->fill(1); - std::fill_n(this->small_stop.get_data(), this->small_stop.get_num_elems(), + std::fill_n(this->small_stop.get_data(), this->small_stop.get_size(), this->stopped); gko::kernels::reference::cg::initialize( diff --git a/reference/test/solver/cgs_kernels.cpp b/reference/test/solver/cgs_kernels.cpp index 13ab5b74fcb..59f82b6e59d 100644 --- a/reference/test/solver/cgs_kernels.cpp +++ b/reference/test/solver/cgs_kernels.cpp @@ -92,8 +92,7 @@ class Cgs : public ::testing::Test { small_stop = gko::array(exec, small_size[1]); stopped.stop(1); non_stopped.reset(); - std::fill_n(small_stop.get_data(), small_stop.get_num_elems(), - non_stopped); + std::fill_n(small_stop.get_data(), small_stop.get_size(), non_stopped); } std::shared_ptr exec; @@ -141,7 +140,7 @@ TYPED_TEST(Cgs, KernelInitialize) this->small_t->fill(1); this->small_prev_rho->fill(0); this->small_rho->fill(1); - std::fill_n(this->small_stop.get_data(), this->small_stop.get_num_elems(), + std::fill_n(this->small_stop.get_data(), this->small_stop.get_size(), this->stopped); gko::kernels::reference::cgs::initialize( diff --git a/reference/test/solver/fcg_kernels.cpp b/reference/test/solver/fcg_kernels.cpp index 203a7de76f7..662106423f8 100644 --- a/reference/test/solver/fcg_kernels.cpp +++ b/reference/test/solver/fcg_kernels.cpp @@ -88,8 +88,7 @@ class Fcg : public ::testing::Test { small_stop = gko::array(exec, small_size[1]); stopped.stop(1); non_stopped.reset(); - std::fill_n(small_stop.get_data(), small_stop.get_num_elems(), - non_stopped); + std::fill_n(small_stop.get_data(), small_stop.get_size(), non_stopped); } std::shared_ptr exec; @@ -130,7 +129,7 @@ TYPED_TEST(Fcg, KernelInitialize) this->small_prev_rho->fill(0); this->small_rho->fill(1); this->small_rho_t->fill(0); - std::fill_n(this->small_stop.get_data(), this->small_stop.get_num_elems(), + std::fill_n(this->small_stop.get_data(), this->small_stop.get_size(), this->stopped); gko::kernels::reference::fcg::initialize( diff --git a/reference/test/solver/gcr_kernels.cpp b/reference/test/solver/gcr_kernels.cpp index 51d9991c3cd..3e56cff894f 100644 --- a/reference/test/solver/gcr_kernels.cpp +++ b/reference/test/solver/gcr_kernels.cpp @@ -97,8 +97,7 @@ class Gcr : public ::testing::Test { stopped.converge(1, true); non_stopped.reset(); small_stop = gko::array(exec, small_size[1]); - std::fill_n(small_stop.get_data(), small_stop.get_num_elems(), - non_stopped); + std::fill_n(small_stop.get_data(), small_stop.get_size(), non_stopped); small_final_iter_nums = gko::array(exec, small_size[1]); } @@ -133,7 +132,7 @@ TYPED_TEST(Gcr, KernelInitialize) using T = typename TestFixture::value_type; const T nan = std::numeric_limits>::quiet_NaN(); this->small_residual->fill(nan); - std::fill_n(this->small_stop.get_data(), this->small_stop.get_num_elems(), + std::fill_n(this->small_stop.get_data(), this->small_stop.get_size(), this->stopped); gko::kernels::reference::gcr::initialize(this->exec, this->small_b.get(), @@ -141,7 +140,7 @@ TYPED_TEST(Gcr, KernelInitialize) this->small_stop.get_data()); GKO_ASSERT_MTX_NEAR(this->small_residual, this->small_b, 0); - for (int i = 0; i < this->small_stop.get_num_elems(); ++i) { + for (int i = 0; i < this->small_stop.get_size(); ++i) { ASSERT_EQ(this->small_stop.get_data()[i], this->non_stopped); } } @@ -158,7 +157,7 @@ TYPED_TEST(Gcr, KernelRestart) this->small_krylov_bases_p->fill(nan); this->small_mapped_krylov_bases_Ap->fill(nan); std::fill_n(this->small_final_iter_nums.get_data(), - this->small_final_iter_nums.get_num_elems(), 999); + this->small_final_iter_nums.get_size(), 999); auto expected_p_bases = gko::clone(this->exec, this->small_krylov_bases_p); auto expected_Ap_bases = gko::clone(this->exec, this->small_mapped_krylov_bases_Ap); @@ -179,9 +178,9 @@ TYPED_TEST(Gcr, KernelRestart) this->small_mapped_krylov_bases_Ap.get(), this->small_final_iter_nums.get_data()); - ASSERT_EQ(this->small_final_iter_nums.get_num_elems(), + ASSERT_EQ(this->small_final_iter_nums.get_size(), this->small_residual->get_size()[1]); - for (int i = 0; i < this->small_final_iter_nums.get_num_elems(); ++i) { + for (int i = 0; i < this->small_final_iter_nums.get_size(); ++i) { ASSERT_EQ(this->small_final_iter_nums.get_const_data()[i], 0); } GKO_ASSERT_MTX_NEAR(this->small_krylov_bases_p, this->small_residual, diff --git a/reference/test/solver/gmres_kernels.cpp b/reference/test/solver/gmres_kernels.cpp index 4a43f7ca8af..50e5a670978 100644 --- a/reference/test/solver/gmres_kernels.cpp +++ b/reference/test/solver/gmres_kernels.cpp @@ -112,8 +112,7 @@ class Gmres : public ::testing::Test { stopped.converge(1, true); non_stopped.reset(); small_stop = gko::array(exec, small_size[1]); - std::fill_n(small_stop.get_data(), small_stop.get_num_elems(), - non_stopped); + std::fill_n(small_stop.get_data(), small_stop.get_size(), non_stopped); small_final_iter_nums = gko::array(exec, small_size[1]); } @@ -152,7 +151,7 @@ TYPED_TEST(Gmres, KernelInitialize) this->small_residual->fill(nan); this->small_givens_sin->fill(nan); this->small_givens_cos->fill(nan); - std::fill_n(this->small_stop.get_data(), this->small_stop.get_num_elems(), + std::fill_n(this->small_stop.get_data(), this->small_stop.get_size(), this->stopped); auto expected_sin_cos = Mtx::create(this->exec, this->small_givens_sin->get_size()); @@ -166,7 +165,7 @@ TYPED_TEST(Gmres, KernelInitialize) GKO_ASSERT_MTX_NEAR(this->small_residual, this->small_b, 0); GKO_ASSERT_MTX_NEAR(this->small_givens_sin, expected_sin_cos, 0); GKO_ASSERT_MTX_NEAR(this->small_givens_cos, expected_sin_cos, 0); - for (int i = 0; i < this->small_stop.get_num_elems(); ++i) { + for (int i = 0; i < this->small_stop.get_size(); ++i) { ASSERT_EQ(this->small_stop.get_data()[i], this->non_stopped); } } @@ -183,7 +182,7 @@ TYPED_TEST(Gmres, KernelRestart) this->small_residual_norm_collection->fill(nan); this->small_krylov_bases->fill(9999); std::fill_n(this->small_final_iter_nums.get_data(), - this->small_final_iter_nums.get_num_elems(), 999); + this->small_final_iter_nums.get_size(), 999); auto expected_krylov = gko::clone(this->exec, this->small_krylov_bases); const auto small_size = this->small_residual->get_size(); for (int i = 0; i < small_size[0]; ++i) { @@ -201,9 +200,9 @@ TYPED_TEST(Gmres, KernelRestart) this->small_residual_norm_collection.get(), this->small_krylov_bases.get(), this->small_final_iter_nums.get_data()); - ASSERT_EQ(this->small_final_iter_nums.get_num_elems(), + ASSERT_EQ(this->small_final_iter_nums.get_size(), this->small_residual_norm_collection->get_size()[1]); - for (int i = 0; i < this->small_final_iter_nums.get_num_elems(); ++i) { + for (int i = 0; i < this->small_final_iter_nums.get_size(); ++i) { ASSERT_EQ(this->small_final_iter_nums.get_const_data()[i], 0); ASSERT_EQ(this->small_residual_norm_collection->get_const_values()[i], this->small_residual_norm->get_const_values()[i]); diff --git a/reference/test/solver/ir_kernels.cpp b/reference/test/solver/ir_kernels.cpp index 1c4886b8f9f..dfe9a3bf085 100644 --- a/reference/test/solver/ir_kernels.cpp +++ b/reference/test/solver/ir_kernels.cpp @@ -60,7 +60,7 @@ TYPED_TEST(Ir, KernelInitialize) auto stop = gko::array(this->exec, 2); stopped.stop(1); non_stopped.reset(); - std::fill_n(stop.get_data(), stop.get_num_elems(), non_stopped); + std::fill_n(stop.get_data(), stop.get_size(), non_stopped); gko::kernels::reference::ir::initialize(this->exec, &stop); diff --git a/reference/test/stop/residual_norm_kernels.cpp b/reference/test/stop/residual_norm_kernels.cpp index e35e6dc60d4..c776c720d15 100644 --- a/reference/test/stop/residual_norm_kernels.cpp +++ b/reference/test/stop/residual_norm_kernels.cpp @@ -80,7 +80,7 @@ TYPED_TEST(ResidualNorm, CheckIfResZeroConverges) using Mtx = typename TestFixture::Mtx; using NormVector = typename TestFixture::NormVector; using T = typename TestFixture::ValueType; - using mode = typename gko::stop::mode; + using gko::stop::mode; std::shared_ptr mtx = gko::initialize({1.0}, this->exec_); std::shared_ptr rhs = gko::initialize({0.0}, this->exec_); std::shared_ptr x = gko::initialize({0.0}, this->exec_); @@ -831,7 +831,7 @@ TYPED_TEST(ImplicitResidualNorm, CheckIfResZeroConverges) { using Mtx = typename TestFixture::Mtx; using T = typename TestFixture::ValueType; - using mode = typename gko::stop::mode; + using gko::stop::mode; std::shared_ptr mtx = gko::initialize({1.0}, this->exec_); std::shared_ptr rhs = gko::initialize({0.0}, this->exec_); std::shared_ptr x = gko::initialize({0.0}, this->exec_); diff --git a/test/base/device_matrix_data_kernels.cpp b/test/base/device_matrix_data_kernels.cpp index d273b0b77f6..b05a98d3d9d 100644 --- a/test/base/device_matrix_data_kernels.cpp +++ b/test/base/device_matrix_data_kernels.cpp @@ -53,7 +53,7 @@ class DeviceMatrixData : public CommonTestFixture { gko::zero()); } // remove duplicate nonzero locations - host_data.ensure_row_major_order(); + host_data.sort_row_major(); host_data.nonzeros.erase( std::unique(host_data.nonzeros.begin(), host_data.nonzeros.end(), [](nonzero_type nz1, nonzero_type nz2) { @@ -102,7 +102,7 @@ TYPED_TEST(DeviceMatrixData, DefaultConstructsCorrectly) ASSERT_EQ((gko::dim<2>{0, 0}), local_data.get_size()); ASSERT_EQ(this->exec, local_data.get_executor()); - ASSERT_EQ(local_data.get_num_elems(), 0); + ASSERT_EQ(local_data.get_num_stored_elements(), 0); } @@ -116,7 +116,7 @@ TYPED_TEST(DeviceMatrixData, ConstructsCorrectly) ASSERT_EQ((gko::dim<2>{4, 3}), local_data.get_size()); ASSERT_EQ(this->exec, local_data.get_executor()); - ASSERT_EQ(local_data.get_num_elems(), 10); + ASSERT_EQ(local_data.get_num_stored_elements(), 10); } @@ -132,7 +132,8 @@ TYPED_TEST(DeviceMatrixData, CopyConstructsOnOtherExecutorCorrectly) this->exec->get_master(), device_data}; ASSERT_EQ(device_data.get_size(), host_data.get_size()); - ASSERT_EQ(device_data.get_num_elems(), host_data.get_num_elems()); + ASSERT_EQ(device_data.get_num_stored_elements(), + host_data.get_num_stored_elements()); auto device_arrays = device_data.empty_out(); auto host_arrays = host_data.empty_out(); GKO_ASSERT_ARRAY_EQ(device_arrays.row_idxs, host_arrays.row_idxs); @@ -156,7 +157,7 @@ TYPED_TEST(DeviceMatrixData, ResizesCorrectly) local_data.resize_and_reset(12); - ASSERT_EQ(local_data.get_num_elems(), 12); + ASSERT_EQ(local_data.get_num_stored_elements(), 12); ASSERT_EQ(local_data.get_size(), gko::dim<2>(4, 3)); } @@ -170,7 +171,7 @@ TYPED_TEST(DeviceMatrixData, ResizesDimensionsCorrectly) local_data.resize_and_reset(gko::dim<2>{5, 4}, 12); - ASSERT_EQ(local_data.get_num_elems(), 12); + ASSERT_EQ(local_data.get_num_stored_elements(), 12); ASSERT_EQ(local_data.get_size(), gko::dim<2>(5, 4)); } @@ -187,7 +188,7 @@ TYPED_TEST(DeviceMatrixData, CreatesFromHost) ASSERT_EQ(data.get_size(), this->host_data.size); auto host_device_data = gko::device_matrix_data( this->exec->get_master(), data); - for (gko::size_type i = 0; i < data.get_num_elems(); i++) { + for (gko::size_type i = 0; i < data.get_num_stored_elements(); i++) { const auto entry = this->host_data.nonzeros[i]; ASSERT_EQ(host_device_data.get_const_row_idxs()[i], entry.row); ASSERT_EQ(host_device_data.get_const_col_idxs()[i], entry.column); @@ -210,7 +211,7 @@ TYPED_TEST(DeviceMatrixData, EmptiesOut) auto arrays = data.empty_out(); ASSERT_EQ(data.get_size(), gko::dim<2>{}); - ASSERT_EQ(data.get_num_elems(), 0); + ASSERT_EQ(data.get_num_stored_elements(), 0); ASSERT_NE(data.get_const_row_idxs(), original_ptr1); ASSERT_NE(data.get_const_col_idxs(), original_ptr2); ASSERT_NE(data.get_const_values(), original_ptr3); @@ -220,7 +221,7 @@ TYPED_TEST(DeviceMatrixData, EmptiesOut) arrays.row_idxs.set_executor(this->exec->get_master()); arrays.col_idxs.set_executor(this->exec->get_master()); arrays.values.set_executor(this->exec->get_master()); - for (gko::size_type i = 0; i < arrays.values.get_num_elems(); i++) { + for (gko::size_type i = 0; i < arrays.values.get_size(); i++) { const auto entry = this->host_data.nonzeros[i]; ASSERT_EQ(arrays.row_idxs.get_const_data()[i], entry.row); ASSERT_EQ(arrays.col_idxs.get_const_data()[i], entry.column); @@ -318,7 +319,7 @@ TYPED_TEST(DeviceMatrixData, SumsDuplicates) GKO_ASSERT_ARRAY_EQ(arrays.col_idxs, ref_arrays.col_idxs); double max_error{}; arrays.values.set_executor(this->exec->get_master()); - for (int i = 0; i < arrays.values.get_num_elems(); i++) { + for (int i = 0; i < arrays.values.get_size(); i++) { max_error = std::max( max_error, std::abs(arrays.values.get_const_data()[i] - ref_arrays.values.get_const_data()[i])); diff --git a/test/base/kernel_launch_generic.cpp b/test/base/kernel_launch_generic.cpp index ccbc172d423..ae64e3d4190 100644 --- a/test/base/kernel_launch_generic.cpp +++ b/test/base/kernel_launch_generic.cpp @@ -120,7 +120,7 @@ void run1d(std::shared_ptr exec, size_type dim, int* data) TEST_F(KernelLaunch, Runs1D) { - run1d(exec, zero_array.get_num_elems(), zero_array.get_data()); + run1d(exec, zero_array.get_size(), zero_array.get_data()); GKO_ASSERT_ARRAY_EQ(zero_array, iota_array); } @@ -141,7 +141,7 @@ void run1d(std::shared_ptr exec, gko::array& data) d[i] = 0; } }, - data.get_num_elems(), data, data.get_const_data(), move_only_val); + data.get_size(), data, data.get_const_data(), move_only_val); } TEST_F(KernelLaunch, Runs1DArray) @@ -354,7 +354,7 @@ void run1d_reduction_cached(std::shared_ptr exec, static_cast(size)); // The temporary storage (used for partial sums) must be smaller than // the input array - ASSERT_LE(temp.get_num_elems(), size * sizeof(int64)); + ASSERT_LE(temp.get_size(), size * sizeof(int64)); } } @@ -449,7 +449,7 @@ void run2d_reduction_cached(std::shared_ptr exec, static_cast(dim[0] + dim[1])); // The temporary storage (used for partial sums) must be smaller than // the input array - ASSERT_LE(temp.get_num_elems(), dim[0] * dim[1] * sizeof(int64)); + ASSERT_LE(temp.get_size(), dim[0] * dim[1] * sizeof(int64)); } } @@ -528,7 +528,7 @@ void run2d_row_reduction_cached(std::shared_ptr exec, gko::array host_ref{exec->get_master(), dim[0]}; gko::array output{exec, host_ref}; temp.clear(); - for (int64 i = 0; i < host_ref.get_num_elems(); ++i) { + for (int64 i = 0; i < host_ref.get_size(); ++i) { host_ref.get_data()[i] = dim[1] + i + 1; } @@ -541,7 +541,7 @@ void run2d_row_reduction_cached(std::shared_ptr exec, GKO_ASSERT_ARRAY_EQ(host_ref, output); // The temporary storage (used for partial sums) must be smaller than // the input array - ASSERT_LE(temp.get_num_elems(), dim[0] * dim[1] * sizeof(int64)); + ASSERT_LE(temp.get_size(), dim[0] * dim[1] * sizeof(int64)); } } @@ -621,7 +621,7 @@ void run2d_col_reduction_cached(std::shared_ptr exec, gko::array host_ref{exec->get_master(), dim[1]}; gko::array output{exec, host_ref}; temp.clear(); - for (int64 i = 0; i < host_ref.get_num_elems(); ++i) { + for (int64 i = 0; i < host_ref.get_size(); ++i) { host_ref.get_data()[i] = dim[0] + i + 1; } @@ -632,7 +632,7 @@ void run2d_col_reduction_cached(std::shared_ptr exec, dim, temp); GKO_ASSERT_ARRAY_EQ(host_ref, output); - ASSERT_LE(temp.get_num_elems(), dim[0] * dim[1] * sizeof(int64)); + ASSERT_LE(temp.get_size(), dim[0] * dim[1] * sizeof(int64)); } } diff --git a/test/components/format_conversion_kernels.cpp b/test/components/format_conversion_kernels.cpp index 07e7a969787..21fb2f09d81 100644 --- a/test/components/format_conversion_kernels.cpp +++ b/test/components/format_conversion_kernels.cpp @@ -103,7 +103,7 @@ TYPED_TEST(FormatConversion, ConvertIdxsToPtrsIsEquivalentToRef) this->ptrs.fill(-1); gko::kernels::EXEC_NAMESPACE::components::convert_idxs_to_ptrs( - this->exec, this->idxs.get_const_data(), this->idxs.get_num_elems(), + this->exec, this->idxs.get_const_data(), this->idxs.get_size(), this->size, this->ptrs.get_data()); GKO_ASSERT_ARRAY_EQ(this->ptrs, ref_ptrs); diff --git a/test/components/prefix_sum_kernels.cpp b/test/components/prefix_sum_kernels.cpp index a2400f30e7c..71d69cc4bc8 100644 --- a/test/components/prefix_sum_kernels.cpp +++ b/test/components/prefix_sum_kernels.cpp @@ -75,7 +75,7 @@ TYPED_TEST(PrefixSum, WorksCloseToOverflow) gko::array data{this->exec, I({max - 1, 1, 0})}; gko::kernels::EXEC_NAMESPACE::components::prefix_sum_nonnegative( - this->exec, data.get_data(), data.get_num_elems()); + this->exec, data.get_data(), data.get_size()); GKO_ASSERT_ARRAY_EQ(data, I({0, max - 1, max})); } @@ -87,7 +87,7 @@ TYPED_TEST(PrefixSum, DoesntOverflowFromLastElement) gko::array data{this->exec, I({2, max - 1})}; gko::kernels::EXEC_NAMESPACE::components::prefix_sum_nonnegative( - this->exec, data.get_data(), data.get_num_elems()); + this->exec, data.get_data(), data.get_size()); GKO_ASSERT_ARRAY_EQ(data, I({0, 2})); } @@ -104,7 +104,7 @@ TYPED_TEST(PrefixSum, ThrowsOnOverflow) ASSERT_THROW( gko::kernels::EXEC_NAMESPACE::components::prefix_sum_nonnegative( - this->exec, data.get_data(), data.get_num_elems()), + this->exec, data.get_data(), data.get_size()), gko::OverflowError); } diff --git a/test/distributed/vector_kernels.cpp b/test/distributed/vector_kernels.cpp index 2946210b59d..918da81fd9e 100644 --- a/test/distributed/vector_kernels.cpp +++ b/test/distributed/vector_kernels.cpp @@ -86,7 +86,7 @@ gko::device_matrix_data generate_random_matrix_data_array( num_rows, num_cols, std::forward(nonzero_dist), std::forward(value_dist), std::forward(engine)); - md.ensure_row_major_order(); + md.sort_row_major(); return gko::device_matrix_data::create_from_host(exec, md); } diff --git a/test/factorization/cholesky_kernels.cpp b/test/factorization/cholesky_kernels.cpp index 02632c24f20..056f4862427 100644 --- a/test/factorization/cholesky_kernels.cpp +++ b/test/factorization/cholesky_kernels.cpp @@ -283,7 +283,7 @@ class Cholesky : public CommonTestFixture { // add missing upper diagonal entries // (values not important, only pattern important) gko::utils::make_symmetric(mtx_chol_data); - mtx_chol_data.ensure_row_major_order(); + mtx_chol_data.sort_row_major(); mtx_chol = matrix_type::create(ref); mtx_chol->read(mtx_chol_data); storage_offsets.resize_and_reset(num_rows + 1); diff --git a/test/matrix/csr_kernels.cpp b/test/matrix/csr_kernels.cpp index f54b64f2a81..10110b1db43 100644 --- a/test/matrix/csr_kernels.cpp +++ b/test/matrix/csr_kernels.cpp @@ -106,7 +106,7 @@ class CsrLookup : public CommonTestFixture { data.nonzeros.emplace_back(221, i + 100, 1.0); data.nonzeros.emplace_back(421, i * 3 + 100, 2.0); } - data.ensure_row_major_order(); + data.sort_row_major(); // initialize the matrices mtx = Mtx::create(ref); mtx->read(data); diff --git a/test/matrix/csr_kernels2.cpp b/test/matrix/csr_kernels2.cpp index 523cc460978..39fe28113fd 100644 --- a/test/matrix/csr_kernels2.cpp +++ b/test/matrix/csr_kernels2.cpp @@ -1348,7 +1348,7 @@ TEST_F(Csr, ComputeSubmatrixIsEquivalentToRef) gko::kernels::reference::csr::calculate_nonzeros_per_row_in_span( this->ref, this->mtx2.get(), rspan, cspan, &row_nnz); gko::kernels::reference::components::prefix_sum_nonnegative( - this->ref, row_nnz.get_data(), row_nnz.get_num_elems()); + this->ref, row_nnz.get_data(), row_nnz.get_size()); auto num_nnz = row_nnz.get_data()[rspan.length()]; auto drow_nnz = gko::array(this->exec, row_nnz); auto smat1 = @@ -1385,7 +1385,7 @@ TEST_F(Csr, CalculateNnzPerRowInIndexSetIsEquivalentToRef) {42, 22, 24, 26, 28, 30, 81, 82, 83, 88}}; gko::index_set drset(this->exec, rset); gko::index_set dcset(this->exec, cset); - auto row_nnz = gko::array(this->ref, rset.get_num_elems() + 1); + auto row_nnz = gko::array(this->ref, rset.get_size() + 1); row_nnz.fill(gko::zero()); auto drow_nnz = gko::array(this->exec, row_nnz); @@ -1408,24 +1408,24 @@ TEST_F(Csr, ComputeSubmatrixFromIndexSetIsEquivalentToRef) {42, 22, 24, 26, 28, 30, 81, 82, 83, 88}}; gko::index_set drset(this->exec, rset); gko::index_set dcset(this->exec, cset); - auto row_nnz = gko::array(this->ref, rset.get_num_elems() + 1); + auto row_nnz = gko::array(this->ref, rset.get_size() + 1); row_nnz.fill(gko::zero()); gko::kernels::reference::csr::calculate_nonzeros_per_row_in_index_set( this->ref, this->mtx2.get(), rset, cset, row_nnz.get_data()); gko::kernels::reference::components::prefix_sum_nonnegative( - this->ref, row_nnz.get_data(), row_nnz.get_num_elems()); - auto num_nnz = row_nnz.get_data()[rset.get_num_elems()]; + this->ref, row_nnz.get_data(), row_nnz.get_size()); + auto num_nnz = row_nnz.get_data()[rset.get_size()]; auto drow_nnz = gko::array(this->exec, row_nnz); - auto smat1 = Mtx::create( - this->ref, gko::dim<2>(rset.get_num_elems(), cset.get_num_elems()), - std::move(gko::array(this->ref, num_nnz)), - std::move(gko::array(this->ref, num_nnz)), - std::move(row_nnz)); - auto sdmat1 = Mtx::create( - this->exec, gko::dim<2>(rset.get_num_elems(), cset.get_num_elems()), - std::move(gko::array(this->exec, num_nnz)), - std::move(gko::array(this->exec, num_nnz)), - std::move(drow_nnz)); + auto smat1 = + Mtx::create(this->ref, gko::dim<2>(rset.get_size(), cset.get_size()), + std::move(gko::array(this->ref, num_nnz)), + std::move(gko::array(this->ref, num_nnz)), + std::move(row_nnz)); + auto sdmat1 = + Mtx::create(this->exec, gko::dim<2>(rset.get_size(), cset.get_size()), + std::move(gko::array(this->exec, num_nnz)), + std::move(gko::array(this->exec, num_nnz)), + std::move(drow_nnz)); gko::kernels::reference::csr::compute_submatrix_from_index_set( this->ref, this->mtx2.get(), rset, cset, smat1.get()); diff --git a/test/matrix/dense_kernels.cpp b/test/matrix/dense_kernels.cpp index d04c2df177f..6659bd15cfe 100644 --- a/test/matrix/dense_kernels.cpp +++ b/test/matrix/dense_kernels.cpp @@ -607,7 +607,7 @@ TEST_F(Dense, CalculateNNZPerRowIsEquivalentToRef) exec, dx.get(), dnnz_per_row.get_data()); auto tmp = gko::array(ref, dnnz_per_row); - for (gko::size_type i = 0; i < nnz_per_row.get_num_elems(); i++) { + for (gko::size_type i = 0; i < nnz_per_row.get_size(); i++) { ASSERT_EQ(nnz_per_row.get_const_data()[i], tmp.get_const_data()[i]); } } @@ -1204,7 +1204,7 @@ TEST_F(Dense, CanGatherRowsIntoDenseCrossExecutor) auto sub_x = x->create_submatrix(row_span, col_span); auto sub_dx = dx->create_submatrix(row_span, col_span); auto gather_size = - gko::dim<2>{rgather_idxs->get_num_elems(), sub_x->get_size()[1]}; + gko::dim<2>{rgather_idxs->get_size(), sub_x->get_size()[1]}; auto r_gather = Mtx::create(ref, gather_size); // test make_temporary_clone and non-default stride auto dr_gather = Mtx::create(ref, gather_size, sub_x->get_size()[1] + 2); @@ -1224,7 +1224,7 @@ TEST_F(Dense, CanAdvancedGatherRowsIntoDenseCrossExecutor) auto sub_x = x->create_submatrix(row_span, col_span); auto sub_dx = dx->create_submatrix(row_span, col_span); auto gather_size = - gko::dim<2>{rgather_idxs->get_num_elems(), sub_x->get_size()[1]}; + gko::dim<2>{rgather_idxs->get_size(), sub_x->get_size()[1]}; auto r_gather = gen_mtx(gather_size[0], gather_size[1]); // test make_temporary_clone and non-default stride auto dr_gather = Mtx::create(ref, gather_size, sub_x->get_size()[1] + 2); @@ -1245,7 +1245,7 @@ TEST_F(Dense, CanGatherRowsIntoMixedDenseCrossExecutor) auto sub_x = x->create_submatrix(row_span, col_span); auto sub_dx = dx->create_submatrix(row_span, col_span); auto gather_size = - gko::dim<2>{rgather_idxs->get_num_elems(), sub_x->get_size()[1]}; + gko::dim<2>{rgather_idxs->get_size(), sub_x->get_size()[1]}; auto r_gather = MixedMtx::create(ref, gather_size); // test make_temporary_clone and non-default stride auto dr_gather = @@ -1266,7 +1266,7 @@ TEST_F(Dense, CanAdvancedGatherRowsIntoMixedDenseCrossExecutor) auto sub_x = x->create_submatrix(row_span, col_span); auto sub_dx = dx->create_submatrix(row_span, col_span); auto gather_size = - gko::dim<2>{rgather_idxs->get_num_elems(), sub_x->get_size()[1]}; + gko::dim<2>{rgather_idxs->get_size(), sub_x->get_size()[1]}; auto r_gather = gen_mtx(gather_size[0], gather_size[1]); // test make_temporary_clone and non-default stride auto dr_gather = diff --git a/test/matrix/matrix.cpp b/test/matrix/matrix.cpp index 365fd84dd04..f8e4ed99a60 100644 --- a/test/matrix/matrix.cpp +++ b/test/matrix/matrix.cpp @@ -1234,7 +1234,7 @@ TYPED_TEST(Matrix, DeviceReadMoveIsEquivalentToHostRef) dev_result->read(std::move(ref_device_data)); ASSERT_EQ(ref_device_data.get_size(), gko::dim<2>{}); - ASSERT_EQ(ref_device_data.get_num_elems(), 0); + ASSERT_EQ(ref_device_data.get_num_stored_elements(), 0); GKO_ASSERT_MTX_NEAR(ref_result, dev_result, 0.0); GKO_ASSERT_MTX_EQ_SPARSITY(ref_result, dev_result); }); diff --git a/test/mpi/partition_helpers.cpp b/test/mpi/partition_helpers.cpp index 2d53fbc0ec8..66caaf3bedc 100644 --- a/test/mpi/partition_helpers.cpp +++ b/test/mpi/partition_helpers.cpp @@ -37,12 +37,11 @@ TYPED_TEST(PartitionHelpers, CanBuildFromLocalRanges) GKO_ASSERT_ARRAY_EQ( expects_ranges, - gko::make_const_array_view(this->exec, expects_ranges.get_num_elems(), + gko::make_const_array_view(this->exec, expects_ranges.get_size(), part->get_range_bounds())); - GKO_ASSERT_ARRAY_EQ( - expects_pid, - gko::make_const_array_view(this->exec, expects_pid.get_num_elems(), - part->get_part_ids())); + GKO_ASSERT_ARRAY_EQ(expects_pid, gko::make_const_array_view( + this->exec, expects_pid.get_size(), + part->get_part_ids())); } @@ -60,12 +59,11 @@ TYPED_TEST(PartitionHelpers, CanBuildFromLocalRangesUnsorted) GKO_ASSERT_ARRAY_EQ( expects_ranges, - gko::make_const_array_view(this->exec, expects_ranges.get_num_elems(), + gko::make_const_array_view(this->exec, expects_ranges.get_size(), part->get_range_bounds())); - GKO_ASSERT_ARRAY_EQ( - expects_pid, - gko::make_const_array_view(this->exec, expects_pid.get_num_elems(), - part->get_part_ids())); + GKO_ASSERT_ARRAY_EQ(expects_pid, gko::make_const_array_view( + this->exec, expects_pid.get_size(), + part->get_part_ids())); } @@ -98,10 +96,9 @@ TYPED_TEST(PartitionHelpers, CanBuildFromLocalSize) GKO_ASSERT_ARRAY_EQ( expects_ranges, - gko::make_const_array_view(this->exec, expects_ranges.get_num_elems(), + gko::make_const_array_view(this->exec, expects_ranges.get_size(), part->get_range_bounds())); - GKO_ASSERT_ARRAY_EQ( - expects_pid, - gko::make_const_array_view(this->exec, expects_pid.get_num_elems(), - part->get_part_ids())); + GKO_ASSERT_ARRAY_EQ(expects_pid, gko::make_const_array_view( + this->exec, expects_pid.get_size(), + part->get_part_ids())); } diff --git a/test/preconditioner/jacobi_kernels.cpp b/test/preconditioner/jacobi_kernels.cpp index 0bbc018837e..cac40c3385c 100644 --- a/test/preconditioner/jacobi_kernels.cpp +++ b/test/preconditioner/jacobi_kernels.cpp @@ -55,7 +55,7 @@ class Jacobi : public CommonTestFixture { } gko::array block_ptrs(ref, block_pointers); gko::array block_prec(ref, block_precisions); - if (block_prec.get_num_elems() == 0) { + if (block_prec.get_size() == 0) { bj_factory = Bj::build() .with_max_block_size(max_block_size) diff --git a/test/solver/bicg_kernels.cpp b/test/solver/bicg_kernels.cpp index b2baa36927a..acc4d941daf 100644 --- a/test/solver/bicg_kernels.cpp +++ b/test/solver/bicg_kernels.cpp @@ -73,7 +73,7 @@ class Bicg : public CommonTestFixture { prev_rho->at(2) = 0.0; stop_status = std::make_unique>(ref, n); - for (size_t i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status->get_size(); ++i) { stop_status->get_data()[i].reset(); } // check correct handling for stopped columns diff --git a/test/solver/cb_gmres_kernels.cpp b/test/solver/cb_gmres_kernels.cpp index 4b92dd23b5b..34dccba365b 100644 --- a/test/solver/cb_gmres_kernels.cpp +++ b/test/solver/cb_gmres_kernels.cpp @@ -59,8 +59,8 @@ class CbGmres : public CommonTestFixture { std::uniform_int_distribution(num_cols, num_cols), std::normal_distribution(-1.0, 1.0), rand_engine, ref); - std::copy_n(temp_krylov_bases->get_const_values(), - bases.get_num_elems(), bases.get_data()); + std::copy_n(temp_krylov_bases->get_const_values(), bases.get_size(), + bases.get_data()); // Only useful when the Accessor actually has a scale auto range = helper.get_range(); auto dist = std::normal_distribution(-1, 1); @@ -101,20 +101,20 @@ class CbGmres : public CommonTestFixture { givens_cos = gen_mtx(default_krylov_dim_mixed, n); stop_status = std::make_unique>(ref, n); - for (size_t i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status->get_size(); ++i) { stop_status->get_data()[i].reset(); } reorth_status = std::make_unique>(ref, n); - for (size_t i = 0; i < reorth_status->get_num_elems(); ++i) { + for (size_t i = 0; i < reorth_status->get_size(); ++i) { reorth_status->get_data()[i].reset(); } final_iter_nums = std::make_unique>(ref, n); - for (size_t i = 0; i < final_iter_nums->get_num_elems(); ++i) { + for (size_t i = 0; i < final_iter_nums->get_size(); ++i) { final_iter_nums->get_data()[i] = 5; } num_reorth = std::make_unique>(ref, n); - for (size_t i = 0; i < num_reorth->get_num_elems(); ++i) { + for (size_t i = 0; i < num_reorth->get_size(); ++i) { num_reorth->get_data()[i] = 5; } @@ -151,7 +151,7 @@ class CbGmres : public CommonTestFixture { d_to_host = d_range_helper.get_bases(); const auto tolerance = r::value; using std::abs; - for (gko::size_type i = 0; i < krylov_bases.get_num_elems(); ++i) { + for (gko::size_type i = 0; i < krylov_bases.get_size(); ++i) { const auto ref_value = krylov_bases.get_const_data()[i]; const auto dev_value = d_to_host.get_const_data()[i]; ASSERT_LE(abs(dev_value - ref_value), tolerance); diff --git a/test/solver/cg_kernels.cpp b/test/solver/cg_kernels.cpp index 9437675328f..d05ab7c9afc 100644 --- a/test/solver/cg_kernels.cpp +++ b/test/solver/cg_kernels.cpp @@ -62,7 +62,7 @@ class Cg : public CommonTestFixture { prev_rho->at(2) = 0.0; stop_status = std::make_unique>(ref, n); - for (size_t i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status->get_size(); ++i) { stop_status->get_data()[i].reset(); } // check correct handling for stopped columns diff --git a/test/solver/cgs_kernels.cpp b/test/solver/cgs_kernels.cpp index fa947e53e22..61ba0abc997 100644 --- a/test/solver/cgs_kernels.cpp +++ b/test/solver/cgs_kernels.cpp @@ -91,7 +91,7 @@ class Cgs : public CommonTestFixture { rho_prev->at(2) = 0.0; stop_status = std::make_unique>(ref, n); - for (size_t i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status->get_size(); ++i) { stop_status->get_data()[i].reset(); } // check correct handling for stopped columns diff --git a/test/solver/fcg_kernels.cpp b/test/solver/fcg_kernels.cpp index 7e9d697690a..5e50efbbd2d 100644 --- a/test/solver/fcg_kernels.cpp +++ b/test/solver/fcg_kernels.cpp @@ -64,7 +64,7 @@ class Fcg : public CommonTestFixture { prev_rho->at(2) = 0.0; stop_status = std::make_unique>(ref, n); - for (size_t i = 0; i < stop_status->get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status->get_size(); ++i) { stop_status->get_data()[i].reset(); } // check correct handling for stopped columns diff --git a/test/solver/gcr_kernels.cpp b/test/solver/gcr_kernels.cpp index 4a3658e88e0..4326823ddbe 100644 --- a/test/solver/gcr_kernels.cpp +++ b/test/solver/gcr_kernels.cpp @@ -89,11 +89,11 @@ class Gcr : public CommonTestFixture { stop_status = gko::array(ref, nrhs); - for (size_t i = 0; i < stop_status.get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status.get_size(); ++i) { stop_status.get_data()[i].reset(); } final_iter_nums = gko::array(ref, nrhs); - for (size_t i = 0; i < final_iter_nums.get_num_elems(); ++i) { + for (size_t i = 0; i < final_iter_nums.get_size(); ++i) { final_iter_nums.get_data()[i] = 5; } diff --git a/test/solver/gmres_kernels.cpp b/test/solver/gmres_kernels.cpp index a84aafaf8de..128747ecb56 100644 --- a/test/solver/gmres_kernels.cpp +++ b/test/solver/gmres_kernels.cpp @@ -89,11 +89,11 @@ class Gmres : public CommonTestFixture { givens_sin = gen_mtx(gko::solver::gmres_default_krylov_dim, nrhs); givens_cos = gen_mtx(gko::solver::gmres_default_krylov_dim, nrhs); stop_status = gko::array(ref, nrhs); - for (size_t i = 0; i < stop_status.get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status.get_size(); ++i) { stop_status.get_data()[i].reset(); } final_iter_nums = gko::array(ref, nrhs); - for (size_t i = 0; i < final_iter_nums.get_num_elems(); ++i) { + for (size_t i = 0; i < final_iter_nums.get_size(); ++i) { final_iter_nums.get_data()[i] = 5; } diff --git a/test/solver/ir_kernels.cpp b/test/solver/ir_kernels.cpp index 0a5f2d3962f..6e7fb274cf3 100644 --- a/test/solver/ir_kernels.cpp +++ b/test/solver/ir_kernels.cpp @@ -49,7 +49,7 @@ class Ir : public CommonTestFixture { TEST_F(Ir, InitializeIsEquivalentToRef) { auto stop_status = gko::array(ref, 43); - for (size_t i = 0; i < stop_status.get_num_elems(); ++i) { + for (size_t i = 0; i < stop_status.get_size(); ++i) { stop_status.get_data()[i].reset(); } auto d_stop_status = gko::array(exec, stop_status); @@ -58,7 +58,7 @@ TEST_F(Ir, InitializeIsEquivalentToRef) gko::kernels::EXEC_NAMESPACE::ir::initialize(exec, &d_stop_status); auto tmp = gko::array(ref, d_stop_status); - for (int i = 0; i < stop_status.get_num_elems(); ++i) { + for (int i = 0; i < stop_status.get_size(); ++i) { ASSERT_EQ(stop_status.get_const_data()[i], tmp.get_const_data()[i]); } } diff --git a/test/stop/residual_norm_kernels.cpp b/test/stop/residual_norm_kernels.cpp index 56a078d2b0b..385ea63dba1 100644 --- a/test/stop/residual_norm_kernels.cpp +++ b/test/stop/residual_norm_kernels.cpp @@ -550,7 +550,7 @@ TYPED_TEST(ImplicitResidualNorm, CheckIfResZeroConverges) { using Mtx = typename TestFixture::Mtx; using T = typename TestFixture::ValueType; - using mode = typename gko::stop::mode; + using gko::stop::mode; std::shared_ptr mtx = gko::initialize({1.0}, this->exec); std::shared_ptr rhs = gko::initialize({0.0}, this->exec); std::shared_ptr x = gko::initialize({0.0}, this->exec);