Skip to content

Commit 23f6d96

Browse files
committed
[Code] SpGEMM: minor fixes && create result vector without dense vector scan
1 parent 76612dd commit 23f6d96

File tree

6 files changed

+135
-144
lines changed

6 files changed

+135
-144
lines changed

cubool/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ if (CUBOOL_WITH_CUDA)
117117
sources/cuda/cuda_backend.cu
118118
sources/cuda/cuda_instance.hpp
119119
sources/cuda/cuda_instance.cu
120-
sources/cuda/cuda_instance.cpp
121120
sources/cuda/cuda_matrix.hpp
122121
sources/cuda/cuda_matrix.cu
123122
sources/cuda/cuda_matrix_ewiseadd.cu

cubool/sources/cuda/cuda_instance.cpp

Lines changed: 0 additions & 64 deletions
This file was deleted.

cubool/sources/cuda/cuda_instance.cu

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030

3131
namespace cubool {
3232

33+
volatile CudaInstance* CudaInstance::gInstance = nullptr;
34+
35+
CudaInstance::CudaInstance(bool useManagedMemory) {
36+
gInstance = this;
37+
mMemoryType = useManagedMemory? Managed: Default;
38+
}
39+
3340
CudaInstance::~CudaInstance() {
3441
assert(mHostAllocCount == 0);
3542
assert(mDeviceAllocCount == 0);
@@ -108,4 +115,29 @@ namespace cubool {
108115
}
109116
}
110117

118+
void CudaInstance::allocate(void* &ptr, size_t size) const {
119+
ptr = malloc(size);
120+
CHECK_RAISE_ERROR(ptr != nullptr, MemOpFailed, "Failed to allocate memory on the CPU");
121+
mHostAllocCount++;
122+
}
123+
124+
void CudaInstance::deallocate(void* ptr) const {
125+
CHECK_RAISE_ERROR(ptr != nullptr, InvalidArgument, "Passed null ptr to free");
126+
free(ptr);
127+
mHostAllocCount--;
128+
}
129+
130+
CudaInstance& CudaInstance::getInstanceRef() {
131+
CHECK_RAISE_ERROR(gInstance != nullptr, InvalidState, "No instance in the system");
132+
return (CudaInstance&) *gInstance;
133+
}
134+
135+
CudaInstance* CudaInstance::getInstancePtr() {
136+
return (CudaInstance* ) gInstance;
137+
}
138+
139+
bool CudaInstance::isInstancePresent() {
140+
return gInstance != nullptr;
141+
}
142+
111143
}

cubool/sources/cuda/cuda_instance.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace cubool {
3535
*/
3636
class CudaInstance {
3737
public:
38+
3839
enum MemType {
3940
Default,
4041
Managed

0 commit comments

Comments
 (0)