Commit fcf98c9a authored by Bram Veenboer's avatar Bram Veenboer

Cleanup of registered host memory in InstanceCUDA

parent d4be4138
......@@ -912,6 +912,14 @@ namespace idg {
return *d_grid;
}
cu::HostMemory& InstanceCUDA::allocate_host_grid(
unsigned int grid_size)
{
auto size = auxiliary::sizeof_grid(grid_size);
reuse_memory(size, h_grid);
return *h_grid;
}
cu::DeviceMemory& InstanceCUDA::allocate_device_aterms(
unsigned int nr_stations,
unsigned int nr_timeslots,
......@@ -1119,21 +1127,12 @@ namespace idg {
return m;
}
cu::HostMemory& InstanceCUDA::allocate_host_grid(
unsigned int grid_size)
{
auto size = auxiliary::sizeof_grid(grid_size);
h_grid_allocated = reuse_memory(h_misc_, size, NULL);
return *h_grid_allocated;
}
cu::HostMemory& InstanceCUDA::register_host_grid(
unsigned int grid_size,
void *ptr)
{
auto size = auxiliary::sizeof_grid(grid_size);
h_grid_registered = reuse_memory(h_misc_, size, ptr);
return *h_grid_registered;
return *reuse_memory(h_registered_, size, ptr);
}
cu::HostMemory& InstanceCUDA::register_host_visibilities(
......@@ -1143,8 +1142,7 @@ namespace idg {
void *ptr)
{
auto size = auxiliary::sizeof_visibilities(nr_baselines, nr_timesteps, nr_channels);
h_visibilities_registered = reuse_memory(h_misc_, size, ptr);
return *h_visibilities_registered;
return *reuse_memory(h_registered_, size, ptr);
}
cu::HostMemory& InstanceCUDA::register_host_uvw(
......@@ -1153,8 +1151,7 @@ namespace idg {
void *ptr)
{
auto size = auxiliary::sizeof_uvw(nr_baselines, nr_timesteps);
h_uvw_registered = reuse_memory(h_misc_, size, ptr);
return *h_uvw_registered;
return *reuse_memory(h_registered_, size, ptr);
}
/*
......@@ -1165,7 +1162,7 @@ namespace idg {
h_uvw_.clear();
h_metadata_.clear();
h_subgrids_.clear();
h_misc_.clear();
h_registered_.clear();
}
/*
......
......@@ -250,7 +250,7 @@ namespace idg {
cu::DeviceMemory& retrieve_device_memory(unsigned int id);
// Retrieve pre-allocated buffers (per device)
cu::HostMemory& retrieve_host_grid() { return *h_grid_allocated; }
cu::HostMemory& retrieve_host_grid() { return *h_grid; }
cu::DeviceMemory& retrieve_device_grid() { return *d_grid; }
cu::DeviceMemory& retrieve_device_aterms() { return *d_aterms; }
cu::DeviceMemory& retrieve_device_aterms_indices() { return *d_aterms_indices; }
......@@ -314,6 +314,7 @@ namespace idg {
std::unique_ptr<cu::DeviceMemory> d_wavenumbers;
std::unique_ptr<cu::DeviceMemory> d_spheroidal;
std::unique_ptr<cu::DeviceMemory> d_grid;
std::unique_ptr<cu::HostMemory> h_grid;
// One instance per stream
std::vector<std::unique_ptr<cu::HostMemory>> h_visibilities_;
......@@ -325,12 +326,8 @@ namespace idg {
std::vector<std::unique_ptr<cu::DeviceMemory>> d_metadata_;
std::vector<std::unique_ptr<cu::DeviceMemory>> d_subgrids_;
// Misc host memory
std::vector<std::unique_ptr<cu::HostMemory>> h_misc_;
cu::HostMemory *h_grid_registered;
cu::HostMemory *h_visibilities_registered;
cu::HostMemory *h_uvw_registered;
cu::HostMemory *h_grid_allocated;
// Registered host memory
std::vector<std::unique_ptr<cu::HostMemory>> h_registered_;
// Misc device memory
std::vector<std::unique_ptr<cu::DeviceMemory>> d_misc_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment