Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coompare newbc and gym-arch #5

Open
wants to merge 2 commits into
base: newbc
Choose a base branch
from
Open

Coompare newbc and gym-arch #5

wants to merge 2 commits into from

Conversation

VanillaBrooks
Copy link
Member

for illustration and discussion of the diffs, not intended to be merged

# with mpi support
h5py
mpi4py
gymnasium
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these files dont have their versions pinned, so its possible they have been updated since this MR was originally created & have caused breaking changes


[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why I decided to only now start packaging things up into a pyproject.toml but probably the right thing to do

@@ -54,7 +54,7 @@ OBJ_FILES = alloc.o bcdf.o bcextr.o bcfree.o bc.o bcrecyc.o bcrelax.o bcshk.o bc
setup.o solver.o startmpi.o stats.o step.o target_reystress.o tbforce.o updateghost.o utility.o utyibm.o \
visflx.o writedf.o writefield.o writefieldvtk.o writegridplot3d.o writerst.o \
writestatbl.o writestatchann.o writestat.o writestatzbl.o write_wallpressure.o visflx_stag.o \
write_probe_data.o bcblow.o dissipation.o
bcblow.o dissipation.o dealloc.o
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically just adds dealloc and removes write_probe_data files from the build.

  • dealloc deallocates all arrays if they exist. This is so we can start the solver again without needing to restart the python process. Otherwise, the fortran code would attempt to reallocate these arrays. This would be a problem because (1) not enough memory (2) they are already allocated so it would error
  • write_probe_data is legacy from when I first started working on streams. Since you can now (in theory) run streams from python, exporting data with python IO routines w/ h5py is much much simpler than doing it in fortran

if (allocated(w_order)) deallocate(w_order)
if (allocated(wallpfield_gpu)) deallocate(wallpfield_gpu)
if (allocated(slicexy_gpu)) deallocate(slicexy_gpu)
if (allocated(vf_df_old)) deallocate(vf_df_old)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deallocate CPU-side arrays if they exist. deallocate_all is bound out to python

if (allocated(fdm_grid_points)) deallocate(fdm_grid_points)
#ifdef USE_CUDA
if (allocated(fl_trans_gpu)) deallocate(fl_trans_gpu)
if (allocated(temperature_trans_gpu)) deallocate(temperature_trans_gpu)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deallocations for GPU arrays. Note that this section is in #ifdef USE_CUDA which evaluates to true for all practical lab applications (essentially, ensuring we are running w/ GPU accelerations)

@@ -135,6 +135,8 @@ subroutine initurb
enddo
enddo
enddo
deallocate(ranf_av)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont recall why I put this here, probably some constraint such that I couldnt put it in the main deallocate routine above

call deallocate_all()
call setup()
call solver()
call finalize() ! Finalize computation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proof of concept, not meant for real use. This shows that after stopping the simulation (the first finalize) you can

  • deallocate the arrays
  • call setup which reallocates them
  • run the solver
  • stop again

and you will get the same data twice. Not sure if I ever proved it was the same data, but I do believe it ran without error.

@@ -10,8 +10,6 @@ subroutine manage_solver
updatestat = .false.
savefield = .false.
saverst = .false.
saveprobe = .false.
savespanaverage = .false.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this IO can now be done from python, removed

if (save_probe_steps > 0) then
if (mod(icyc, save_probe_steps) == 0) saveprobe = .true.
end if

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this IO can now be done from python, removed

if (saveprobe) then
call write_probe_data
endif

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this IO can now be done from python, removed

implicit none

call deallocate_all()
end subroutine
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind the deallocate_all function to python under the name wrap_deallocate_all

@@ -51,9 +51,6 @@ subroutine readinp
read (12,*) rand_start
read (12,*)
read (12,*)
read (12,*) save_probe_steps, save_span_average_steps
read (12,*)
read (12,*)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer need to read IO information from config files for these parameters since they are unused

@@ -101,8 +101,6 @@ module mod_streams
!f2py integer :: slot_start_x_global, slot_end_x_global
integer :: slot_start_x_global, slot_end_x_global

! the number of solver steps between outputting probe information / span average information
integer :: save_probe_steps, save_span_average_steps
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead variables now, removed

@@ -1,314 +0,0 @@
module mod_probe
real(8), dimension(:,:,:), allocatable :: span_average
character(len=5) :: nxstr, nystr
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole file was to export binary data, using hdf5 now so remove it

deallocate(nyvec)
deallocate(retauvec)
deallocate(reydata)
deallocate(reydataycode)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont recall why these are here, might be that they are not part of mod_streams and could not dealloc them in deallocate_all.f90

#importlib.reload(streams)
#streams.wrap_startmpi()
setup_solver()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the 5th timestep, stop the solver and set it up again

from itertools import count
from typing import Deque

# pytorch imports
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are from the pytorch getting started tutorial, do not recall which one

ObsType = Any
RenderFrame = Any

class StreamsSolver(Env):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

framework for creating a gym environment with gymnasium. these are all placeholders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant