-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhash_mult_vlengthcluster.h
More file actions
535 lines (494 loc) · 23.7 KB
/
hash_mult_vlengthcluster.h
File metadata and controls
535 lines (494 loc) · 23.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include <immintrin.h>
#include <algorithm>
#include <fstream>
#include <x86intrin.h>
#include "utility.h"
#include "CSR.h"
#include "CSR_VlengthCluster.h"
#include "BIN_VlengthCluster.h"
/* SpGEMM Specific Parameters */
#define HASH_SCAL 107 // Set disjoint number to hash table size (=2^n)
#define SMALL_THRESHOLD 100
#define MIN_HT_S 8 // minimum hash table size per row in symbolic phase
#define MIN_HT_N 8 // minimum hash table size per row in numeric phase
/*
* Symbolic phase for HashSpGEMMVLCluster.
*/
template<class IT, class NT>
inline void hash_symbolic_kernel_vlcluster(const IT *arpt, const IT *acol,
const IT *brpt, const IT *bcol,
BIN_VlengthCluster<IT, NT> &bin) {
#pragma omp parallel
{
IT tid = omp_get_thread_num();
IT start_row = bin.clusters_offset[tid]; // start cluster
IT end_row = bin.clusters_offset[tid + 1]; // end cluster
IT *check = bin.local_hash_table_id[tid];
for (IT i = start_row; i < end_row; ++i) { // loop over clusters
IT nz = 0;
IT bid = bin.bin_id_cluster[i];
if (bid > 0) {
IT ht_size = MIN_HT_S << (bid - 1); // determine hash table size for i-th row
for (IT j = 0; j < ht_size; ++j) { // initialize hash table
check[j] = -1;
}
for (IT j = arpt[i]; j < arpt[i + 1]; ++j) { // loop over the columns of cluster[i]
IT t_acol = acol[j];
for (IT k = brpt[t_acol]; k < brpt[t_acol + 1]; ++k) { // loop over columns of B (B.row selected by columns of cluster[i])
IT key = bcol[k];
IT hash = (key * HASH_SCAL) & (ht_size - 1);
while (1) { // Loop for hash probing
if (check[hash] == key) { // if the key is already inserted, it's ok
break;
} else if (check[hash] == -1) { // if the key has not been inserted yet, then it's added.
check[hash] = key;
nz++;
break;
} else { // linear probing: check next entry
hash = (hash + 1) & (ht_size - 1); // hash = (hash + 1) % ht_size
}
}
}
}
}
bin.cluster_nz[i] = nz; // updating cluster_nz by row[i] nnz; previously it was set to flops of row[i]
}
}
}
// Reference function for Symbolic phase of HashSpGEMMVLCluster
template<class IT, class NT>
inline void hash_symbolic_vlcluster(const IT *arpt, const IT *acol, const IT *brpt, const IT *bcol,
IT *crpt, IT *crpt_val, BIN_VlengthCluster<IT, NT> &bin,
const IT nrow, IT *nnzc, IT *nnzv) {
hash_symbolic_kernel_vlcluster(arpt, acol, brpt, bcol, bin);
/* Set row/value pointer of matrix C */
scan<IT>(bin.cluster_nz, crpt, crpt_val, bin.cluster_sz, nrow + 1);
*nnzc = crpt[nrow];
*nnzv = crpt_val[nrow];
}
/*
* Used for sort function.
* Elements are sorted in ascending order.
*/
// todo: uncomment this
//template<typename IT, typename NT>
//bool sort_less_V1(const pair<IT, NT> &left, const pair<IT, NT> &right) {
// return left.first < right.first;
//}
/*
* After calculating on each hash table, sort them in ascending order if necessary, and then store them as output matrix
* This function is used in hash_numeric* function.
* the actual indices of colids and values of output matrix are rpt[rowid];
*/
template<bool sortOutput, typename IT, typename NT>
inline void sort_and_store_table2mat_vlcluster(IT *ht_check, NT *ht_value,
IT *colids, NT *values,
IT nz, IT ht_size, IT offset, IT cluster_sz) {
IT index = 0;
IT val_idx, ht_idx;
// Sort elements in ascending order if necessary, and store them as output matrix
if (sortOutput) {
// todo: uncomment this
// vector <pair<IT, IT>> p_vec(nz); // <col-id, position-in-hashtable>
// for (IT j = 0; j < ht_size; ++j) { // accumulate non-zero entry from hash table
// if (ht_check[j] != -1) {
// p_vec[index++] = make_pair(ht_check[j], j);
// }
// }
//
//// assert(index <= nz && "Index goes beyond p_vector limit");
//// assert(index < offset && "Index goes beyond output limit");
//
// sort(p_vec.begin(), p_vec.end(), sort_less_V1<IT, IT>); // sort only non-zero elements
// // store the results
// for (IT j = 0; j < index; ++j) {
// colids[j] = p_vec[j].first;
// val_idx = (j * cluster_sz);
// ht_idx = (p_vec[j].second * cluster_sz);
// for (IT l = 0; l < cluster_sz; l += 1) {
// values[val_idx + l] = ht_value[ht_idx + l];
// }
// }
} else {
// store the results
for (IT j = 0; j < ht_size; ++j) {
if (ht_check[j] != -1) {
colids[index] = ht_check[j];
val_idx = (index * cluster_sz);
ht_idx = (j * cluster_sz);
for (IT l = 0; l < cluster_sz; l += 1) {
values[val_idx + l] = ht_value[ht_idx + l];
}
index++;
}
}
}
}
// todo: here is the update that I was trying to make to improve the performance of variable length cluster SpGEMM
// todo: I think this thinking is still valied as we observed that single-length cluster computation is not that efficient compared to the row-wise spgemm
// todo: I will try to implement this in the future
///*
// * Numeric phase in HashSpGEMMCluster.
// */
//template<bool sortOutput, typename IT, typename NT, typename MultiplyOperation, typename AddOperation>
//inline void hash_numeric_vlcluster(const IT *arpt, const IT *arpt_val, const IT *acol, const NT *aval,
// const IT *brpt, const IT *bcol, const NT *bval,
// const IT *crpt, const IT *crpt_val, IT *ccol, NT *cval,
// const BIN_VlengthCluster<IT, NT> &bin,
// const MultiplyOperation multop, const AddOperation addop, IT cnnz,
// const IT *cluster_sz, const NT eps = 0.000001f) {
//#pragma omp parallel
// {
// IT tid = omp_get_thread_num();
// IT start_row = bin.clusters_offset[tid];
// IT end_row = bin.clusters_offset[tid + 1];
//
// IT *ht_check = bin.local_hash_table_id[tid];
// NT *ht_value = bin.local_hash_table_val[tid];
//
// IT t_acol;
// NT t_aval, t_val;
// for (IT i = start_row; i < end_row; ++i) { // A.clusters
//// note: BIN class is based on the cluster (not in row order of the original CSR)
// IT bid = bin.bin_id_cluster[i];
// if (bid > 0) {
// IT offset = crpt[i];
// IT cval_offset = crpt_val[i];
//// IT aval_offset = arpt_val[i];
// IT aval_offset = arpt_val[i] + ((j - arpt[i]) * cluster_sz[i]);
// IT ht_size = MIN_HT_N << (bid - 1);
// for (IT j = 0; j < ht_size; ++j) {
// ht_check[j] = -1;
// }
//
// for (IT j = arpt[i]; j < arpt[i + 1]; ++j) { // union of col-ids of cluster A.cluster[i]
// t_acol = acol[j];
// for (IT k = brpt[t_acol]; k < brpt[t_acol + 1]; ++k) { // B.cols
// IT key = bcol[k];
// IT hash = (key * HASH_SCAL) & (ht_size - 1);
// while (1) { // Loop for hash probing
// if (ht_check[hash] == key) { // key is already inserted
// IT htval_offset = (hash * cluster_sz[i]);
// for (IT l = 0; l <
// cluster_sz[i]; l += 1, htval_offset += 1) { // loop over all the rows of A.cluster[i].col[j]
// t_aval = aval[aval_offset + l]; // value from A
//// note: maybe we can use a bitmap to find whether [(j * cluster_sz) + l]-pos is valid
// if (fabs(t_aval - 0.0f) >= eps) { // avoid flop when (A.value[] == 0.0)
// t_val = multop(t_aval, bval[k]); // value for C
// ht_value[htval_offset] = addop(t_val, ht_value[htval_offset]);
// }
// }
// break;
// } else if (ht_check[hash] == -1) { // insert new entry
// ht_check[hash] = key;
// for (IT l = 0; l <
// cluster_sz[i]; l += 1, htval_offset += 1) { // loop over all the rows of A.cluster[i].col[j]
// t_aval = aval[aval_offset + l]; // value from A
// t_val = multop(t_aval, bval[k]); // value for C
//// ht_value will be automatically initialized by 0.0 if t_val is zero
//// assert((htval_offset + l) < bin.ht_val_sz[tid] && "Trying to access beyond Hashtable size!");
// ht_value[htval_offset] = t_val;
// }
// break;
// } else {
// hash = (hash + 1) & (ht_size - 1); // (hash + 1) % ht_size
// }
// }
// }
// }
//// copy results from ht to the C_csr
// sort_and_store_table2mat_vlcluster<sortOutput, IT, NT>(ht_check, ht_value,
// ccol + offset, cval + cval_offset,
// (crpt[i + 1] - offset), ht_size, (cnnz - offset),
// cluster_sz[i]);
// }
// }
// }
//}
/*
* Numeric phase in HashSpGEMMCluster.
*/
template<bool sortOutput, typename IT, typename NT, typename MultiplyOperation, typename AddOperation>
inline void hash_numeric_vlcluster(const IT *arpt, const IT *arpt_val, const IT *acol, const NT *aval,
const IT *brpt, const IT *bcol, const NT *bval,
const IT *crpt, const IT *crpt_val, IT *ccol, NT *cval,
const BIN_VlengthCluster<IT, NT> &bin,
const MultiplyOperation multop, const AddOperation addop, IT cnnz,
const IT *cluster_sz, const NT eps = 0.000001f) {
#pragma omp parallel
{
IT tid = omp_get_thread_num();
IT start_row = bin.clusters_offset[tid];
IT end_row = bin.clusters_offset[tid + 1];
IT *ht_check = bin.local_hash_table_id[tid];
NT *ht_value = bin.local_hash_table_val[tid];
IT t_acol;
NT t_aval, t_val;
for (IT i = start_row; i < end_row; ++i) { // A.clusters
// note: BIN class is based on the cluster (not in row order of the original CSR)
IT bid = bin.bin_id_cluster[i];
if (bid > 0) {
IT offset = crpt[i];
IT cval_offset = crpt_val[i];
IT aval_offset = arpt_val[i];
IT ht_size = MIN_HT_N << (bid - 1);
for (IT j = 0; j < ht_size; ++j) {
ht_check[j] = -1;
}
for (IT j = arpt[i]; j < arpt[i + 1]; ++j) { // union of col-ids of cluster A.cluster[i]
t_acol = acol[j];
for (IT k = brpt[t_acol]; k < brpt[t_acol + 1]; ++k) { // B.cols
IT key = bcol[k];
IT hash = (key * HASH_SCAL) & (ht_size - 1);
while (1) { // Loop for hash probing
if (ht_check[hash] == key) { // key is already inserted
for (IT l = 0; l < cluster_sz[i]; l += 1) { // loop over all the rows of A.cluster[i].col[j]
t_aval = aval[aval_offset + ((j - arpt[i]) * cluster_sz[i]) + l]; // value from A
t_val = multop(t_aval, bval[k]); // value for C
// note: maybe we can use a bitmap to find whether [(j * cluster_sz) + l]-pos is valid
if (fabs(t_aval - 0.0f) >= eps) { // avoid flop when (A.value[] == 0.0)
ht_value[(hash * cluster_sz[i]) + l] = addop(t_val, ht_value[(hash * cluster_sz[i]) + l]);
}
}
break;
} else if (ht_check[hash] == -1) { // insert new entry
ht_check[hash] = key;
for (IT l = 0; l < cluster_sz[i]; l += 1) { // loop over all the rows of A.cluster[i].col[j]
t_aval = aval[aval_offset + ((j - arpt[i]) * cluster_sz[i]) + l]; // value from A
t_val = multop(t_aval, bval[k]); // value for C
// ht_value will be automatically initialized by 0.0 if t_val is zero
// assert(((hash * cluster_sz[i]) + l) < bin.ht_val_sz[tid] && "Trying to access beyond Hashtable size!");
ht_value[(hash * cluster_sz[i]) + l] = t_val;
}
break;
} else {
hash = (hash + 1) & (ht_size - 1); // (hash + 1) % ht_size
}
}
}
}
// copy results from ht to the C_csr
sort_and_store_table2mat_vlcluster<sortOutput, IT, NT>(ht_check, ht_value,
ccol + offset, cval + cval_offset,
(crpt[i + 1] - offset), ht_size, (cnnz - offset),
cluster_sz[i]);
}
}
}
}
/*
* After calculating on each hash table, sort them in ascending order if necessary, and then store them as output matrix
* This function is used in hash_numeric* function.
* the actual indices of colids and values of output matrix are rpt[rowid];
*/
template<bool sortOutput, typename IT, typename NT>
inline void sort_and_store_table2mat_vlcluster_V1(IT *ht_check, NT *ht_value,
IT *colids, NT *values,
IT nz, IT ht_size) {
IT index = 0;
IT val_idx, ht_idx;
// Sort elements in ascending order if necessary, and store them as output matrix
if (sortOutput) {
// todo: uncomment this
// vector <pair<IT, IT>> p_vec(nz); // <col-id, position-in-hashtable>
// for (IT j = 0; j < ht_size; ++j) { // accumulate non-zero entry from hash table
// if (ht_check[j] != -1) {
// p_vec[index++] = make_pair(ht_check[j], j);
// }
// }
//
//// assert(index <= nz && "Index goes beyond p_vector limit");
//// assert(index < offset && "Index goes beyond output limit");
//
// sort(p_vec.begin(), p_vec.end(), sort_less_V1<IT, IT>); // sort only non-zero elements
// // store the results
// for (IT j = 0; j < index; ++j) {
// colids[j] = p_vec[j].first;
//// val_idx = (j * cluster_sz);
// ht_idx = p_vec[j].second;
//// for (IT l = 0; l < cluster_sz; l += 1) {
// values[j] = ht_value[ht_idx];
//// }
// }
} else {
// store the results
for (IT j = 0; j < ht_size; ++j) {
if (ht_check[j] != -1) {
colids[index] = ht_check[j];
// val_idx = (index * cluster_sz);
// ht_idx = (j * cluster_sz);
// for (IT l = 0; l < cluster_sz; l += 1) {
values[index] = ht_value[j];
// }
index++;
}
}
}
}
/*
* Numeric phase in HashSpGEMMCluster.
*/
template<bool sortOutput, typename IT, typename NT, typename MultiplyOperation, typename AddOperation>
inline void hash_numeric_vlcluster_V1(const IT *arpt, const IT *arpt_val, const IT *acol, const NT *aval,
const IT *brpt, const IT *bcol, const NT *bval,
const IT *crpt, const IT *crpt_val, IT *ccol, NT *cval,
const BIN_VlengthCluster<IT, NT> &bin,
const MultiplyOperation multop, const AddOperation addop, IT cnnz,
const IT *cluster_sz, const NT eps = 0.000001f) {
#pragma omp parallel
{
IT tid = omp_get_thread_num();
IT start_row = bin.clusters_offset[tid];
IT end_row = bin.clusters_offset[tid + 1];
IT *ht_check = bin.local_hash_table_id[tid];
NT *ht_value = bin.local_hash_table_val[tid];
IT t_acol;
NT t_aval, t_val;
for (IT i = start_row; i < end_row; ++i) { // A.clusters
// note: BIN class is based on the cluster (not in row order of the original CSR)
IT bid = bin.bin_id_cluster[i];
if (bid > 0) {
IT csz = cluster_sz[i];
IT offset = crpt[i];
IT cval_offset = crpt_val[i];
IT aval_offset = arpt_val[i];
IT ht_size = MIN_HT_N << (bid - 1);
for (IT j = 0; j < ht_size; ++j) {
ht_check[j] = -1;
}
IT tmp1, tmp2;
for (IT j = arpt[i]; j < arpt[i + 1]; ++j) { // union of col-ids of cluster A.cluster[i]
t_acol = acol[j];
tmp1 = aval_offset + ((j - arpt[i]) * csz);
for (IT k = brpt[t_acol]; k < brpt[t_acol + 1]; ++k) { // B.cols
IT key = bcol[k];
IT hash = (key * HASH_SCAL) & (ht_size - 1);
while (1) { // Loop for hash probing
tmp2 = (hash * csz);
if (ht_check[hash] == key) { // key is already inserted
for (IT l = 0; l < csz; l += 1) { // loop over all the rows of A.cluster[i].col[j]
t_aval = aval[tmp1 + l]; // value from A
t_val = multop(t_aval, bval[k]); // value for C
// note: maybe we can use a bitmap to find whether [(j * cluster_sz) + l]-pos is valid
if (fabs(t_aval - 0.0f) >= eps) { // avoid flop when (A.value[] == 0.0)
// ht_value[tmp2 + l] = addop(t_val, ht_value[tmp2 + l]);
ht_value[tmp2] = addop(t_val, ht_value[tmp2]);
}
tmp2++;
}
break;
} else if (ht_check[hash] == -1) { // insert new entry
ht_check[hash] = key;
for (IT l = 0; l < csz; l += 1) { // loop over all the rows of A.cluster[i].col[j]
t_aval = aval[tmp1 + l]; // value from A
t_val = multop(t_aval, bval[k]); // value for C
// ht_value will be automatically initialized by 0.0 if t_val is zero
// assert(((hash * csz) + l) < bin.ht_val_sz[tid] && "Trying to access beyond Hashtable size!");
ht_value[tmp2] = t_val;
tmp2++;
}
break;
} else {
hash = (hash + 1) & (ht_size - 1); // (hash + 1) % ht_size
}
}
}
}
// copy results from ht to the C_csr
sort_and_store_table2mat_vlcluster_V1<sortOutput, IT, NT>(ht_check, ht_value,
ccol + offset, cval + cval_offset,
(crpt[i + 1] - offset), ht_size);
}
}
}
}
/*
* Executing HashSpGEMMVLCluster
* The function starts with initialization of hash table followed by symbolic phase and numeric phase with hash table.
* Hash table also stores data in clustered format
*/
template<bool sortOutput, typename IT, typename NT, typename MultiplyOperation, typename AddOperation>
void
HashSpGEMMVLCluster(const CSR_VlengthCluster<IT, NT> &a, const CSR<IT, NT> &b, CSR_VlengthCluster<IT, NT> &c,
MultiplyOperation multop, AddOperation addop) {
// initialize bin
// double start, end, msec;
// start = omp_get_wtime();
BIN_VlengthCluster<IT, NT> bin(a.rows, MIN_HT_S, a.cluster_sz);
c.csr_rows = a.csr_rows;
c.rows = a.rows;
c.cols = b.cols;
c.cluster_sz = my_malloc<IT>(a.rows);
memcpy(c.cluster_sz, a.cluster_sz, sizeof(IT) * a.rows);
/* Set max bin */
bin.set_max_bin(a.rowptr, a.colids, b.rowptr, c.cols);
/* Create hash table (thread local) */
bin.create_local_hash_table(c.cols);
/* Symbolic Phase */
c.rowptr = my_malloc<IT>(c.rows + 1);
c.rowptr_val = my_malloc<IT>(c.rows + 1);
// end = omp_get_wtime();
// msec = (end - start) * 1000;
// cout << "BIN initialization time: " << msec << " milli seconds." << endl;
//
// start = omp_get_wtime();
hash_symbolic_vlcluster(a.rowptr, a.colids, b.rowptr, b.colids,
c.rowptr, c.rowptr_val,
bin, c.rows, &(c.nnzc), &(c.nnzv));
// resetting (reduce) hash table size
// hash table size is initialized by flops count
// after the symbolic phase, we can reset it by nnz count
bin.set_bin_id(c.cols, bin.min_ht_size);
c.colids = my_malloc<IT>(c.nnzc);
c.values = my_malloc<NT>(c.nnzv);
// end = omp_get_wtime();
// msec = (end - start) * 1000;
// cout << "Symbolic time: " << msec << " milli seconds." << endl;
//
// /* Numeric Phase */
// start = omp_get_wtime();
// hash_numeric_vlcluster<sortOutput>(a.rowptr, a.rowptr_val, a.colids, a.values,
// b.rowptr, b.colids, b.values,
// c.rowptr, c.rowptr_val, c.colids, c.values,
// bin, multop, addop, c.nnzc, c.cluster_sz);
hash_numeric_vlcluster_V1<sortOutput>(a.rowptr, a.rowptr_val, a.colids, a.values,
b.rowptr, b.colids, b.values,
c.rowptr, c.rowptr_val, c.colids, c.values,
bin, multop, addop, c.nnzc, c.cluster_sz);
// end = omp_get_wtime();
// msec = (end - start) * 1000;
// cout << "Numeric time: " << msec << " milli seconds." << endl;
}
template<bool sortOutput, typename IT, typename NT, typename MultiplyOperation, typename AddOperation>
void
HashSpGEMMVLClustertoCheckMemoryRequirement(const CSR_VlengthCluster<IT, NT> &a, const CSR<IT, NT> &b, CSR_VlengthCluster<IT, NT> &c,
MultiplyOperation multop, AddOperation addop) {
// initialize bin
BIN_VlengthCluster<IT, NT> bin(a.rows, MIN_HT_S, a.cluster_sz);
c.csr_rows = a.csr_rows;
c.rows = a.rows;
c.cols = b.cols;
c.cluster_sz = my_malloc<IT>(a.rows);
memcpy(c.cluster_sz, a.cluster_sz, sizeof(IT) * a.rows);
/* Set max bin */
bin.set_max_bin(a.rowptr, a.colids, b.rowptr, c.cols);
/* Create hash table (thread local) */
bin.create_local_hash_table(c.cols);
/* Symbolic Phase */
c.rowptr = my_malloc<IT>(c.rows + 1);
c.rowptr_val = my_malloc<IT>(c.rows + 1);
hash_symbolic_vlcluster(a.rowptr, a.colids, b.rowptr, b.colids,
c.rowptr, c.rowptr_val,
bin, c.rows, &(c.nnzc), &(c.nnzv));
// resetting (reduce) hash table size
// hash table size is initialized by flops count
// after the symbolic phase, we can reset it by nnz count
bin.set_bin_id(c.cols, bin.min_ht_size);
c.colids = my_malloc<IT>(c.nnzc);
c.values = my_malloc<NT>(c.nnzv);
printf("BIN size: %.2f bytes\n", bin.calculate_size_in_gb());
printf("C size: %.2f bytes\n", c.calculate_size());
}