Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues detected by Coverity (2024.01) #5272

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions dali/operators/random/rng_checkpointing_utils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -77,16 +77,18 @@ class RngCheckpointUtils<GPUBackend, curand_states> {
const auto &states_gpu = cpt.CheckpointState<curand_states>();
size_t n = states_gpu.length();
std::vector<curandState> states(n);
cudaMemcpy(states.data(), states_gpu.states(), n * sizeof(curandState),
cudaMemcpyDeviceToHost);
CUDA_CALL(cudaMemcpy(states.data(), states_gpu.states(), n * sizeof(curandState),
cudaMemcpyDeviceToHost));
return SnapshotSerializer().Serialize(states);
}

static void DeserializeCheckpoint(OpCheckpoint &cpt, const std::string &data) {
auto deserialized = SnapshotSerializer().Deserialize<std::vector<curandState>>(data);
curand_states states(deserialized.size());
cudaMemcpy(states.states(), deserialized.data(), sizeof(curandState) * deserialized.size(),
cudaMemcpyHostToDevice);
CUDA_CALL(cudaMemcpy(states.states(),
deserialized.data(),
sizeof(curandState) * deserialized.size(),
cudaMemcpyHostToDevice));
cpt.MutableCheckpointState() = states;
}
};
Expand Down
9 changes: 5 additions & 4 deletions dali/operators/util/randomizer.cuh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright (c) 2020-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,13 +53,14 @@ struct curand_states {

DALI_HOST inline curand_states copy(AccessOrder order) const {
curand_states states(len_);
cudaMemcpyAsync(states.states_, states_, sizeof(curandState) * len_,
cudaMemcpyDeviceToDevice, order.stream());
CUDA_CALL(cudaMemcpyAsync(states.states_, states_, sizeof(curandState) * len_,
cudaMemcpyDeviceToDevice, order.stream()));
return states;
}

DALI_HOST inline void set(const curand_states &other) {
cudaMemcpy(states_, other.states_, sizeof(curandState) * len_, cudaMemcpyDeviceToDevice);
CUDA_CALL(cudaMemcpy(states_, other.states_, sizeof(curandState) * len_,
cudaMemcpyDeviceToDevice));
}

private:
Expand Down
6 changes: 3 additions & 3 deletions dali/pipeline/operator/checkpointing/checkpoint.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@ class OpGraph;
/**
* @brief Pipeline-wide state, passed from python side
*/
struct DLL_PUBLIC ExternalContextCheckpoint {
struct ExternalContextCheckpoint {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to mark a plain struct with DLL_PUBLIC.

int epoch_idx; // Epoch index, as counted by python Pipeline
int iter; // Iteration, as counted by python Pipeline
};
Expand Down Expand Up @@ -78,7 +78,7 @@ class DLL_PUBLIC Checkpoint {
*/
DLL_PUBLIC void DeserializeFromProtobuf(const OpGraph &graph, const std::string &serialized_data);

ExternalContextCheckpoint external_ctx_cpt_;
ExternalContextCheckpoint external_ctx_cpt_{};

private:
std::vector<OpCheckpoint> cpts_;
Expand Down