OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
kernels_simple.hpp File Reference

Simple GPU kernel operations for element-wise computations. More...

Include dependency graph for kernels_simple.hpp:

Go to the source code of this file.

Functions

void pfc::gpu::add_scalar (GPUVector< double > &vec, double value)
 Add a scalar value to each element of a GPU vector.
 
void pfc::gpu::multiply_scalar (GPUVector< double > &vec, double value)
 Multiply each element of a GPU vector by a scalar.
 

Detailed Description

Simple GPU kernel operations for element-wise computations.

This header provides simple GPU kernel operations that work with GPUVector. These are basic building blocks for more complex GPU computations.

All functions are only available when CUDA is enabled at compile time. On systems without CUDA, these functions will not be compiled.

#ifdef OpenPFC_ENABLE_CUDA
// ... initialize vec ...
pfc::gpu::add_scalar(vec, 10.0); // Add 10.0 to each element
#endif
Simple GPU memory container (RAII)
Definition gpu_vector.hpp:73
Author
OpenPFC Development Team
Date
2025

Function Documentation

◆ add_scalar()

void pfc::gpu::add_scalar ( GPUVector< double > &  vec,
double  value 
)

Add a scalar value to each element of a GPU vector.

Performs element-wise addition: vec[i] = vec[i] + value for all i.

Parameters
vecGPU vector to modify (in-place)
valueScalar value to add to each element
Exceptions
std::runtime_errorif CUDA kernel launch fails
Note
Only available when OpenPFC_ENABLE_CUDA is defined. On systems without CUDA, this function will not be compiled.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ multiply_scalar()

void pfc::gpu::multiply_scalar ( GPUVector< double > &  vec,
double  value 
)

Multiply each element of a GPU vector by a scalar.

Performs element-wise multiplication: vec[i] = vec[i] * value for all i.

Parameters
vecGPU vector to modify (in-place)
valueScalar value to multiply each element by
Exceptions
std::runtime_errorif CUDA kernel launch fails
Note
Only available when OpenPFC_ENABLE_CUDA is defined.
Here is the call graph for this function:
Here is the caller graph for this function: