-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
based on gw_enable_caching_allocator This way, after the library is built and installed, the user does not need to specify `-DGW_ENABLE_CACHING_ALLOCATOR`, which would select the DefaultDeviceAllocator to use.
- Loading branch information
Christopher Dunn
committed
Feb 23, 2021
1 parent
52024f5
commit 008f8cd
Showing
5 changed files
with
161 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
common/base/include/claraparabricks/genomeworks/utils/allocator.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2019-2020 NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include @GW_USE_DEVICE_ALLOCATOR_FILE@ | ||
|
||
namespace claraparabricks | ||
{ | ||
|
||
namespace genomeworks | ||
{ | ||
|
||
/// Gets the size of the largest free memory block in the allocator | ||
/// | ||
/// @see create_default_device_allocator | ||
/// \return returns the size in bytes | ||
inline int64_t get_size_of_largest_free_memory_block(DefaultDeviceAllocator const& allocator) | ||
{ | ||
return allocator.get_size_of_largest_free_memory_block(); | ||
} | ||
|
||
} // namespace genomeworks | ||
|
||
} // namespace claraparabricks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
common/base/include/claraparabricks/genomeworks/utils/use_caching_device_allocator.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2019-2020 NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef GW_INCLUDED_DEVICE_ALLOCATOR_HPP | ||
#define GW_INCLUDED_DEVICE_ALLOCATOR_HPP | ||
|
||
#ifdef GW_ENABLE_CACHING_ALLOCATOR | ||
#warning "GW_ENABLE_CACHING_ALLOCATOR should not be already set." | ||
#else | ||
#define GW_ENABLE_CACHING_ALLOCATOR | ||
#endif | ||
|
||
#include "allocators.hpp" | ||
|
||
namespace claraparabricks | ||
{ | ||
|
||
namespace genomeworks | ||
{ | ||
|
||
using DefaultDeviceAllocator = CachingDeviceAllocator<char, details::DevicePreallocatedAllocator>; | ||
|
||
/// Constructs a DefaultDeviceAllocator | ||
/// | ||
/// This function provides a way to construct a valid DefaultDeviceAllocator | ||
/// for all possible DefaultDeviceAllocators. | ||
/// Use this function to obtain a DefaultDeviceAllocator object. | ||
/// This function is needed, since construction of CachingDeviceAllocator | ||
/// requires a max_caching_size argument to obtain a valid allocator. | ||
/// Default constuction of CachingDeviceAllocator yields an dummy object | ||
/// which cannot allocate memory. | ||
/// \param max_cached_bytes max bytes used by memory resource used by CachingDeviceAllocator (default: 2GiB) | ||
/// \param default_stream if a call to allocate() does not specify any streams this stream will be used instead | ||
inline DefaultDeviceAllocator create_default_device_allocator(std::size_t max_caching_size = 2ull * 1024 * 1024 * 1024, | ||
cudaStream_t default_stream = 0) | ||
{ | ||
return DefaultDeviceAllocator(max_caching_size, | ||
default_stream); | ||
} | ||
|
||
} // namespace genomeworks | ||
|
||
} // namespace claraparabricks | ||
|
||
#else | ||
#error "Attempted to included 2 DeviceAllocators!" | ||
#endif |
58 changes: 58 additions & 0 deletions
58
common/base/include/claraparabricks/genomeworks/utils/use_cuda_malloc_allocator.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2019-2020 NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef GW_INCLUDED_DEVICE_ALLOCATOR_HPP | ||
#define GW_INCLUDED_DEVICE_ALLOCATOR_HPP | ||
|
||
#ifdef GW_ENABLE_CACHING_ALLOCATOR | ||
#warning "GW_ENABLE_CACHING_ALLOCATOR should not be set for CudaMallocAllocator." | ||
#undef GW_ENABLE_CACHING_ALLOCATOR | ||
#endif | ||
|
||
namespace claraparabricks | ||
{ | ||
|
||
namespace genomeworks | ||
{ | ||
|
||
using DefaultDeviceAllocator = CudaMallocAllocator<char>; | ||
|
||
/// Constructs a DefaultDeviceAllocator | ||
/// | ||
/// This function provides a way to construct a valid DefaultDeviceAllocator | ||
/// for all possible DefaultDeviceAllocators. | ||
/// Use this function to obtain a DefaultDeviceAllocator object. | ||
/// This function is needed, since construction of CachingDeviceAllocator | ||
/// requires a max_caching_size argument to obtain a valid allocator. | ||
/// Default constuction of CachingDeviceAllocator yields an dummy object | ||
/// which cannot allocate memory. | ||
/// \param max_cached_bytes max bytes used by memory resource used by CachingDeviceAllocator (unused) | ||
/// \param default_stream if a call to allocate() does not specify any streams this stream will be used instead (unused) | ||
inline DefaultDeviceAllocator create_default_device_allocator(std::size_t max_caching_size = 2ull * 1024 * 1024 * 1024, | ||
cudaStream_t default_stream = 0) | ||
{ | ||
static_cast<void>(max_caching_size); | ||
static_cast<void>(default_stream); | ||
return DefaultDeviceAllocator(); | ||
} | ||
|
||
} // namespace genomeworks | ||
|
||
} // namespace claraparabricks | ||
|
||
#else | ||
#error "Attempted to included 2 DeviceAllocators!" | ||
#endif |