Skip to content

Commit fc0c3b5

Browse files
committed
[Project] Update project logo && readme update
1 parent 38d1813 commit fc0c3b5

File tree

4 files changed

+136
-124
lines changed

4 files changed

+136
-124
lines changed

README.md

Lines changed: 26 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
![Project logo](https://github.com/JetBrains-Research/cuBool/blob/master/docs/logo/cubool_logo_trsp.png?raw=true)
22

3-
# CUBOOL
3+
# cuBool
44

55
[![JB Research](https://jb.gg/badges/research-flat-square.svg)](https://research.jetbrains.org/)
66
[![Ubuntu](https://github.com/JetBrains-Research/cuBool/workflows/Ubuntu/badge.svg?branch=master)](https://github.com/JetBrains-Research/cuBool/actions)
77
[![License](https://img.shields.io/badge/license-MIT-orange)](https://github.com/JetBrains-Research/cuBool/blob/master/LICENSE)
88

9-
CuBool is a linear boolean algebra library primitives and operations for
10-
work with dense and sparse matrices written on the NVIDIA CUDA platform. The primary
9+
**cuBool** is a linear Boolean algebra library primitives and operations for
10+
work with sparse matrices written on the NVIDIA CUDA platform. The primary
1111
goal of the library is implementation, testing and profiling algorithms for
1212
solving *formal-language-constrained problems*, such as *context-free*
1313
and *regular* path queries with various semantics for graph databases.
1414
The library provides C-compatible API, written in the GraphBLAS style,
15-
as well as python high-level wrapper with automated resources management.
15+
as well as python high-level wrapper with automated resources management and fancy syntax sugar.
1616

17-
> The name of the library is formed by a combination of words *Cuda* and *Boolean*,
18-
> what literally means *Cuda with Boolean* and sounds very similar to the name of
19-
> the programming language *COBOL*.
17+
**The primary library primitive** is a sparse boolean matrix. The library provides
18+
the most popular operations for matrix manipulation, such as construction from
19+
values, transpose, sub-matrix extraction, matrix-to-vector reduce, matrix-matrix
20+
element-wise addition, matrix-matrix multiplication and Kronecker product.
21+
22+
**As a fallback** library provides sequential backend for mentioned above operations
23+
for computations on CPU side only. This backend is selected automatically
24+
if Cuda compatible is not presented in the system. This can be very quite handy for
25+
prototyping algorithms on a local computer for later running on a powerful server.
2026

2127
### Features
2228

@@ -55,9 +61,12 @@ as well as python high-level wrapper with automated resources management.
5561
- GCC Compiler
5662
- NVIDIA CUDA toolkit
5763
- Python 3 (for `pycubool` library)
58-
- Git
64+
- Git (to get source code)
65+
66+
### Cuda & Compiler Setup
5967

60-
### Setup
68+
> Skip thia section if you want to build library with only sequential backend
69+
> without cuda backend support.
6170
6271
Before the CUDA setup process, validate your system NVIDIA driver with `nvidia-smi`
6372
command. if it is need, install required driver via `ubuntu-drivers devices` and
@@ -129,7 +138,7 @@ Configure build in Release mode with tests and run actual compilation process:
129138
```shell script
130139
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCUBOOL_BUILD_TESTS=ON
131140
$ cmake --build . --target all -j `nproc`
132-
$ sh ./scripts/tests_run_all.sh
141+
$ bash ./scripts/tests_run_all.sh
133142
```
134143

135144
By default, the following cmake options will be automatically enabled:
@@ -159,8 +168,6 @@ which uses this variable in order to located library object.
159168
160169
## Usage
161170
162-
### Brief Example
163-
164171
The following C++ code snipped demonstrates, how library functions and
165172
primitives can be used for the transitive closure evaluation of the directed
166173
graph, represented as an adjacency matrix with boolean values. The transitive
@@ -219,117 +226,6 @@ def transitive_closure(a: pycubool.Matrix):
219226
return t
220227
```
221228
222-
### Detailed Example
223-
224-
The following code snippet demonstrates, how to create basic cubool based application
225-
for sparse matrix-matrix multiplication and matrix-matrix element-wise addition
226-
with cubool C API usage.
227-
228-
```c++
229-
/************************************************/
230-
/* Evaluate transitive closure for some graph G */
231-
/************************************************/
232-
233-
/* Actual cubool C API */
234-
#include <cubool/cubool.h>
235-
#include <stdio.h>
236-
237-
/* Macro to check result of the function call */
238-
#define CHECK(f) { cuBool_Status s = f; if (s != CUBOOL_STATUS_SUCCESS) return s; }
239-
240-
int main() {
241-
cuBool_Matrix A;
242-
cuBool_Matrix TC;
243-
244-
/* System may not provide Cuda compatible device */
245-
CHECK(cuBool_Initialize(CUBOOL_HINT_NO));
246-
247-
/* Input graph G */
248-
249-
/* -> (1) -> */
250-
/* | | */
251-
/* (0) --> (2) <--> (3) */
252-
253-
/* Adjacency matrix in sparse format */
254-
cuBool_Index n = 4;
255-
cuBool_Index e = 5;
256-
cuBool_Index rows[] = { 0, 0, 1, 2, 3 };
257-
cuBool_Index cols[] = { 1, 2, 2, 3, 2 };
258-
259-
/* Create matrix */
260-
CHECK(cuBool_Matrix_New(&A, n, n));
261-
262-
/* Fill the data */
263-
CHECK(cuBool_Matrix_Build(A, rows, cols, e, CUBOOL_HINT_VALUES_SORTED));
264-
265-
/* Now we have created the following matrix */
266-
267-
/* [0][1][2][3]
268-
/* [0] . 1 1 . */
269-
/* [1] . . 1 . */
270-
/* [2] . . . 1 */
271-
/* [3] . . 1 . */
272-
273-
/* Create result matrix from source as copy */
274-
CHECK(cuBool_Matrix_Duplicate(A, &TC));
275-
276-
/* Query current number on non-zero elements */
277-
cuBool_Index total = 0;
278-
cuBool_Index current;
279-
CHECK(cuBool_Matrix_Nvals(TC, &current));
280-
281-
/* Loop while values are added */
282-
while (current != total) {
283-
total = current;
284-
285-
/** Transitive closure step */
286-
CHECK(cuBool_MxM(TC, TC, TC, CUBOOL_HINT_ACCUMULATE));
287-
CHECK(cuBool_Matrix_Nvals(TC, &current));
288-
}
289-
290-
/** Get result */
291-
cuBool_Index tc_rows[16], tc_cols[16];
292-
CHECK(cuBool_Matrix_ExtractPairs(TC, tc_rows, tc_cols, &total));
293-
294-
/** Now tc_rows and tc_cols contain (i,j) pairs of the result G_tc graph */
295-
296-
/* [0][1][2][3]
297-
/* [0] . 1 1 1 */
298-
/* [1] . . 1 1 */
299-
/* [2] . . 1 1 */
300-
/* [3] . . 1 1 */
301-
302-
/* Output result size */
303-
printf("Nnz(tc)=%lli\n", (unsigned long long) total);
304-
305-
for (cuBool_Index i = 0; i < total; i++)
306-
printf("(%u,%u) ", tc_rows[i], tc_cols[i]);
307-
308-
/* Release resources */
309-
CHECK(cuBool_Matrix_Free(A));
310-
CHECK(cuBool_Matrix_Free(TC));
311-
312-
/* Release library */
313-
return cuBool_Finalize() != CUBOOL_STATUS_SUCCESS;
314-
}
315-
```
316-
317-
Export path to library cubool, compile the file and run with the following
318-
command (assuming, that source code is placed into tc.cpp file):
319-
320-
```shell script
321-
$ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:path/to/folder/with/libcubool/"
322-
$ gcc tc.cpp -o tc -I/path/to/cubool/include/dir/ -L/path/to/folder/with/libcubool/ -lcubool
323-
$ ./tc
324-
```
325-
326-
The program will print the following output:
327-
328-
```
329-
Nnz(tc)=9
330-
(0,1) (0,2) (0,3) (1,2) (1,3) (2,2) (2,3) (3,2) (3,3)
331-
```
332-
333229
## Directory structure
334230
335231
```
@@ -372,4 +268,10 @@ This project is licensed under MIT License. License text can be found in the
372268
## Acknowledgments
373269
374270
This is research project of the Programming Languages and Tools Laboratory
375-
at Jet-Brains Research company. Laboratory website [link](https://research.jetbrains.org/groups/plt_lab/projects/).
271+
at JetBrains Research company. Laboratory website [link](https://research.jetbrains.org/groups/plt_lab/).
272+
273+
## Also
274+
275+
The name of the library is formed by a combination of words *Cuda* and *Boolean*,
276+
what literally means *Cuda with Boolean* and sounds very similar to the name of
277+
the programming language *COBOL*.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Detailed Example
2+
3+
The following code snippet demonstrates, how to create basic cubool based application
4+
for sparse matrix-matrix multiplication and matrix-matrix element-wise addition
5+
with cubool C API usage.
6+
7+
```c++
8+
/************************************************/
9+
/* Evaluate transitive closure for some graph G */
10+
/************************************************/
11+
12+
/* Actual cubool C API */
13+
#include <cubool/cubool.h>
14+
#include <stdio.h>
15+
16+
/* Macro to check result of the function call */
17+
#define CHECK(f) { cuBool_Status s = f; if (s != CUBOOL_STATUS_SUCCESS) return s; }
18+
19+
int main() {
20+
cuBool_Matrix A;
21+
cuBool_Matrix TC;
22+
23+
/* System may not provide Cuda compatible device */
24+
CHECK(cuBool_Initialize(CUBOOL_HINT_NO));
25+
26+
/* Input graph G */
27+
28+
/* -> (1) -> */
29+
/* | | */
30+
/* (0) --> (2) <--> (3) */
31+
32+
/* Adjacency matrix in sparse format */
33+
cuBool_Index n = 4;
34+
cuBool_Index e = 5;
35+
cuBool_Index rows[] = { 0, 0, 1, 2, 3 };
36+
cuBool_Index cols[] = { 1, 2, 2, 3, 2 };
37+
38+
/* Create matrix */
39+
CHECK(cuBool_Matrix_New(&A, n, n));
40+
41+
/* Fill the data */
42+
CHECK(cuBool_Matrix_Build(A, rows, cols, e, CUBOOL_HINT_VALUES_SORTED));
43+
44+
/* Now we have created the following matrix */
45+
46+
/* [0][1][2][3]
47+
/* [0] . 1 1 . */
48+
/* [1] . . 1 . */
49+
/* [2] . . . 1 */
50+
/* [3] . . 1 . */
51+
52+
/* Create result matrix from source as copy */
53+
CHECK(cuBool_Matrix_Duplicate(A, &TC));
54+
55+
/* Query current number on non-zero elements */
56+
cuBool_Index total = 0;
57+
cuBool_Index current;
58+
CHECK(cuBool_Matrix_Nvals(TC, &current));
59+
60+
/* Loop while values are added */
61+
while (current != total) {
62+
total = current;
63+
64+
/** Transitive closure step */
65+
CHECK(cuBool_MxM(TC, TC, TC, CUBOOL_HINT_ACCUMULATE));
66+
CHECK(cuBool_Matrix_Nvals(TC, &current));
67+
}
68+
69+
/** Get result */
70+
cuBool_Index tc_rows[16], tc_cols[16];
71+
CHECK(cuBool_Matrix_ExtractPairs(TC, tc_rows, tc_cols, &total));
72+
73+
/** Now tc_rows and tc_cols contain (i,j) pairs of the result G_tc graph */
74+
75+
/* [0][1][2][3]
76+
/* [0] . 1 1 1 */
77+
/* [1] . . 1 1 */
78+
/* [2] . . 1 1 */
79+
/* [3] . . 1 1 */
80+
81+
/* Output result size */
82+
printf("Nnz(tc)=%lli\n", (unsigned long long) total);
83+
84+
for (cuBool_Index i = 0; i < total; i++)
85+
printf("(%u,%u) ", tc_rows[i], tc_cols[i]);
86+
87+
/* Release resources */
88+
CHECK(cuBool_Matrix_Free(A));
89+
CHECK(cuBool_Matrix_Free(TC));
90+
91+
/* Release library */
92+
return cuBool_Finalize() != CUBOOL_STATUS_SUCCESS;
93+
}
94+
```
95+
96+
Export path to library cubool, compile the file and run with the following
97+
command (assuming, that source code is placed into tc.cpp file):
98+
99+
```shell script
100+
$ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:path/to/folder/with/libcubool/"
101+
$ gcc tc.cpp -o tc -I/path/to/cubool/include/dir/ -L/path/to/folder/with/libcubool/ -lcubool
102+
$ ./tc
103+
```
104+
105+
The program will print the following output:
106+
107+
```
108+
Nnz(tc)=9
109+
(0,1) (0,2) (0,3) (1,2) (1,3) (2,2) (2,3) (3,2) (3,3)
110+
```

docs/logo/cubool_logo_dark.png

-7.5 KB
Loading

docs/logo/cubool_logo_trsp.png

13.1 KB
Loading

0 commit comments

Comments
 (0)