GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Functions | Variables
cu_temp_buffer_malloc.cpp File Reference
#include "ghost/cu_temp_buffer_malloc.h"
#include "ghost/error.h"
#include "ghost/log.h"
#include "ghost/util.h"
#include <algorithm>
#include <iostream>
#include <mutex>
#include <thread>
#include <vector>
Include dependency graph for cu_temp_buffer_malloc.cpp:

Classes

struct  SmallBuffer
 

Functions

ghost_error ghost_cu_temp_buffer_malloc (void **mem, size_t bytesize)
 Useful for allocating small temporary buffers. Keeps a list of previously allocated and freed buffers, and returns one if the size fits. Threadsafe. More...
 
ghost_error ghost_cu_temp_buffer_free (void *mem)
 Frees memory allocated with ghost_cu_temp_buffer_malloc. Threadsafe. More...
 

Variables

vector< SmallBufferbuffers
 
std::mutex cu_temp_buffer_malloc_mutex
 
unsigned int peakBufferCount = 0
 

Function Documentation

ghost_error ghost_cu_temp_buffer_free ( void *  mem)

Frees memory allocated with ghost_cu_temp_buffer_malloc. Threadsafe.

Parameters
memWhich address to free
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_temp_buffer_malloc ( void **  mem,
size_t  bytesize 
)

Useful for allocating small temporary buffers. Keeps a list of previously allocated and freed buffers, and returns one if the size fits. Threadsafe.

Parameters
memWhere to store the memory.
bytesizeThe number of bytes to allocate.
Returns
GHOST_SUCCESS on success or an error indicator.

Variable Documentation

vector<SmallBuffer> buffers
std::mutex cu_temp_buffer_malloc_mutex
unsigned int peakBufferCount = 0