Skip to content

Commit 49854b5

Browse files
committed
[Tests] Tests setup fixes
1 parent 3dd3091 commit 49854b5

24 files changed

+330
-192
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ option(CUBOOL_BUILD_TESTS "Build project unit-tests with gtest" ON)
1212

1313
set(CUBOOL_VERSION_MAJOR 1)
1414
set(CUBOOL_VERSION_MINOR 0)
15+
set(CUBOOL_VERSION_SUB 0)
1516

1617
# Configure cuda dependencies
1718
if (CUBOOL_WITH_CUDA)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ as well as python high-level wrapper with automated resources management.
2424
- [X] Library setup
2525
- [X] CSR matrix
2626
- [X] CSR multiplication
27-
- [X] CSR addition
27+
- [X] CSR element-wise addition
2828
- [X] CSR kronecker
2929
- [X] CSR transpose
3030
- [X] CSR submatrix
@@ -136,6 +136,7 @@ By default, the following cmake options will be automatically enabled:
136136

137137
- `CUBOOL_WITH_CUDA` - build library with actual cuda backend
138138
- `CUBOOL_WITH_CPU` - build library witt cpu based backend
139+
- `CUBOOL_WITH_TESTS` - build library unit-tests collection
139140

140141
> Note: in order to provide correct GCC version for CUDA sources compiling,
141142
> you will have to provide custom paths to the CC and CXX compilers before

cubool/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ target_include_directories(cubool PRIVATE ${CMAKE_CURRENT_LIST_DIR}/sources)
116116
target_compile_definitions(cubool PRIVATE CUBOOL_EXPORTS)
117117
target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_MAJOR=${CUBOOL_VERSION_MAJOR})
118118
target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_MINOR=${CUBOOL_VERSION_MINOR})
119+
target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_SUB=${CUBOOL_VERSION_SUB})
119120

120121
target_compile_features(cubool PUBLIC cxx_std_14)
121122

cubool/include/cubool/cubool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ CUBOOL_EXPORT CUBOOL_API const char* cuBool_LicenseInfo_Get(
131131
*
132132
* @param major Major version number part
133133
* @param minor Minor version number part
134-
* @param version Composite integer version
134+
* @param sub Sub version number part
135135
*
136136
* @return Error if failed to query version info
137137
*/
138138
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Version_Get(
139139
int* major,
140140
int* minor,
141-
int* version
141+
int* sub
142142
);
143143

144144
/**

cubool/sources/core/version.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
/** Defined in cmake */
3232
#define CUBOOL_MINOR CUBOOL_VERSION_MINOR
3333

34-
/** Nice utility */
35-
#define CUBOOL_VERSION ((uint32_t) CUBOOL_VERSION_MAJOR << 4u) | ((uint32_t) CUBOOL_VERSION_MINOR)
36-
#define CUBOOL_VERSION_STRING #CUBOOL_VERSION_MAJOR "." #CUBOOL_VERSION_MINOR
34+
/** Defined in cmake */
35+
#define CUBOOL_SUB CUBOOL_VERSION_SUB
3736

3837
#endif //CUBOOL_VERSION_HPP

cubool/sources/cuBool_Version_Get.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@
2727
cuBool_Status cuBool_Version_Get(
2828
int *major,
2929
int *minor,
30-
int *version
30+
int *sub
3131
) {
32+
auto MAJOR = (uint32_t)(CUBOOL_MAJOR);
33+
auto MINOR = (uint32_t)(CUBOOL_MINOR);
34+
auto SUB = (uint32_t)(CUBOOL_SUB);
35+
3236
if (major)
33-
*major = CUBOOL_MAJOR;
37+
*major = MAJOR;
3438

3539
if (minor)
36-
*minor = CUBOOL_MINOR;
40+
*minor = MINOR;
3741

38-
if (version)
39-
*version = CUBOOL_VERSION;
42+
if (sub)
43+
*sub = SUB;
4044

4145
return CUBOOL_STATUS_SUCCESS;
4246
}

cubool/sources/sequential/sq_kronecker.cpp

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

2828
namespace cubool {
2929

30-
void scan(std::vector<index> &v) {
31-
index sum = 0;
32-
for (auto& val: v) {
33-
index next = sum + val;
34-
val = sum;
35-
sum = next;
36-
}
37-
}
38-
3930
void sq_kronecker(const CsrData& a, const CsrData& b, CsrData& out) {
4031
size_t nvals = a.nvals * b.nvals;
4132

cubool/sources/sequential/sq_matrix.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ namespace cubool {
4545
}
4646

4747
void SqMatrix::build(const index *rows, const index *cols, size_t nvals, bool isSorted) {
48-
if (nvals == 0)
49-
return;
50-
51-
assert(rows);
52-
assert(cols);
53-
5448
auto nrows = mData.nrows;
5549
auto ncols = mData.ncols;
5650

@@ -59,6 +53,12 @@ namespace cubool {
5953
mData.colIndices.clear();
6054
mData.colIndices.reserve(nvals);
6155

56+
if (nvals == 0)
57+
return;
58+
59+
assert(rows);
60+
assert(cols);
61+
6262
if (isSorted) {
6363
for (size_t k = 0; k < nvals; k++) {
6464
auto i = rows[k];

cubool/sources/sequential/sq_spgemm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ namespace cubool {
6161
// Row offsets
6262
sq_exclusive_scan(out.rowOffsets.begin(), out.rowOffsets.end(), 0);
6363

64+
out.nvals = nvals;
6465
out.colIndices.resize(nvals);
6566

6667
// Fill column indices per row and sort

cubool/tests/test_library_api.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ TEST(cuBoolInstance, Example) {
8787

8888
testing::Matrix ta = testing::Matrix::generateSparse(n , n, 0.2);
8989

90-
cuBool_Matrix_Build(A, ta.mRowsIndex.data(), ta.mColsIndex.data(), ta.mNvals, CUBOOL_HINT_VALUES_SORTED);
90+
cuBool_Matrix_Build(A, ta.rowsIndex.data(), ta.colsIndex.data(), ta.nvals, CUBOOL_HINT_VALUES_SORTED);
9191

9292
TransitiveClosure(A, &T);
9393

9494
testing::Matrix tr = ta;
95-
size_t total = 0;
95+
size_t total;
9696

9797
do {
98-
total = tr.mNvals;
98+
total = tr.nvals;
9999

100100
testing::MatrixMultiplyFunctor functor;
101-
tr = std::move(functor(tr, tr, tr));
101+
tr = std::move(functor(tr, tr, tr, true));
102102
}
103-
while (tr.mNvals != total);
103+
while (tr.nvals != total);
104104

105105
ASSERT_TRUE(tr.areEqual(T));
106106

0 commit comments

Comments
 (0)