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

mmap()'d Ring Space #135

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a0e46bd
Initial commit of the disk backed ring idea. This concept uses a mma…
jaycedowell Sep 30, 2019
f04ca10
Fixed build problems with the CPU-only version.
jaycedowell Sep 30, 2019
2d5a582
Renamed to BF_SPACE_MAPPED since that seems a little more clear. Cle…
jaycedowell Sep 30, 2019
3e057bf
Typos. Missing file. So fun.
jaycedowell Sep 30, 2019
e48d266
Added flags to user.mk and Makefile to help control where the files a…
jaycedowell Sep 30, 2019
40a5cb6
Renamed MAPPED_DIR to MAPPED_RING_DIR to make it a little more clear …
jaycedowell Sep 30, 2019
388fd8c
Added the mapped space into a couple of other places in Bifrost.
jaycedowell Oct 2, 2019
8258a1e
Added a missing BF_SPACE_MAPPED case to bfMemcpy2D.
jaycedowell Oct 2, 2019
fb2c49e
Cleaned up the typing and naming inside the MappedMgr class.
jaycedowell Oct 2, 2019
23c4751
Hacked in a few quick tests for the mapped ring space.
jaycedowell Oct 2, 2019
9ded2aa
And a few more tests that involve the mapped space.
jaycedowell Oct 2, 2019
817979e
More cleanup in the MappedMgr class.
jaycedowell Oct 2, 2019
5d0a9e3
Updated the dates in the files that were modified as part of this bra…
jaycedowell Oct 2, 2019
a74f24d
Fixed a problem specifying the MAPPED_RING_DIR path in user.mk.
jaycedowell Nov 9, 2019
120da36
Updated the version of PyPy used for testing.
jaycedowell Nov 11, 2019
f9ed7bc
Moved all of the file locking and directory managment features into f…
jaycedowell Mar 18, 2020
9a6750d
Formatting cleanup in memory.cpp.
jaycedowell Mar 18, 2020
1d755d8
Formatting cleanup in memory.h.
jaycedowell Mar 18, 2020
497057a
Clean up some compiler warnings in memory.cpp a la PR #136. Updated …
jaycedowell Mar 18, 2020
4ccffeb
Formatting cleanup.
jaycedowell Jun 9, 2020
9bbac38
Updated memory.cpp so that the BIFROST_MAPPED_RING_DIR enviroment var…
jaycedowell Jun 12, 2020
7d3aa57
Oh yeah, it's not strictly static anymore.
jaycedowell Jun 12, 2020
a489d0e
Switched to a shorter environment variable name for runtime specifica…
jaycedowell Jun 14, 2020
b3338e9
Another iteration of the environemnt variable name. Plus, a note to …
jaycedowell Jun 15, 2020
3abcc4a
Pulled in master.
jaycedowell Jul 23, 2020
e8714cf
Merge remote-tracking branch 'upstream/master' into disk-backed-ring
jaycedowell Feb 13, 2021
772acd2
Merge remote-tracking branch 'upstream/master' into disk-backed-ring
jaycedowell Apr 20, 2021
4ff90d0
Merge branch 'master' into disk-backed-ring
jaycedowell Dec 3, 2021
c4cac5a
Merge remote-tracking branch 'upstream/master' into disk-backed-ring
jaycedowell Mar 22, 2022
2567d99
Rebuild configure.
jaycedowell Mar 22, 2022
e60ae31
Rebuild configure correctly.
jaycedowell Mar 22, 2022
7e89a4c
Bad merge.
jaycedowell Mar 22, 2022
e87ad47
Include the mapped ring directory.
jaycedowell Mar 22, 2022
9e51695
Use config.h instead of CPPFLAGS.
jaycedowell Mar 22, 2022
f0cf402
Updated for BF_MAPPED_RING_DIR.
jaycedowell Mar 22, 2022
dca077f
Rebuild configure.
jaycedowell Mar 22, 2022
39c5a53
Bad fix for a bad merge.
jaycedowell Mar 22, 2022
3b5e7e9
Get the mapped ring space to work on MacOS.
jaycedowell Mar 22, 2022
d7cd7fe
No struct.
jaycedowell Mar 22, 2022
f2cd51a
Ugh, maybe I should switch to my laptop.
jaycedowell Mar 22, 2022
d2c96d0
Changed the default mapped ring directory location.
jaycedowell Mar 23, 2022
58c7281
Rebuild configure (this gets old).
jaycedowell Mar 23, 2022
2ac8b05
Fix segfault under MacOS.
jaycedowell Mar 25, 2022
5e6a6e8
Formatting cleanup.
jaycedowell Mar 25, 2022
ed7ae5d
Reorder to make MacOS happier.
jaycedowell Mar 25, 2022
84b29ba
Style.
jaycedowell Mar 25, 2022
56afbdd
Match the features of #132.
jaycedowell Mar 25, 2022
196e66b
Merge branch 'master' into disk-backed-ring
jaycedowell Mar 29, 2022
86c56e6
Updated for new fileutils function names.
jaycedowell Mar 29, 2022
159ccb4
Updated for the new 'mapped' ring space.
jaycedowell Mar 29, 2022
0693fbb
Avoid warning about catching polymorphic exception by value
league Mar 29, 2022
35f7cd6
Merge branch 'master' into disk-backed-ring
jaycedowell Apr 22, 2022
d4d3376
remove_file_glob -> remove_file.
jaycedowell Apr 22, 2022
fa08729
Octal strikes again.
jaycedowell Apr 22, 2022
0e30bb2
Ignore the libbifrost_generated.py file that is automatically created.
jaycedowell Apr 25, 2022
e6a4dea
Merge remote-tracking branch 'upstream/master' into disk-backed-ring
jaycedowell Aug 3, 2022
d768ed5
Merge remote-tracking branch 'upstream/master' into disk-backed-ring
jaycedowell Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Added set_stream and get_stream to bifrost.device to help control which CUDA stream is used
* Added bifrost.device.ExternalStream as a context manager to help with mixing Bifrost and cupy/pycuda
* Fixed a problem calling bifrost.reduce on a slice of an array
* Added support for a new 'mapped' ring space which is backed by a file on disk

