Skip to content
Snippets Groups Projects
Commit c2805a92 authored by Matteo Cicuttin's avatar Matteo Cicuttin
Browse files

Added skeleton for OpenAcc.

parent abcc5a8c
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include <silo.h> #include <silo.h>
#include <Kokkos_Core.hpp> #include <Kokkos_Core.hpp>
#include <pmmintrin.h>
#include <xmmintrin.h>
#define WAVE_8_HALO_SIZE 4 #define WAVE_8_HALO_SIZE 4
using namespace Kokkos; using namespace Kokkos;
...@@ -180,6 +183,11 @@ double solve_kokkos(wave_equation_context_kokkos<T>& wec) ...@@ -180,6 +183,11 @@ double solve_kokkos(wave_equation_context_kokkos<T>& wec)
static const T w4 = -1.0/560.0; static const T w4 = -1.0/560.0;
static const T w[9] = { w4, w3, w2, w1, w0, w1, w2, w3, w4 }; static const T w[9] = { w4, w3, w2, w1, w0, w1, w2, w3, w4 };
#ifdef DISALLOW_DENORMALS
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
#endif
i += WAVE_8_HALO_SIZE; i += WAVE_8_HALO_SIZE;
j += WAVE_8_HALO_SIZE; j += WAVE_8_HALO_SIZE;
...@@ -226,7 +234,20 @@ double solve_kokkos(wave_equation_context_kokkos<T>& wec) ...@@ -226,7 +234,20 @@ double solve_kokkos(wave_equation_context_kokkos<T>& wec)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#ifdef SINGLE_PRECISION
using T = float;
std::cout << "Precision: single" << std::endl;
#else
using T = double; using T = double;
std::cout << "Precision: single" << std::endl;
#endif
#ifdef DISALLOW_DENORMALS
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
std::cout << "Denormals: FTZ and DAZ" << std::endl;
#endif
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
Kokkos::initialize( argc, argv ); Kokkos::initialize( argc, argv );
......
...@@ -2,31 +2,36 @@ ...@@ -2,31 +2,36 @@
#include <fstream> #include <fstream>
#include <cstdio> #include <cstdio>
#include <unistd.h> #include <unistd.h>
#include <pmmintrin.h>
#include <xmmintrin.h>
#include "fd_wave_cpu.hpp" #include "fd_wave_cpu.hpp"
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
#include "fd_wave_cuda.hpp" #include "fd_wave_cuda.hpp"
#endif #endif
#include <pmmintrin.h>
#include <xmmintrin.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef DISALLOW_DENORMALS
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
#endif
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
#ifdef SINGLE_PRECISION #ifdef SINGLE_PRECISION
using T = float; using T = float;
std::cout << "Precision: single" << std::endl;
std::ofstream ofs("timings-float.txt"); std::ofstream ofs("timings-float.txt");
#else #else
using T = double; using T = double;
std::cout << "Precision: double" << std::endl;
std::ofstream ofs("timings-double.txt"); std::ofstream ofs("timings-double.txt");
#endif #endif
#ifdef DISALLOW_DENORMALS
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
std::cout << "Denormals: FTZ and DAZ" << std::endl;
#endif
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
/* Make header */ /* Make header */
ofs << "\"SIZE\" \"Seq\" \"SeqBlk\" "; ofs << "\"SIZE\" \"Seq\" \"SeqBlk\" ";
......
#include <iostream>
#include <fstream>
#include <cstdio>
#include <unistd.h>
#include "fd_wave_cpu.hpp"
template<typename T>
double solve_openacc(wave_equation_context<T>& wec, size_t nths)
{
}
int main(void)
{
#ifdef SINGLE_PRECISION
using T = float;
std::cout << "Precision: single" << std::endl;
#else
using T = double;
std::cout << "Precision: double" << std::endl;
#endif
for (size_t sz = 128; sz <= 1024; sz *= 2)
{
wave_equation_context<T> wec(sz, sz, 1, 0.1, 0.0001, 5000);
wec.init();
time = solve_openacc(wec);
}
return 0;
}
\ No newline at end of file
...@@ -359,7 +359,7 @@ solve_sequential_aux(wave_equation_context<T>& wec) ...@@ -359,7 +359,7 @@ solve_sequential_aux(wave_equation_context<T>& wec)
std::cout << "[Wave][SeqBlk] Wall Time: " << time << "ms" << std::endl; std::cout << "[Wave][SeqBlk] Wall Time: " << time << "ms" << std::endl;
double itertime = time/wec.maxiter; double itertime = time/wec.maxiter;
double gflops_s = 60*(params.maxrow*params.maxcol)/(1e6*itertime); double gflops_s = 58*(params.maxrow*params.maxcol)/(1e6*itertime);
std::cout << "[Wave][SeqBlk] GFlops/s: " << gflops_s << std::endl; std::cout << "[Wave][SeqBlk] GFlops/s: " << gflops_s << std::endl;
} }
else else
...@@ -368,7 +368,7 @@ solve_sequential_aux(wave_equation_context<T>& wec) ...@@ -368,7 +368,7 @@ solve_sequential_aux(wave_equation_context<T>& wec)
std::cout << "[Wave][Sequential] Wall Time: " << time << "ms" << std::endl; std::cout << "[Wave][Sequential] Wall Time: " << time << "ms" << std::endl;
double itertime = time/wec.maxiter; double itertime = time/wec.maxiter;
double gflops_s = 60*(params.maxrow*params.maxcol)/(1e6*itertime); double gflops_s = 58*(params.maxrow*params.maxcol)/(1e6*itertime);
std::cout << "[Wave][Sequential] GFlops/s: " << gflops_s << std::endl; std::cout << "[Wave][Sequential] GFlops/s: " << gflops_s << std::endl;
size_t kernel_bytes = 3*sizeof(T)*(params.maxrow*params.maxcol); size_t kernel_bytes = 3*sizeof(T)*(params.maxrow*params.maxcol);
...@@ -418,6 +418,10 @@ double solve_multithread(wave_equation_context<T>& wec, size_t nths) ...@@ -418,6 +418,10 @@ double solve_multithread(wave_equation_context<T>& wec, size_t nths)
bool iteration_finished = false; bool iteration_finished = false;
auto thread_lambda = [&](size_t thread_id, size_t num_threads) { auto thread_lambda = [&](size_t thread_id, size_t num_threads) {
#ifdef DISALLOW_DENORMALS
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
#endif
while (1) while (1)
{ {
/* Wait for the producer to notify that there's something to do */ /* Wait for the producer to notify that there's something to do */
......
#include <iostream>
#include <pmmintrin.h>
#include <xmmintrin.h>
int main(void)
{
std::cout << "DAZ: " << _MM_GET_DENORMALS_ZERO_MODE() << std::endl;
std::cout << "FTZ: " << _MM_GET_FLUSH_ZERO_MODE() << std::endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment