Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_devices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_devices
Commits
29b28ccc
Commit
29b28ccc
authored
7 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Plain Diff
Merge branch 'GPU_test' of git.mpi-cbg.de:openfpm/openfpm_devices into GPU_test
parents
7529e69f
c09e850f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/memory/ExtPreAlloc.hpp
+62
-5
62 additions, 5 deletions
src/memory/ExtPreAlloc.hpp
with
62 additions
and
5 deletions
src/memory/ExtPreAlloc.hpp
+
62
−
5
View file @
29b28ccc
...
...
@@ -26,14 +26,15 @@
template
<
typename
Mem
>
class
ExtPreAlloc
:
public
memory
{
// Actual allocation pointer
//
!
Actual allocation pointer
size_t
a_seq
;
// Last allocation size
//
!
Last allocation size
size_t
l_size
;
// Main class for memory allocation
//
!
Main class for memory allocation
Mem
*
mem
;
//! Reference counter
long
int
ref_cnt
;
...
...
@@ -94,11 +95,10 @@ public:
if
(
sz
==
0
)
return
true
;
// Check that the size match
a_seq
=
l_size
;
l_size
+=
sz
;
// Check we do not overflow the allocated memory
#ifdef SE_CLASS1
if
(
l_size
>
mem
->
size
())
...
...
@@ -242,6 +242,63 @@ public:
return
s
;
}
/*! \brief shift the pointer backward
*
* \warning when you shift backward the pointer, the last allocation is lost
* this mean that you have to do again an allocation.
*
* This function is useful to go ahead in memory and fill the memory later on
*
* \code
mem.allocate(16); <------ Here we allocate 16 byte but we do not fill it because
subsequently we do another allocation without using mem
unsigned char * start = (unsigned char *)mem.getPointer()
mem.allocate(100)
// ...
// ...
// Code that fill mem in some way and do other mem.allocate(...)
// ...
// ...
unsigned char * final = (unsigned char *)mem.getPointer()
mem.shift_backward(final - start);
mem.allocate(16); <------ Here I am getting the same memory that I request for the
first allocate
// we now fill the memory
\endcode
*
*
*
* \param how many byte to shift
*
*/
void
shift_backward
(
size_t
sz
)
{
a_seq
-=
sz
;
l_size
=
a_seq
;
}
/*! \brief shift the pointer forward
*
* The same as shift backward, but in this case it move the pointer forward
*
* In general you use this function after the you went back with shift_backward
* and you have to move forward again
*
* \warning when you shift forward the pointer, the last allocation is lost
* this mean that you have to do again an allocation.
*
*/
void
shift_forward
(
size_t
sz
)
{
a_seq
+=
sz
;
l_size
=
a_seq
;
}
};
#endif
/* PREALLOCHEAPMEMORY_HPP_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment