Skip to content

Commit 64e8893

Browse files
committed
[Code] Fixes:
- Core object marker logic - Sub-vector extraction (fix indices numeration) - Cuda matrix^t to vec reduce fixes
1 parent 24ba646 commit 64e8893

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

cubool/sources/core/matrix.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ namespace cubool {
4040
Matrix::Matrix(size_t nrows, size_t ncols, BackendBase &backend) {
4141
mHnd = backend.createMatrix(nrows, ncols);
4242
mProvider = &backend;
43-
44-
// By default marker is the address of the matrix
45-
std::stringstream s;
46-
s << this;
47-
mMarker = s.str();
4843
}
4944

5045
Matrix::~Matrix() {

cubool/sources/core/object.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727

2828
namespace cubool {
2929

30+
Object::Object() {
31+
// By default marker is the address of the object
32+
std::stringstream s;
33+
s << this;
34+
mMarker = s.str();
35+
}
36+
3037
void Object::setDebugMarker(const char *marker) {
3138
CHECK_RAISE_ERROR(marker, InvalidArgument, "Null pointer marker string");
3239

cubool/sources/core/object.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace cubool {
3232

3333
class Object {
3434
public:
35+
Object();
3536
void setDebugMarker(const char* marker);
3637
const char* getDebugMarker() const;
3738
index getDebugMarkerSizeWithNullT() const;

cubool/sources/core/vector.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ namespace cubool {
4040
Vector::Vector(size_t nrows, BackendBase &backend) {
4141
mHnd = backend.createVector(nrows);
4242
mProvider = &backend;
43-
44-
// By default marker is the address of the vector
45-
std::stringstream s;
46-
s << this;
47-
mMarker = s.str();
4843
}
4944

5045
Vector::~Vector() {

cubool/sources/core/vector.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ namespace cubool {
6565
// Cached values by the set functions
6666
mutable std::vector<index> mCachedI;
6767

68-
// Marker for debugging
69-
std::string mMarker;
70-
7168
// Implementation handle references
7269
VectorBase* mHnd = nullptr;
7370
BackendBase* mProvider = nullptr;

cubool/sources/cuda/cuda_vector.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ namespace cubool {
124124
index firstToCopy = region.front();
125125

126126
VectorImplType::container_type result(resultSize);
127-
thrust::copy(vec.m_rows_index.begin() + firstToCopy, vec.m_rows_index.begin() + firstToCopy + resultSize,
128-
result.begin());
127+
thrust::transform(vec.m_rows_index.begin() + firstToCopy, vec.m_rows_index.begin() + firstToCopy + resultSize,result.begin(),
128+
[i]__device__(index id) { return id - i; });
129129

130130
// Update this impl data
131131
mVectorImpl = std::move(VectorImplType(std::move(result), nrows, resultSize));

cubool/sources/sequential/sq_subvector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace cubool {
4848

4949
for (auto v: a.indices) {
5050
if (first <= v && v < last) {
51-
out.indices.push_back(v);
51+
out.indices.push_back(v - i);
5252
}
5353
}
5454
}

cubool/tests/test_vector_misc.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ TEST(cuBool_Vector, Marker) {
109109

110110
ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS);
111111
ASSERT_EQ(cuBool_Vector_New(&vector, m), CUBOOL_STATUS_SUCCESS);
112+
113+
ASSERT_EQ(cuBool_Vector_Marker(vector, nullptr, &size), CUBOOL_STATUS_SUCCESS);
114+
ASSERT_LE(size, BUFFER_SIZE);
115+
ASSERT_EQ(cuBool_Vector_Marker(vector, buffer, &size), CUBOOL_STATUS_SUCCESS);
116+
std::cout << "Default marker: " << buffer << std::endl;
117+
112118
ASSERT_EQ(cuBool_Vector_SetMarker(vector, marker), CUBOOL_STATUS_SUCCESS);
113119
ASSERT_EQ(cuBool_Vector_Marker(vector, nullptr, &size), CUBOOL_STATUS_SUCCESS);
114120
ASSERT_LE(size, BUFFER_SIZE);

cubool/utils/testing/vector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace testing {
4646

4747
for (auto v: index) {
4848
if (i <= v && v < (i + m))
49-
out.index.push_back(v);
49+
out.index.push_back(v - i);
5050
}
5151

5252
out.nrows = m;

0 commit comments

Comments
 (0)