0.10.0
* Switched over to an autotools-based build system
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# https://docs.codecov.com/docs/fixing-paths
fixes:
- "/home/docker/actions-runner/_work/_tool/Python/3.*/x64/lib/python3.*/site-packages/::python/"
ignore:
- "**/libbifrost_generated.py"
18 changes: 18 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ PYBUILDFLAGS
PYTHON3
PYTHON
HAVE_PYTHON
MAPPED_RING_DIR
HAVE_MAP_CACHE
HAVE_CUDA_DEBUG
enable_native_arch
Expand Down Expand Up @@ -862,6 +863,7 @@ enable_debug
enable_trace
enable_native_arch
enable_cuda_debug
with_mapped_ring_dir
enable_map_cache
enable_python
with_python
Expand Down Expand Up @@ -1568,6 +1570,9 @@ Optional Packages:
--with-alignment=N default memory alignment in bytes (default=4096)
--with-logging-dir=DIR directory for Bifrost proclog logging
(default=autodetect)
--with-mapped-ring-dir=...
directory to store mapped ring files in
(default=/tmp/bifrost_mapped)
--with-python=[PATH] absolute path to python executable
--with-pybuild-flags build flags for python (default='')
--with-pyinstall-flags install flags for python (default='')
Expand Down Expand Up @@ -22075,6 +22080,16 @@ then :
NVCCFLAGS="$NVCCFLAGS -G"
fi

# Check whether --with-mapped_ring_dir was given.
if test ${with_mapped_ring_dir+y}
then :
withval=$with_mapped_ring_dir;
else $as_nop
mapped_ring_dir=/tmp/bifrost_mapped
fi

MAPPED_RING_DIR=$mapped_ring_dir

# Check whether --enable-map_cache was given.
if test ${enable_map_cache+y}
then :
Expand Down Expand Up @@ -27057,6 +27072,9 @@ fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: memory alignment: $ALIGNMENT" >&5
printf "%s\n" "$as_me: memory alignment: $ALIGNMENT" >&6;}

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: mapped ring directory: $mapped_ring_dir" >&5
printf "%s\n" "$as_me: mapped ring directory: $mapped_ring_dir" >&6;}

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: logging directory: $HAVE_TMPFS" >&5
printf "%s\n" "$as_me: logging directory: $HAVE_TMPFS" >&6;}

Expand Down
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ AS_IF([test x$enable_cuda_debug != xno],
[AC_SUBST([HAVE_CUDA_DEBUG], [1])
NVCCFLAGS="$NVCCFLAGS -G"])

AC_ARG_WITH([mapped_ring_dir],
[AS_HELP_STRING([--with-mapped-ring-dir=...],
[directory to store mapped ring files in (default=/tmp/bifrost_mapped)])],
[],
[mapped_ring_dir=/tmp/bifrost_mapped])
AC_SUBST([MAPPED_RING_DIR], [$mapped_ring_dir])

AC_ARG_ENABLE([map_cache],
[AS_HELP_STRING([--disable-map-cache],
[disable caching bifrost.map kernels (default=no)])],
Expand Down Expand Up @@ -375,6 +382,8 @@ AS_IF([test x$HAVE_PYTHON = x1],
[AC_MSG_NOTICE(python bindings: no)])

AC_MSG_NOTICE(memory alignment: $ALIGNMENT)

AC_MSG_NOTICE(mapped ring directory: $mapped_ring_dir)

AC_MSG_NOTICE(logging directory: $HAVE_TMPFS)

Expand Down
4 changes: 3 additions & 1 deletion python/bifrost/Space.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@

SPACEMAP_TO_STR = {_bf.BF_SPACE_AUTO: 'auto',
_bf.BF_SPACE_SYSTEM: 'system',
_bf.BF_SPACE_MAPPED: 'mapped',
_bf.BF_SPACE_CUDA: 'cuda',
_bf.BF_SPACE_CUDA_HOST: 'cuda_host',
_bf.BF_SPACE_CUDA_MANAGED: 'cuda_managed'}

SPACEMAP_FROM_STR = {'auto': _bf.BF_SPACE_AUTO,
'system': _bf.BF_SPACE_SYSTEM,
'mapped': _bf.BF_SPACE_MAPPED,
'cuda': _bf.BF_SPACE_CUDA,
'cuda_host': _bf.BF_SPACE_CUDA_HOST,
'cuda_managed': _bf.BF_SPACE_CUDA_MANAGED}

class Space(object):
def __init__(self, s):
if isinstance(s, str):
if s not in set(['auto', 'system',
if s not in set(['auto', 'system', 'mapped',
'cuda', 'cuda_host', 'cuda_managed']):
raise ValueError('Invalid space: %s' % s)
self._space = s
Expand Down
2 changes: 2 additions & 0 deletions python/bifrost/libbifrost.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def _get(func, *args):

STRING2SPACE = {'auto': _bf.BF_SPACE_AUTO,
'system': _bf.BF_SPACE_SYSTEM,
'mapped': _bf.BF_SPACE_MAPPED,
'cuda': _bf.BF_SPACE_CUDA,
'cuda_host': _bf.BF_SPACE_CUDA_HOST,
'cuda_managed': _bf.BF_SPACE_CUDA_MANAGED}
Expand All @@ -192,6 +193,7 @@ def _string2space(s):

SPACE2STRING = {_bf.BF_SPACE_AUTO: 'auto',
_bf.BF_SPACE_SYSTEM: 'system',
_bf.BF_SPACE_MAPPED: 'mapped',
_bf.BF_SPACE_CUDA: 'cuda',
_bf.BF_SPACE_CUDA_HOST: 'cuda_host',
_bf.BF_SPACE_CUDA_MANAGED: 'cuda_managed'}
Expand Down
13 changes: 11 additions & 2 deletions python/bifrost/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ def space_accessible(space, from_spaces):
from_spaces = set(from_spaces)
if space in from_spaces:
return True
elif space in ('system', 'mapped'):
return 'system' in from_spaces \
or 'mapped' in from_spaces \
or 'cuda_host' in from_spaces \
or 'cuda_managed' in from_spaces
elif space == 'cuda_host':
return 'system' in from_spaces
return 'system' in from_spaces \
or 'mapped' in from_spaces \
or 'cuda_managed' in from_spaces
elif space == 'cuda_managed':
return 'system' in from_spaces or 'cuda' in from_spaces
return 'system' in from_spaces \
or 'mapped' in from_spaces \
or 'cuda' in from_spaces
else:
return False

Expand Down
1 change: 1 addition & 0 deletions python/bifrost/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def dot_graph(self, parent_graph=None):
for oring in block.orings:
space_colors = {
'system': 'orange',
'mapped': 'goldenrod',
'cuda': 'limegreen',
'cuda_host': 'deepskyblue'
}
Expand Down
4 changes: 4 additions & 0 deletions python/bifrost/version/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from __future__ import print_function

import os

Check warning on line 31 in python/bifrost/version/__main__.py

View check run for this annotation

Codecov / codecov/patch

python/bifrost/version/__main__.py#L31

Added line #L31 was not covered by tests
import argparse

from bifrost import __version__, __copyright__, __license__
Expand All @@ -49,6 +50,9 @@
print(" NUMA support %s" % _yes_no(BF_NUMA_ENABLED))
print(" Hardware locality support: %s" % _yes_no(BF_HWLOC_ENABLED))
print(" Mellanox messaging accelerator (VMA) support: %s" % _yes_no(BF_VMA_ENABLED))
print(" Mapped ring directory: %s" % BF_MAPPED_RING_DIR)
if os.getenv('BIFROST_MAPPED_DIR') is not None:
print("Mapped ring directory: override - %s" % os.getenv('BIFROST_MAPPED_DIR'))

Check warning on line 55 in python/bifrost/version/__main__.py

View check run for this annotation

Codecov / codecov/patch

python/bifrost/version/__main__.py#L53-L55

Added lines #L53 - L55 were not covered by tests
print(" Logging directory: %s" % BF_PROCLOG_DIR)
print(" Debugging: %s" % _yes_no(BF_DEBUG_ENABLED))
print(" CUDA support: %s" % _yes_no(BF_CUDA_ENABLED))
Expand Down
3 changes: 3 additions & 0 deletions src/bifrost/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ extern "C" {
#define BF_TRACE_ENABLED @HAVE_TRACE@
#define BF_CUDA_DEBUG_ENABLED @HAVE_CUDA_DEBUG@

// Mapped ring directory
#define BF_MAPPED_RING_DIR "@MAPPED_RING_DIR@"

// Logging directory
#define BF_PROCLOG_DIR "@HAVE_TMPFS@"

Expand Down
9 changes: 5 additions & 4 deletions src/bifrost/memory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The Bifrost Authors. All rights reserved.
* Copyright (c) 2016-2019, The Bifrost Authors. All rights reserved.
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -43,9 +43,10 @@ extern "C" {
typedef enum BFspace_ {
BF_SPACE_AUTO = 0,
BF_SPACE_SYSTEM = 1, // aligned_alloc
BF_SPACE_CUDA = 2, // cudaMalloc
BF_SPACE_CUDA_HOST = 3, // cudaHostAlloc
BF_SPACE_CUDA_MANAGED = 4 // cudaMallocManaged
BF_SPACE_MAPPED = 2, // mmapped to a file
BF_SPACE_CUDA = 3, // cudaMalloc
BF_SPACE_CUDA_HOST = 4, // cudaHostAlloc
BF_SPACE_CUDA_MANAGED = 5 // cudaMallocManaged
} BFspace;

BFstatus bfMalloc(void** ptr, BFsize size, BFspace space);
Expand Down
2 changes: 1 addition & 1 deletion src/fileutils.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022, The Bifrost Authors. All rights reserved.
* Copyright (c) 2016-2022, The Bifrost Authors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down
Loading
Loading