Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hydra-image-processor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
OpenSource
hydra-image-processor
Commits
6362f483
Commit
6362f483
authored
7 years ago
by
Eric Wait
Browse files
Options
Downloads
Patches
Plain Diff
Added a kernel class to hold the const kernel
parent
525c408c
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/c/Cuda/Kernel.cu
+38
-0
38 additions, 0 deletions
src/c/Cuda/Kernel.cu
src/c/Cuda/Kernel.cuh
+28
-0
28 additions, 0 deletions
src/c/Cuda/Kernel.cuh
with
66 additions
and
0 deletions
src/c/Cuda/Kernel.cu
0 → 100644
+
38
−
0
View file @
6362f483
#include
"Kernel.cuh"
#include
"CudaUtilities.cuh"
Kernel
::
Kernel
(
Vec
<
size_t
>
dimensions
)
{
dims
=
dimensions
;
kernel
.
resize
(
dims
.
product
());
HANDLE_ERROR
(
cudaMemcpyToSymbol
(
cudaConstKernel
,
kernel
.
data
(),
sizeof
(
float
)
*
dims
.
product
()));
}
Kernel
::
Kernel
(
Vec
<
size_t
>
dimensions
,
float
*
values
)
{
dims
=
dimensions
;
if
(
values
==
NULL
)
{
setOnes
();
}
else
{
kernel
.
resize
(
dims
.
product
());
memcpy
(
kernel
.
data
(),
values
,
sizeof
(
float
)
*
dims
.
product
());
}
HANDLE_ERROR
(
cudaMemcpyToSymbol
(
cudaConstKernel
,
kernel
.
data
(),
sizeof
(
float
)
*
dims
.
product
()));
}
void
Kernel
::
setOnes
()
{
for
(
int
i
=
0
;
i
<
dims
.
product
();
++
i
)
kernel
.
push_back
(
1
);
}
This diff is collapsed.
Click to expand it.
src/c/Cuda/Kernel.cuh
0 → 100644
+
28
−
0
View file @
6362f483
#pragma once
#include
"Vec.h"
#include
<cuda_runtime.h>
#include
<vector>
#ifndef CUDA_CONST_KERNEL
#define CUDA_CONST_KERNEL
__constant__
float
cudaConstKernel
[
MAX_KERNEL_DIM
*
MAX_KERNEL_DIM
*
MAX_KERNEL_DIM
];
#endif
class
Kernel
{
public:
Kernel
(
Vec
<
size_t
>
dimensions
);
Kernel
(
Vec
<
size_t
>
dimensions
,
float
*
values
);
~
Kernel
()
{
kernel
.
clear
();
}
Vec
<
size_t
>
getDimensions
()
const
{
return
dims
;
}
const
float
*
getConstPtr
()
const
{
return
kernel
.
data
();
}
private
:
Kernel
();
void
setOnes
();
std
::
vector
<
float
>
kernel
;
Vec
<
size_t
>
dims
;
};
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