Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MemoryProcessing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
数学の武士
MemoryProcessing
Commits
ba45d642
Commit
ba45d642
authored
7 months ago
by
数学の武士
Browse files
Options
Downloads
Patches
Plain Diff
.
parent
ef7ca12d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+10
-1
10 additions, 1 deletion
CMakeLists.txt
include/stacktrace.h
+9
-0
9 additions, 0 deletions
include/stacktrace.h
src/MemoryProcessing.cpp
+25
-1
25 additions, 1 deletion
src/MemoryProcessing.cpp
src/MemoryProcessing.cu
+33
-1
33 additions, 1 deletion
src/MemoryProcessing.cu
with
77 additions
and
3 deletions
CMakeLists.txt
+
10
−
1
View file @
ba45d642
...
...
@@ -7,6 +7,7 @@ option(CXX23_STACKTRACE "Enable C++23 stacktrace" OFF)
enable_language
(
CXX
)
if
(
CXX23_STACKTRACE
)
set
(
CMAKE_CXX_STANDARD 23
)
add_definitions
(
-DINCLUDE_CXX23_STACKTRACE
)
else
(
CXX23_STACKTRACE
)
set
(
CMAKE_CXX_STANDARD 11
)
endif
(
CXX23_STACKTRACE
)
...
...
@@ -36,10 +37,18 @@ if(INCLUDE_CUDA)
)
endif
(
INCLUDE_CUDA
)
if
(
CXX23_STACKTRACE
)
set
(
STACKTRACE_HEADERS
include/stacktrace.h
)
endif
(
CXX23_STACKTRACE
)
set
(
SOURCES
${
SOURCES_CU
}
${
SOURCES_CXX
}
)
set
(
HEADERS
${
HEADERS_CU
}
${
HEADERS_CXX
}
)
set
(
HEADERS
${
HEADERS_CU
}
${
HEADERS_CXX
}
${
STACKTRACE_HEADERS
}
)
add_library
(
memproc STATIC
${
HEADERS
}
${
SOURCES
}
)
target_include_directories
(
memproc PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
if
(
CXX23_STACKTRACE
)
target_link_libraries
(
memproc PUBLIC -lstdc++_libbacktrace
)
endif
(
CXX23_STACKTRACE
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
include/stacktrace.h
0 → 100644
+
9
−
0
View file @
ba45d642
#pragma once
#include
<iostream>
#include
<stacktrace>
void
print_stacktrace
()
{
std
::
cout
<<
std
::
stacktrace
::
current
()
<<
'\n'
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/MemoryProcessing.cpp
+
25
−
1
View file @
ba45d642
#include
"
../include/
MemoryProcessing.h"
#include
"MemoryProcessing.h"
#include
<cstdlib>
#include
<cstring>
#ifdef INCLUDE_CXX23_STACKTRACE
#include
"stacktrace.h"
#endif
namespace
memproc
{
template
<
>
bool
dealloc
<
MemType
::
CPU
>
(
void
*&
array
,
size_t
&
allocated_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
if
(
allocated_size
>
0
)
{
free
(
array
);
...
...
@@ -19,6 +27,10 @@ namespace memproc
template
<
>
bool
dealloc
<
MemType
::
CPU
>
(
void
*&
array
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
free
(
array
);
return
true
;
}
...
...
@@ -26,6 +38,10 @@ namespace memproc
template
<
>
bool
alloc
<
MemType
::
CPU
>
(
void
*&
array
,
const
size_t
new_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
array
=
malloc
(
new_size
);
memset
(
array
,
0
,
new_size
);
...
...
@@ -36,6 +52,10 @@ namespace memproc
template
<
>
bool
realloc
<
MemType
::
CPU
>
(
void
*&
array
,
size_t
&
allocated_size
,
const
size_t
new_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
if
(
new_size
>
allocated_size
)
{
if
(
allocated_size
>
0
)
dealloc
<
MemType
::
CPU
>
(
array
,
allocated_size
);
...
...
@@ -50,6 +70,10 @@ namespace memproc
template
<
>
bool
memcopy
<
MemType
::
CPU
,
MemType
::
CPU
>
(
void
*
dst
,
const
void
*
src
,
const
size_t
copy_elem_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
memcpy
(
dst
,
src
,
copy_elem_size
);
return
true
;
...
...
This diff is collapsed.
Click to expand it.
src/MemoryProcessing.cu
+
33
−
1
View file @
ba45d642
#include
"
../include/
MemoryProcessing.cuh"
#include
"MemoryProcessing.cuh"
#include
<cuda.h>
#include
<cuda_runtime_api.h>
#ifdef INCLUDE_CXX23_STACKTRACE
#include
"stacktrace.h"
#endif
namespace
memproc
{
template
<
>
bool
dealloc
<
MemType
::
GPU
>
(
void
*&
array
,
size_t
&
allocated_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
if
(
allocated_size
>
0
)
{
cudaFree
(
array
);
...
...
@@ -19,6 +27,10 @@ namespace memproc
template
<
>
bool
dealloc
<
MemType
::
GPU
>
(
void
*&
array
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
cudaFree
(
array
);
return
true
;
}
...
...
@@ -26,6 +38,10 @@ namespace memproc
template
<
>
bool
alloc
<
MemType
::
GPU
>
(
void
*&
array
,
const
size_t
new_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
cudaMalloc
(
(
void
**
)
&
array
,
new_size
);
cudaMemset
(
array
,
0
,
new_size
);
...
...
@@ -35,6 +51,10 @@ namespace memproc
template
<
>
bool
realloc
<
MemType
::
GPU
>
(
void
*&
array
,
size_t
&
allocated_size
,
const
size_t
new_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
if
(
new_size
>
allocated_size
)
{
if
(
allocated_size
>
0
)
dealloc
<
MemType
::
GPU
>
(
array
,
allocated_size
);
...
...
@@ -49,6 +69,10 @@ namespace memproc
template
<
>
bool
memcopy
<
MemType
::
GPU
,
MemType
::
CPU
>
(
void
*
dst
,
const
void
*
src
,
const
size_t
copy_elem_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
cudaMemcpy
(
dst
,
src
,
copy_elem_size
,
cudaMemcpyHostToDevice
);
return
true
;
...
...
@@ -57,6 +81,10 @@ namespace memproc
template
<
>
bool
memcopy
<
MemType
::
CPU
,
MemType
::
GPU
>
(
void
*
dst
,
const
void
*
src
,
const
size_t
copy_elem_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
cudaMemcpy
(
dst
,
src
,
copy_elem_size
,
cudaMemcpyDeviceToHost
);
return
true
;
}
...
...
@@ -64,6 +92,10 @@ namespace memproc
template
<
>
bool
memcopy
<
MemType
::
GPU
,
MemType
::
GPU
>
(
void
*
dst
,
const
void
*
src
,
const
size_t
copy_elem_size
)
{
#ifdef INCLUDE_CXX23_STACKTRACE
print_stacktrace
();
#endif
cudaMemcpy
(
dst
,
src
,
copy_elem_size
,
cudaMemcpyDeviceToDevice
);
return
true
;
}
...
...
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