Skip to content

Commit

Permalink
update stream to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Berenger Bramas authored and Berenger Bramas committed Sep 8, 2024
1 parent 3fad770 commit c8a5c6a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Src/Cuda/SpCudaUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstring>
#include <vector>
#include <sstream>
#include <cassert>

#include "Config/SpConfig.hpp"

Expand Down Expand Up @@ -64,6 +65,12 @@ class SpCudaUtils{
return free_byte;
}

static int getUsingDevice() {
int currentDevice;
CUDA_ASSERT(cudaGetDevice(&currentDevice));
return currentDevice;
}

static void UseDevice(const int deviceId){
if(deviceId >= GetNbDevices()){
std::cerr << "[SPECX] Ask to use gpu " << deviceId
Expand All @@ -77,6 +84,8 @@ class SpCudaUtils{
}

static void SynchronizeStream(cudaStream_t& stream){
assert(stream != nullptr);
assert(getUsingDevice() != -1);
CUDA_ASSERT(cudaStreamSynchronize(stream));
}

Expand Down
2 changes: 1 addition & 1 deletion Src/Cuda/SpCudaWorkerData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

struct SpCudaWorkerData {
int cudaId = -1;
cudaStream_t stream;
cudaStream_t stream = nullptr;

void init(int deviceId){
cudaId = deviceId;
Expand Down
9 changes: 9 additions & 0 deletions Src/Hip/SpHipUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstring>
#include <vector>
#include <sstream>
#include <cassert>

#include "Config/SpConfig.hpp"

Expand Down Expand Up @@ -64,6 +65,12 @@ class SpHipUtils{
return free_byte;
}

static int getUsingDevice() {
int currentDevice;
HIP_ASSERT(hipGetDevice(&currentDevice));
return currentDevice;
}

static void UseDevice(const int deviceId){
if(deviceId >= GetNbDevices()){
std::cerr << "[SPECX] Ask to use gpu " << deviceId
Expand All @@ -77,6 +84,8 @@ class SpHipUtils{
}

static void SynchronizeStream(hipStream_t& stream){
assert(stream != nullptr);
assert(getUsingDevice() != -1);
HIP_ASSERT(hipStreamSynchronize(stream));
}

Expand Down
2 changes: 1 addition & 1 deletion Src/Hip/SpHipWorkerData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

struct SpHipWorkerData {
int hipId = -1;
hipStream_t stream;
hipStream_t stream = nullptr;

void init(int deviceId){
hipId = deviceId;
Expand Down

0 comments on commit c8a5c6a

Please sign in to comment.