Skip to content

Commit

Permalink
Auto-format code changes (#210)
Browse files Browse the repository at this point in the history
Auto-format code using Clang-Format

Co-authored-by: GitHub Actions <actions@github.com>
  • Loading branch information
github-actions[bot] and actions-user authored Sep 5, 2023
1 parent 12b01eb commit eaa45d8
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 164 deletions.
80 changes: 38 additions & 42 deletions include/micm/process/cuda_process_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,24 @@ namespace micm
MatrixPolicy<double>& forcing) const
{
CUDAMatrixParam matrixParam;
matrixParam.rate_constants = rate_constants.AsVector().data();
matrixParam.state_variables = state_variables.AsVector().data();
matrixParam.forcing = forcing.AsVector().data();
matrixParam.n_grids = rate_constants.size();
matrixParam.n_reactions = rate_constants[0].size();
matrixParam.rate_constants = rate_constants.AsVector().data();
matrixParam.state_variables = state_variables.AsVector().data();
matrixParam.forcing = forcing.AsVector().data();
matrixParam.n_grids = rate_constants.size();
matrixParam.n_reactions = rate_constants[0].size();
matrixParam.n_species = state_variables[0].size();

CUDAProcessSetParam processSet;
processSet.number_of_reactants = number_of_reactants_.data();
processSet.reactant_ids = reactant_ids_.data();
processSet.reactant_ids_size = reactant_ids_.size();
processSet.number_of_products = number_of_products_.data();
processSet.product_ids = product_ids_.data();
processSet.product_ids_size = product_ids_.size();
processSet.yields = yields_.data();
processSet.yields_size = yields_.size();
CUDAProcessSetParam processSet;
processSet.number_of_reactants = number_of_reactants_.data();
processSet.reactant_ids = reactant_ids_.data();
processSet.reactant_ids_size = reactant_ids_.size();
processSet.number_of_products = number_of_products_.data();
processSet.product_ids = product_ids_.data();
processSet.product_ids_size = product_ids_.size();
processSet.yields = yields_.data();
processSet.yields_size = yields_.size();

std::chrono::nanoseconds kernel_duration = micm::cuda::AddForcingTermsKernelDriver(
matrixParam,
processSet);
std::chrono::nanoseconds kernel_duration = micm::cuda::AddForcingTermsKernelDriver(matrixParam, processSet);
return kernel_duration; // time performance of kernel function
}
template<template<class> class MatrixPolicy, template<class> class SparseMatrixPolicy>
Expand All @@ -82,31 +80,29 @@ namespace micm
const MatrixPolicy<double>& state_variables,
SparseMatrixPolicy<double>& jacobian) const
{
CUDAMatrixParam matrixParam;
matrixParam.rate_constants = rate_constants.AsVector().data();
matrixParam.state_variables = state_variables.AsVector().data();
matrixParam.n_grids = rate_constants.size();
matrixParam.n_reactions = rate_constants[0].size();
matrixParam.n_species = state_variables[0].size();

CUDASparseMatrixParam sparseMatrix;
sparseMatrix.jacobian = jacobian.AsVector().data();
sparseMatrix.jacobian_size = jacobian.AsVector().size();

CUDAProcessSetParam processSet;
processSet.number_of_reactants = number_of_reactants_.data();
processSet.reactant_ids = reactant_ids_.data();
processSet.reactant_ids_size = reactant_ids_.size();
processSet.number_of_products = number_of_products_.data();
processSet.yields = yields_.data();
processSet.yields_size = yields_.size();
processSet.jacobian_flat_ids = jacobian_flat_ids_.data();
processSet.jacobian_flat_ids_size = jacobian_flat_ids_.size();

std::chrono::nanoseconds kernel_duration = micm::cuda::AddJacobianTermsKernelDriver(
matrixParam,
sparseMatrix,
processSet);
CUDAMatrixParam matrixParam;
matrixParam.rate_constants = rate_constants.AsVector().data();
matrixParam.state_variables = state_variables.AsVector().data();
matrixParam.n_grids = rate_constants.size();
matrixParam.n_reactions = rate_constants[0].size();
matrixParam.n_species = state_variables[0].size();

CUDASparseMatrixParam sparseMatrix;
sparseMatrix.jacobian = jacobian.AsVector().data();
sparseMatrix.jacobian_size = jacobian.AsVector().size();

CUDAProcessSetParam processSet;
processSet.number_of_reactants = number_of_reactants_.data();
processSet.reactant_ids = reactant_ids_.data();
processSet.reactant_ids_size = reactant_ids_.size();
processSet.number_of_products = number_of_products_.data();
processSet.yields = yields_.data();
processSet.yields_size = yields_.size();
processSet.jacobian_flat_ids = jacobian_flat_ids_.data();
processSet.jacobian_flat_ids_size = jacobian_flat_ids_.size();

std::chrono::nanoseconds kernel_duration =
micm::cuda::AddJacobianTermsKernelDriver(matrixParam, sparseMatrix, processSet);
return kernel_duration; // time performance of kernel function
}
} // namespace micm
Expand Down
55 changes: 29 additions & 26 deletions include/micm/util/cuda_param.hpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
#ifndef CUDA_PARAM_HPP
#define CUDA_PARAM_HPP
//member data of class CUDAProcessSet grouped in struct passing to kernel driver function
struct CUDAProcessSetParam{
const size_t* number_of_reactants;
const size_t* reactant_ids;
size_t reactant_ids_size;
const size_t* number_of_products;
const size_t* product_ids;
size_t product_ids_size;
const double* yields;
size_t yields_size;
const size_t* jacobian_flat_ids;
size_t jacobian_flat_ids_size;
};
//different matrix data grouped in struct passing to kernel driver function
struct CUDAMatrixParam{
const double* rate_constants;
const double* state_variables;
double* forcing;
size_t n_grids;
size_t n_reactions;
size_t n_species;
};
//sparseMatrix data grouped in struct passing to kernel driver function
struct CUDASparseMatrixParam{
double* jacobian;
size_t jacobian_size;
// member data of class CUDAProcessSet grouped in struct passing to kernel driver function
struct CUDAProcessSetParam
{
const size_t* number_of_reactants;
const size_t* reactant_ids;
size_t reactant_ids_size;
const size_t* number_of_products;
const size_t* product_ids;
size_t product_ids_size;
const double* yields;
size_t yields_size;
const size_t* jacobian_flat_ids;
size_t jacobian_flat_ids_size;
};
// different matrix data grouped in struct passing to kernel driver function
struct CUDAMatrixParam
{
const double* rate_constants;
const double* state_variables;
double* forcing;
size_t n_grids;
size_t n_reactions;
size_t n_species;
};
// sparseMatrix data grouped in struct passing to kernel driver function
struct CUDASparseMatrixParam
{
double* jacobian;
size_t jacobian_size;
};
#endif
Loading

0 comments on commit eaa45d8

Please sign in to comment.