Skip to content

Commit 66d8717

Browse files
authored
Merge pull request #856 from UWB-Biocomputing/AvikantDevelopment
DeviceVector GPU Fix
2 parents 39c65bf + 61fddaa commit 66d8717

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Simulator/Utils/DeviceVector.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ template <typename T> class DeviceVector {
8888
/// @param size Initial size of the host vector (defaults to 0)
8989
/// @post Host vector is created with 'size' default-constructed elements
9090
/// @post Device pointer is nullptr (no GPU memory allocated)
91-
explicit DeviceVector(size_t size = 0) : hostData_(size)
91+
explicit DeviceVector(size_t size = 0) : hostData_(size), devicePtr_(nullptr)
9292
{
93-
#if defined(__CUDACC__)
94-
devicePtr_ = nullptr;
95-
#endif
9693
}
9794

9895
~DeviceVector() = default;
@@ -449,7 +446,9 @@ template <typename T> class DeviceVector {
449446
private:
450447
std::vector<T> hostData_; // Host-side vector
451448

452-
#if defined(__CUDACC__)
449+
// Introducing compilation guards (__CUDACC__) for the device pointer
450+
// causes a runtime error during GPU simulations.
451+
// This is likely because DeviceVector is included in both
452+
// host (.cpp) and device (_d.cpp) code, and compiled on both sides.
453453
T *devicePtr_; // Device pointer
454-
#endif
455-
};
454+
};

0 commit comments

Comments
 (0)