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
79 lines
2.4 KiB
Plaintext
79 lines
2.4 KiB
Plaintext
/***************************************************************************
|
|
Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
|
|
***************************************************************************/
|
|
|
|
#include "Jacobi.hpp"
|
|
|
|
void Jacobi_t::Run() {
|
|
|
|
OnePrintf((!grid.rank), "Starting Jacobi run.\n");
|
|
|
|
iterations = 0;
|
|
|
|
//compute initial residual (assumes zero initial guess)
|
|
dfloat residual = Norm(grid, mesh, computeStream, d_RES);
|
|
|
|
OnePrintf((!grid.rank),
|
|
"Iteration: %d - Residual: %.6f\n", iterations, residual);
|
|
|
|
hipDeviceSynchronize();
|
|
MPI_Barrier(grid.comm);
|
|
timerStart = MPI_Wtime();
|
|
|
|
totalCommTime = 0.0;
|
|
totalLocalComputeTime = 0.0;
|
|
|
|
while ((iterations < JACOBI_MAX_LOOPS) && (residual > JACOBI_TOLERANCE)) {
|
|
|
|
//record when local compute starts on compute stream
|
|
hipEventRecord(JacobiLocalStart, computeStream);
|
|
double commStart = MPI_Wtime();
|
|
|
|
//queue local part of Laplacian to compute stream
|
|
LocalLaplacian(grid, mesh, computeStream, d_U, d_AU);
|
|
|
|
//record when local compute ends on compute stream
|
|
hipEventRecord(JacobiLocalEnd, computeStream);
|
|
|
|
//Extract data off GPU exchange Halo with MPI
|
|
HaloExchange(grid, mesh, dataStream, d_U);
|
|
|
|
//comms are complete at this point, record the elapsed time
|
|
double commElapsed = MPI_Wtime() - commStart;
|
|
|
|
//use halo data to complete Laplacian computation
|
|
HaloLaplacian(grid, mesh, computeStream, d_U, d_AU);
|
|
|
|
//Jacobi iterative method
|
|
// U = U + D^{-1}*(RHS - AU)
|
|
JacobiIteration(grid, mesh, computeStream, d_RHS, d_AU, d_RES, d_U);
|
|
|
|
//residual = ||U||
|
|
residual = Norm(grid, mesh, computeStream, d_RES);
|
|
|
|
//finish everything on device
|
|
hipDeviceSynchronize();
|
|
|
|
//query the completed events to find the time the local laplacian took
|
|
float localLaplacianTime = 0.0;
|
|
hipEventElapsedTime(&localLaplacianTime,
|
|
JacobiLocalStart, JacobiLocalEnd);
|
|
|
|
//keep running totals
|
|
totalCommTime += commElapsed;
|
|
totalLocalComputeTime += localLaplacianTime/1000.0;
|
|
|
|
++iterations;
|
|
OnePrintf((!grid.rank) && ((iterations) % 100 == 0),
|
|
"Iteration: %d - Residual: %.6f\n", iterations, residual);
|
|
}
|
|
|
|
MPI_Barrier(grid.comm);
|
|
timerStop = MPI_Wtime();
|
|
elasped = timerStop - timerStart;
|
|
|
|
OnePrintf((!grid.rank), "Stopped after %d iterations with residue %.6f\n", iterations, residual);
|
|
|
|
PrintResults();
|
|
}
|