Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • CodeursIntensifs/grayscott/GrayScottSyclSetup
1 result
Show changes
Commits on Source (3)
#include <vector>
#include <iostream>
#include <iomanip>
......@@ -6,26 +7,24 @@
using real = double ;
const real KILL_RATE { 0.062f };
const real FEED_RATE { 0.03f };
const real DT { 1.0f };
const real DIFFUSION_RATE_U { 0.1f };
const real DIFFUSION_RATE_V { 0.05f };
constexpr real KILL_RATE { 0.062l };
constexpr real FEED_RATE { 0.03l };
constexpr real DT { 1.0l };
constexpr real DIFFUSION_RATE_U { 0.1l };
constexpr real DIFFUSION_RATE_V { 0.05l };
template<typename Collection>
void drop( Collection & data, std::size_t nb_rows, std::size_t nb_cols, real value ) {
const std::size_t center_row { nb_rows/2ul };
const std::size_t center_col { nb_cols/2ul };
for (std::size_t i = (center_row-2ul) ; i < (center_row+2ul); i++) {
for (std::size_t j = (center_col-3ul); j < (center_col+3ul); j++) {
data[i*nb_cols+j] = value ;
for (std::size_t row = (center_row-2ul) ; row < (center_row+2ul); row++) {
for (std::size_t col = (center_col-3ul); col < (center_col+3ul); col++) {
data[row*nb_cols+col] = value ;
}
}
}
void process(
void transform(
std::vector<real> const & iu, std::vector<real> const & iv,
std::vector<real> & ou, std::vector<real> & ov,
std::size_t nb_rows, std::size_t nb_cols ) {
......@@ -37,16 +36,16 @@ void process(
real v = iv[(r+1)*nb_cols+c+1];
real uvv = u*v*v;
real full_u = 0.0f;
real full_v = 0.0f;
for(std::size_t k = 0ul; k < 3ul; ++k){
for(std::size_t l = 0ul; l < 3ul; ++l){
full_u += iu[(r+k)*nb_cols+c+l] - u;
full_v += iv[(r+k)*nb_cols+c+l] - v;
real full_u = 0.l;
real full_v = 0.l;
for(std::size_t dr = 0ul; dr < 3ul; ++dr){
for(std::size_t dc = 0ul; dc < 3ul; ++dc){
full_u += iu[(r+dr)*nb_cols+c+dc] - u;
full_v += iv[(r+dr)*nb_cols+c+dc] - v;
}
}
real du = DIFFUSION_RATE_U*full_u - uvv + FEED_RATE*(1.0f - u);
real du = DIFFUSION_RATE_U*full_u - uvv + FEED_RATE*(static_cast<real>(1.0l) - u);
real dv = DIFFUSION_RATE_V*full_v + uvv - (FEED_RATE + KILL_RATE)*v;
ou[(r+1)*nb_cols+c+1] = u + du*DT;
......@@ -65,17 +64,18 @@ int main( int argc, char * argv[] ) {
std::size_t nb_images {std::stoul(argv[3])};
std::size_t nb_iterations {std::stoul(argv[4])};
std::cout << std::fixed << std::setprecision(6);
assert(nb_iterations%2==0);
assert(nb_images<=1000);
try {
// Temporary work images
std::vector<real> u1(nb_rows*nb_cols,1.f);
std::vector<real> v1(nb_rows*nb_cols,0.f);
std::vector<real> u2(nb_rows*nb_cols,1.f);
std::vector<real> v2(nb_rows*nb_cols,0.f);
drop(u1, nb_rows, nb_cols, 0.f);
drop(v1, nb_rows, nb_cols, 1.f);
std::vector<real> u1(nb_rows*nb_cols,1.l);
std::vector<real> v1(nb_rows*nb_cols,0.l);
std::vector<real> u2(nb_rows*nb_cols,1.l);
std::vector<real> v2(nb_rows*nb_cols,0.l);
drop(u1, nb_rows, nb_cols, 0.l);
drop(v1, nb_rows, nb_cols, 1.l);
// Final images sequence
std::vector<std::vector<real>> images;
......@@ -85,7 +85,7 @@ int main( int argc, char * argv[] ) {
std::cout<<std::endl ;
for ( std::size_t image = 0 ; image < nb_images ; ++image ) {
for ( std::size_t iter = 0 ; iter < nb_iterations ; ++iter ) {
process( u1, v1, u2, v2, nb_rows, nb_cols );
transform( u1, v1, u2, v2, nb_rows, nb_cols );
std::swap(u1,u2) ; std::swap (v1,v2) ;
}
std::cout << '.' << std::flush;
......@@ -95,7 +95,7 @@ int main( int argc, char * argv[] ) {
// Final product
std::cout << std::endl;
real product = std::inner_product(u1.begin(), u1.end(), v1.begin(),0.f);
real product = std::inner_product(u1.begin(), u1.end(), v1.begin(),static_cast<real>(0.l));
std::cout
<< "product : " << product
<< std::endl;
......
......@@ -32,5 +32,5 @@ gpusub intel.bash 2
The helper function `qclean` will remove all the output of the previous jobs you have submitted.
Have a look at `intel.bash` to see the various compile and run steps, and optionally adapt it to your own needs.
Have a look at `intel.bash` to see the various compile/run steps, and optionally adapt it to your own needs.
......@@ -23,22 +23,20 @@ cd GrayScottSyclSetup/
# check CPU nodes
IMG=gitlab-registry.in2p3.fr/codeursintensifs/grayscott/grayscottsyclsetup/jfalcou:2024.1
docker run --gpus all --device=/dev/dri --network host -it --rm -v ${PWD}:/work -w /work ${IMG}
cd CheckOneApiCpu
./sycl-ls.bash
./cmake.bash
./make.bash
./run.bash
docker run --network host -it --rm -v ${PWD}:/work -w /work ${IMG}
cd CheckOneApi
./intel.bash # give the list of available devices
./intel.bash 1 # check the results of device 1
exit
# Check GPU nodes
IMG=gitlab-registry.in2p3.fr/codeursintensifs/grayscott/grayscottsyclsetup/dchamont:2024.1
docker run --gpus all --device=/dev/dri --network host -it --rm -v ${PWD}:/work -w /work ${IMG}
cd CheckOneApiCuda
cd CheckOneApi
nvidia-smi
./sycl-ls.bash
./cmake.bash
./make.bash
./run.bash
./cuda.bash # give the list of available devices
./cuda.bash 4 # give the list of available devices
exit
```
Have a look at `intel.bash` to see the various compile and run steps, and optionally adapt it to your own needs.
......@@ -10,7 +10,7 @@ RUN pacman-key --init
RUN pacman -Syu --noconfirm --needed \
gcc nano cmake git intel-oneapi-compiler-dpcpp-cpp-runtime-libs intel-oneapi-dpcpp-cpp
RUN pacman -Syu --noconfirm --needed ninja
RUN pacman -Syu --noconfirm --needed make
RUN rm -rf /var/cache/pacman/pkg/
......