-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend state class to cudastate class
- Loading branch information
1 parent
fa1b8a6
commit cd5735e
Showing
4 changed files
with
42 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2023-2024 National Center for Atmospheric Research | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#pragma once | ||
|
||
#include <micm/solver/state.hpp> | ||
#include <micm/util/matrix.hpp> | ||
#include <micm/util/sparse_matrix.hpp> | ||
#include <micm/util/cuda_dense_matrix.hpp> | ||
|
||
namespace micm | ||
{ | ||
/// @brief Construct a state variable for CUDA tests | ||
template<class DenseMatrixPolicy = StandardDenseMatrix, class SparseMatrixPolicy = StandardSparseMatrix> | ||
struct CudaState : public State<DenseMatrixPolicy, SparseMatrixPolicy> | ||
{ | ||
public: | ||
CudaState(const CudaState&) = delete; | ||
CudaState& operator=(const CudaState&) = delete; | ||
CudaState(CudaState&&) = default; | ||
CudaState& operator=(CudaState&&) = default; | ||
|
||
/// @brief Copy input variables to the device | ||
template<class DenseMatrixPolicy, class SparseMatrixPolicy> | ||
requires(CudaMatrix<DenseMatrixPolicy> && VectorizableDense<DenseMatrixPolicy>) | ||
void SyncInputsToDevice() | ||
{ | ||
variables_.CopyToDevice(); | ||
rate_constants_.CopyToDevice(); | ||
} | ||
|
||
/// @brief Copy output variables to the host | ||
template<class DenseMatrixPolicy, class SparseMatrixPolicy> | ||
requires(CudaMatrix<DenseMatrixPolicy> && VectorizableDense<DenseMatrixPolicy>) | ||
void SyncOutputsToHost() | ||
{ | ||
variables_.CopyToHost(); | ||
} | ||
}; | ||
} // namespace micm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters