-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallel_solution_baseline.cuh
64 lines (45 loc) · 2.51 KB
/
parallel_solution_baseline.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include "solution.cuh"
#include "utils.cuh"
namespace KernelFunction {
__device__ __host__ u_int32_t convertIndex(u_int32_t i, u_int32_t j, u_int32_t n);
__global__ void
convertToGrayScaleKernel(const uchar3 *input, u_int32_t inputWidth, u_int32_t inputHeight, int32_t *output);
__global__ void
convolutionKernel(const int32_t *input, u_int32_t inputWidth, u_int32_t inputHeight, const int32_t *filter,
u_int32_t filterSize, int32_t *output);
__global__ void
addAbsKernel(const int32_t *input_1, const int32_t *input_2, u_int32_t inputWidth, u_int32_t inputHeight,
int32_t *output);
__global__ void
updateSeamMapKernel(int32_t *input, u_int32_t inputWidth,
int32_t currentRow);
__global__ void
deleteSeamKernel(const uchar3 *input, u_int32_t inputWidth, u_int32_t inputHeight, const u_int32_t *seam,
uchar3 *output);
__global__ void
deleteSeamKernel(const int32_t *input, u_int32_t inputWidth, u_int32_t inputHeight, const u_int32_t *seam,
int32_t *output);
}
class ParallelSolutionBaseline : public BaseSolution {
public:
static const u_int32_t FILTER_SIZE = 3;
protected:
static const int32_t SOBEL_X[3][3];
static const int32_t SOBEL_Y[3][3];
static void convertToGrayScale(const uchar3 *d_inputImage, uint32_t inputWidth, uint32_t inputHeight,
dim3 blockSize, int32_t *d_outputImage);
static void
calculateEnergyMap(const int32_t *d_inputImage, uint32_t inputWidth, uint32_t inputHeight, const int32_t *d_filterX,
const int32_t *d_filterY, uint32_t filterSize, dim3 blockSize, int32_t *d_outputImage);
static void calculateSeamMap(int32_t *d_inputImage, uint32_t inputWidth, uint32_t inputHeight, uint32_t blockSize);
static void extractSeam(const int32_t *energyMap, uint32_t inputWidth, uint32_t inputHeight, uint32_t *seam);
static void deleteSeam(const int32_t *d_inputImage, uint32_t inputWidth, uint32_t inputHeight, const uint32_t *seam,
dim3 blockSize, int32_t *d_outputImage);
static void deleteSeam(const uchar3 *d_inputImage, uint32_t inputWidth, uint32_t inputHeight, const uint32_t *seam,
dim3 blockSize, uchar3 *d_outputImage);
static void swap(int32_t *&pa, int32_t *&pb);
static void swap(uchar3 *&pa, uchar3 *&pb);
public:
PnmImage run(const PnmImage &inputImage, int argc, char **argv) override;
};