-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GPU] Global Buffer manager and optimization
Implemented global Buffers Optimized pipeline due to reduced buffer creation steps Modifed command queue and Buffer wrappers Signed-off-by: Debadri Samaddar <[email protected]>
- Loading branch information
Showing
11 changed files
with
319 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/** | ||
* Copyright (C) 2024 Debadri Samaddar <[email protected]> | ||
* | ||
* @file cl_buffer_manager.cpp | ||
* @date 01 Dec 2024 | ||
* @see https://github.com/nnstreamer/nntrainer | ||
* @author Debadri Samaddar <[email protected]> | ||
* @bug No known bugs except for NYI items | ||
* @brief This file contains global Buffer objects and manages them | ||
*/ | ||
|
||
#include <cl_buffer_manager.h> | ||
|
||
namespace nntrainer { | ||
|
||
ClBufferManager &ClBufferManager::getInstance() { | ||
static ClBufferManager instance; | ||
return instance; | ||
} | ||
|
||
// to-do: Implementation to be updated with array of Buffer objects if required | ||
// fp16 Buffer objects to be added in future | ||
ClBufferManager::ClBufferManager() { | ||
readBufferA = new opencl::Buffer(context_inst_, buffer_size_bytes, true); | ||
readBufferB = new opencl::Buffer(context_inst_, buffer_size_bytes, true); | ||
readBufferC = new opencl::Buffer(context_inst_, buffer_size_bytes, true); | ||
writeBufferA = new opencl::Buffer(context_inst_, buffer_size_bytes, false); | ||
writeBufferB = new opencl::Buffer(context_inst_, buffer_size_bytes, false); | ||
ml_logi("ClBufferManager: Buffers initialized"); | ||
} | ||
|
||
ClBufferManager::~ClBufferManager() { | ||
delete readBufferA; | ||
delete readBufferB; | ||
delete readBufferC; | ||
delete writeBufferA; | ||
delete writeBufferB; | ||
} | ||
|
||
} // namespace nntrainer |
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,72 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/** | ||
* Copyright (C) 2024 Debadri Samaddar <[email protected]> | ||
* | ||
* @file cl_buffer_manager.h | ||
* @date 01 Dec 2024 | ||
* @see https://github.com/nnstreamer/nntrainer | ||
* @author Debadri Samaddar <[email protected]> | ||
* @bug No known bugs except for NYI items | ||
* @brief This file contains global Buffer objects and manages them | ||
*/ | ||
|
||
#ifndef __CL_BUFFER_MANAGER_H__ | ||
#define __CL_BUFFER_MANAGER_H__ | ||
|
||
#include <string> | ||
|
||
#include <opencl_buffer.h> | ||
#include <opencl_context_manager.h> | ||
|
||
#include <nntrainer_log.h> | ||
|
||
namespace nntrainer { | ||
|
||
/** | ||
* @class ClBufferManager contains Buffer object management | ||
* @brief Support for Buffer management | ||
*/ | ||
|
||
class ClBufferManager { | ||
|
||
private: | ||
/** | ||
* @brief Private constructor to prevent object creation | ||
* | ||
*/ | ||
ClBufferManager(); | ||
|
||
/** | ||
* @brief OpenCl context global instance | ||
* | ||
*/ | ||
opencl::ContextManager &context_inst_ = opencl::ContextManager::GetInstance(); | ||
|
||
/** | ||
* @brief Buffer size in bytes preset (256 mebibytes) | ||
*/ | ||
size_t buffer_size_bytes = 8192 * 8192 * sizeof(float); | ||
|
||
public: | ||
/** | ||
* @brief Get Global ClBufferManager. | ||
* | ||
* @return ClBufferManager& | ||
*/ | ||
static ClBufferManager &getInstance(); | ||
|
||
opencl::Buffer *readBufferA; | ||
opencl::Buffer *readBufferB; | ||
opencl::Buffer *readBufferC; | ||
opencl::Buffer *writeBufferA; | ||
opencl::Buffer *writeBufferB; | ||
|
||
/** | ||
* @brief Destroy Buffer pointers. | ||
* | ||
*/ | ||
~ClBufferManager(); | ||
}; | ||
} // namespace nntrainer | ||
|
||
#endif /* __CL_BUFFER_MANAGER_H__ */ |
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
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
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
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
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
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
Oops, something went wrong.