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