Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various small tdb matrix cleanups #510

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/include/detail/linalg/tdb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ class tdbBlockedMatrix : public MatrixBase {
index_type last_row_;
index_type first_col_;
index_type last_col_;

// The columns loaded into memory. Except for the last (remainder) block,
// this range will be equal to `load_blocksize_`.
index_type first_resident_col_;
index_type last_resident_col_;

// The number of columns loaded into memory. Except for the last (remainder)
// block, this will be equal to `blocksize_`.
index_type num_resident_cols_{0};

// How many columns to load at a time
index_type load_blocksize_{0};

Expand Down Expand Up @@ -234,21 +233,14 @@ class tdbBlockedMatrix : public MatrixBase {

auto cell_order = schema_.cell_order();
auto tile_order = schema_.tile_order();

if ((matrix_order_ == TILEDB_ROW_MAJOR && cell_order == TILEDB_COL_MAJOR) ||
(matrix_order_ == TILEDB_COL_MAJOR && cell_order == TILEDB_ROW_MAJOR)) {
throw std::runtime_error("Cell order and matrix order must match");
}

if (cell_order != tile_order) {
throw std::runtime_error("Cell order and tile order must match");
}

auto domain_{schema_.domain()};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is domain_ not required in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep correct, it's not used.


auto row_domain{domain_.dimension(0)};
auto col_domain{domain_.dimension(1)};

// If non_empty_domain() is an empty vector it means that
// the array is empty. Else If the user specifies a value then we use it,
// otherwise we use the non-empty domain.
Expand Down
6 changes: 3 additions & 3 deletions src/include/detail/linalg/tdb_matrix_with_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class tdbBlockedMatrixWithIds

/**
* @brief Construct a new tdbBlockedMatrixWithIds object, limited to
* `upper_bound` vectors. In this case, the `Matrix` is row-major, so the
* number of vectors is the number of rows.
* `upper_bound` vectors. In this case, the `Matrix` is column-major, so the
* number of vectors is the number of columns.
*
* @param ctx The TileDB context to use.
* @param uri URI of the TileDB array to read.
Expand Down Expand Up @@ -142,7 +142,7 @@ class tdbBlockedMatrixWithIds
size_t first_col,
std::optional<size_t> last_col,
size_t upper_bound,
TemporalPolicy temporal_policy) // noexcept
TemporalPolicy temporal_policy)
requires(std::is_same_v<LayoutPolicy, stdx::layout_left>)
: Base(
ctx,
Expand Down
9 changes: 3 additions & 6 deletions src/include/detail/linalg/tdb_partitioned_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,13 @@ class tdbPartitionedMatrix

auto cell_order = partitioned_vectors_schema_.cell_order();
auto tile_order = partitioned_vectors_schema_.tile_order();

if (cell_order != tile_order) {
throw std::runtime_error("Cell order and tile order must match");
}

auto domain_{partitioned_vectors_schema_.domain()};

auto array_rows{domain_.dimension(0)};
auto array_cols{domain_.dimension(1)};

dimensions_ =
(array_rows.template domain<row_domain_type>().second -
array_rows.template domain<row_domain_type>().first + 1);
Expand Down Expand Up @@ -622,10 +619,10 @@ class tdbPartitionedMatrix
}

void debug_tdb_partitioned_matrix(
const std::string& msg, size_t max_size = 10) {
const std::string& msg, size_t max_size = 10) const {
debug_partitioned_matrix(*this, msg, max_size);
debug_vector(master_indices_, "# master_indices_", max_size);
debug_vector(relevant_parts_, "# relevant_parts_", max_size);
debug_vector(master_indices_, "# master_indices_ ", max_size);
debug_vector(relevant_parts_, "# relevant_parts_ ", max_size);
debug_vector(squashed_indices_, "# squashed_indices_", max_size);
std::cout << "# total_num_parts_: " << total_num_parts_ << std::endl;
std::cout << "# last_resident_part_: " << last_resident_part_ << std::endl;
Expand Down
Loading