CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
117 lines
2.2 KiB
C++
117 lines
2.2 KiB
C++
/***************************************************************************
|
|
Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
|
|
***************************************************************************/
|
|
|
|
#ifndef __JACOBI_HPP__
|
|
#define __JACOBI_HPP__
|
|
|
|
#include <math.h>
|
|
#include <mpi.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "defines.hpp"
|
|
#include "hip/hip_runtime.h"
|
|
|
|
struct grid_t
|
|
{
|
|
MPI_Comm comm;
|
|
int rank, size;
|
|
|
|
int device_id;
|
|
|
|
int Nrow, Ncol;
|
|
int myrow, mycol;
|
|
|
|
int Neighbor[NSIDES];
|
|
};
|
|
|
|
struct mesh_t
|
|
{
|
|
int N;
|
|
int Nx, Ny;
|
|
|
|
int Nhalo;
|
|
|
|
dfloat Lx, Ly;
|
|
dfloat dx, dy;
|
|
|
|
dfloat invNtotal;
|
|
|
|
dfloat* x;
|
|
dfloat* y;
|
|
|
|
dfloat *sendBuffer, *recvBuffer;
|
|
dfloat* d_haloBuffer;
|
|
|
|
int sideLength[NSIDES], sideOffset[NSIDES];
|
|
|
|
MPI_Request requests[2 * NSIDES];
|
|
MPI_Status status[2 * NSIDES];
|
|
};
|
|
|
|
class Jacobi_t
|
|
{
|
|
private:
|
|
grid_t& grid;
|
|
mesh_t& mesh;
|
|
|
|
// host buffers
|
|
dfloat *h_U, *h_RHS, *h_AU, *h_RES;
|
|
|
|
// device buffers
|
|
dfloat *d_U, *d_RHS, *d_AU, *d_RES;
|
|
|
|
double timerStart, timerStop, elasped, avgTransferTime;
|
|
double totalCommTime, totalLocalComputeTime;
|
|
int iterations;
|
|
|
|
hipStream_t computeStream;
|
|
hipStream_t dataStream;
|
|
|
|
hipEvent_t JacobiLocalStart, JacobiLocalEnd;
|
|
|
|
void ApplyTopology();
|
|
|
|
void CreateMesh();
|
|
|
|
void InitializeData();
|
|
|
|
void PrintResults();
|
|
|
|
public:
|
|
Jacobi_t(grid_t& grid_, mesh_t& mesh_);
|
|
|
|
~Jacobi_t();
|
|
|
|
void Run();
|
|
};
|
|
|
|
dfloat
|
|
ForcingFunction(dfloat x, dfloat y);
|
|
dfloat
|
|
BoundaryFunction(dfloat x, dfloat y);
|
|
|
|
void
|
|
ParseCommandLineArguments(int argc, char** argv, MPI_Comm comm, grid_t& grid,
|
|
mesh_t& mesh);
|
|
|
|
void
|
|
HaloExchange(grid_t& grid, mesh_t& mesh, hipStream_t stream, dfloat* d_U);
|
|
|
|
dfloat
|
|
Norm(grid_t& grid, mesh_t& mesh, hipStream_t stream, dfloat* U);
|
|
|
|
void
|
|
LocalLaplacian(grid_t& grid, mesh_t& mesh, hipStream_t stream, dfloat* d_U, dfloat* d_AU);
|
|
|
|
void
|
|
HaloLaplacian(grid_t& grid, mesh_t& mesh, hipStream_t stream, dfloat* d_U, dfloat* d_AU);
|
|
|
|
void
|
|
JacobiIteration(grid_t& grid, mesh_t& mesh, hipStream_t stream, dfloat* d_RHS,
|
|
dfloat* d_AU, dfloat* d_RES, dfloat* d_U);
|
|
|
|
#endif // __JACOBI_HPP__
|