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
d46372d3
Commit
d46372d3
authored
8 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Fixing Cuda compilation
parent
8595ed09
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
+33
-7
33 additions, 7 deletions
src/memory/CudaMemory.cu
src/memory/CudaMemory.cuh
+11
-8
11 additions, 8 deletions
src/memory/CudaMemory.cuh
with
44 additions
and
15 deletions
src/memory/CudaMemory.cu
+
33
−
7
View file @
d46372d3
...
...
@@ -55,7 +55,7 @@ void CudaMemory::destroy()
*
*/
void
CudaMemory
::
allocate_host
(
size_t
sz
)
void
CudaMemory
::
allocate_host
(
size_t
sz
)
const
{
if
(
hm
==
NULL
)
{
...
...
@@ -74,7 +74,7 @@ void CudaMemory::allocate_host(size_t sz)
* \param ptr
* \return true if success
*/
bool
CudaMemory
::
copyFromPointer
(
void
*
ptr
)
bool
CudaMemory
::
copyFromPointer
(
const
void
*
ptr
)
{
// check if we have a host buffer, if not allocate it
...
...
@@ -87,7 +87,7 @@ bool CudaMemory::copyFromPointer(void * ptr)
// memory copy
memcpy
(
ptr
,
dvp
,
sz
);
memcpy
(
dvp
,
ptr
,
sz
);
return
true
;
}
...
...
@@ -100,7 +100,7 @@ bool CudaMemory::copyFromPointer(void * ptr)
*
* \return true is success
*/
bool
CudaMemory
::
copyDeviceToDevice
(
CudaMemory
&
m
)
bool
CudaMemory
::
copyDeviceToDevice
(
const
CudaMemory
&
m
)
{
//! The source buffer is too big to copy it
...
...
@@ -123,10 +123,10 @@ bool CudaMemory::copyDeviceToDevice(CudaMemory & m)
* \param m a memory interface
*
*/
bool
CudaMemory
::
copy
(
memory
&
m
)
bool
CudaMemory
::
copy
(
const
memory
&
m
)
{
//! Here we try to cast memory into OpenFPMwdeviceCudaMemory
CudaMemory
*
ofpm
=
dynamic_cast
<
CudaMemory
*>
(
&
m
);
const
CudaMemory
*
ofpm
=
dynamic_cast
<
const
CudaMemory
*>
(
&
m
);
//! if we fail we get the pointer and simply copy from the pointer
...
...
@@ -152,11 +152,12 @@ bool CudaMemory::copy(memory & m)
*
*/
size_t
CudaMemory
::
size
()
size_t
CudaMemory
::
size
()
const
{
return
sz
;
}
/*! \brief Resize the allocated memory
*
* Resize the allocated memory, if request is smaller than the allocated memory
...
...
@@ -241,3 +242,28 @@ void * CudaMemory::getPointer()
return
hm
;
}
/*! \brief Return a readable pointer with your data
*
* Return a readable pointer with your data
*
*/
const
void
*
CudaMemory
::
getPointer
()
const
{
//| allocate an host memory if not allocated
if
(
hm
==
NULL
)
allocate_host
(
sz
);
//! if the host buffer is synchronized with the device buffer return the host buffer
if
(
is_hm_sync
)
return
hm
;
//! copy from device to host memory
CUDA_SAFE_CALL
(
cudaMemcpy
(
hm
,
dm
,
sz
,
cudaMemcpyDeviceToHost
));
return
hm
;
}
This diff is collapsed.
Click to expand it.
src/memory/CudaMemory.cuh
+
11
−
8
View file @
d46372d3
...
...
@@ -46,13 +46,19 @@ class CudaMemory : public memory
void
*
dm
;
//! host memory
void
*
hm
;
mutable
void
*
hm
;
//! Reference counter
size_t
ref_cnt
;
//! Allocate an host buffer
void
allocate_host
(
size_t
sz
);
void
allocate_host
(
size_t
sz
)
const
;
//! copy from GPU to GPU buffer directly
bool
copyDeviceToDevice
(
const
CudaMemory
&
m
);
//! copy from Pointer to GPU
bool
copyFromPointer
(
const
void
*
ptr
);
public:
...
...
@@ -63,17 +69,14 @@ public:
//! copy from a General device
virtual
bool
copy
(
const
memory
&
m
);
//! the the size of the allocated memory
virtual
size_t
size
();
virtual
size_t
size
()
const
;
//! resize the momory allocated
virtual
bool
resize
(
size_t
sz
);
//! get a readable pointer with the data
void
*
getPointer
();
//! copy from GPU to GPU buffer directly
bool
copyDeviceToDevice
(
CudaMemory
&
m
);
//! copy from Pointer to GPU
bool
copyFromPointer
(
void
*
ptr
);
//! get a readable pointer with the data
virtual
const
void
*
getPointer
()
const
;
//! This function notify that the device memory is not sync with
//! the host memory, is called when a task is performed that write
...
...
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