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
74b215b2
Commit
74b215b2
authored
9 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Small fix in Preallocated memory sequence
parent
bb547f41
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/memory/CudaMemory.cu
+2
-2
2 additions, 2 deletions
src/memory/CudaMemory.cu
src/memory/ExtPreAlloc.hpp
+31
-2
31 additions, 2 deletions
src/memory/ExtPreAlloc.hpp
with
33 additions
and
4 deletions
src/memory/CudaMemory.cu
+
2
−
2
View file @
74b215b2
...
...
@@ -178,10 +178,10 @@ bool CudaMemory::resize(size_t sz)
if
(
size
()
==
0
)
return
allocate
(
sz
);
//! Create a new buffer if sz is bigger than the actual size
//! Create a new buffer
,
if sz is bigger than the actual size
void
*
thm
;
//! Create a new buffer if sz is bigger than the actual size
//! Create a new buffer
,
if sz is bigger than the actual size
void
*
tdm
;
if
(
dm
!=
NULL
)
...
...
This diff is collapsed.
Click to expand it.
src/memory/ExtPreAlloc.hpp
+
31
−
2
View file @
74b215b2
...
...
@@ -7,6 +7,8 @@
#ifndef EXTPREALLOC_HPP_
#define EXTPREALLOC_HPP_
#include
<stddef.h>
/*! Preallocated memory sequence
*
* External pre-allocated memory, is a class that preallocate memory and than it answer
...
...
@@ -37,6 +39,7 @@ class ExtPreAlloc : public memory
long
int
ref_cnt
;
ExtPreAlloc
(
const
ExtPreAlloc
&
ext
)
:
a_seq
(
0
),
mem
(
NULL
),
ref_cnt
(
0
)
{}
public
:
...
...
@@ -49,7 +52,7 @@ public:
//! Default constructor
ExtPreAlloc
()
:
a_seq
(
0
),
ref_cnt
(
0
)
:
a_seq
(
0
),
mem
(
NULL
),
ref_cnt
(
0
)
{
}
...
...
@@ -75,7 +78,7 @@ public:
// Resize the sequence
sequence
.
resize
(
seq
.
size
());
sequence_c
.
resize
(
seq
.
size
());
sequence_c
.
resize
(
seq
.
size
()
+
1
);
for
(
size_t
i
=
0
;
i
<
seq
.
size
()
;
i
++
)
{
sequence
[
i
]
=
seq
[
i
];
...
...
@@ -83,6 +86,7 @@ public:
total_size
+=
seq
[
i
];
}
sequence_c
[
seq
.
size
()]
=
total_size
;
// Allocate the total size of memory
mem
.
allocate
(
total_size
);
...
...
@@ -143,6 +147,16 @@ public:
return
(((
unsigned
char
*
)
mem
->
getPointer
())
+
sequence_c
[
a_seq
-
1
]);
}
/*! \brief Return a readable pointer with your data
*
* \param ip index of the pointer in the sequence
*
*/
virtual
void
*
getPointer
(
size_t
ip
)
{
return
(((
unsigned
char
*
)
mem
->
getPointer
())
+
sequence_c
[
ip
]);
}
/*! \brief Allocate or resize the allocated memory
*
* Resize the allocated memory, if request is smaller than the allocated, memory
...
...
@@ -201,6 +215,21 @@ public:
{
return
false
;
}
/*! \brief Calculate the total memory required to pack the message
*
* \return the total required memory
*
*/
static
size_t
calculateMem
(
std
::
vector
<
size_t
>
&
mm
)
{
size_t
s
=
0
;
for
(
size_t
i
=
0
;
i
<
mm
.
size
()
;
i
++
)
s
+=
mm
[
i
];
return
s
;
}
};
#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