Replace cuNormalizer holder class with unique_ptr
parent
14d708863d
commit
a0ce9d55cb
|
@ -553,17 +553,18 @@ cuAmpcorChunk::cuAmpcorChunk(cuAmpcorParameter *param_, GDALImage *reference_, G
|
|||
stream);
|
||||
}
|
||||
|
||||
corrNormalizerRaw = new cuNormalizer(
|
||||
corrNormalizerRaw = std::unique_ptr<cuNormalizeProcessor>(newCuNormalizer(
|
||||
param->searchWindowSizeHeightRaw,
|
||||
param->searchWindowSizeWidthRaw,
|
||||
param->numberWindowDownInChunk * param->numberWindowAcrossInChunk
|
||||
);
|
||||
));
|
||||
|
||||
corrNormalizerOverSampled = new cuNormalizer(
|
||||
corrNormalizerOverSampled =
|
||||
std::unique_ptr<cuNormalizeProcessor>(newCuNormalizer(
|
||||
param->searchWindowSizeHeight,
|
||||
param->searchWindowSizeWidth,
|
||||
param->numberWindowDownInChunk * param->numberWindowAcrossInChunk
|
||||
);
|
||||
));
|
||||
|
||||
|
||||
#ifdef CUAMPCOR_DEBUG
|
||||
|
|
|
@ -66,8 +66,8 @@ private:
|
|||
cuFreqCorrelator *cuCorrFreqDomain, *cuCorrFreqDomain_OverSampled;
|
||||
|
||||
// correlation surface normalizer
|
||||
cuNormalizer *corrNormalizerRaw;
|
||||
cuNormalizer *corrNormalizerOverSampled;
|
||||
std::unique_ptr<cuNormalizeProcessor> corrNormalizerRaw;
|
||||
std::unique_ptr<cuNormalizeProcessor> corrNormalizerOverSampled;
|
||||
|
||||
// save offset results in different stages
|
||||
cuArrays<int2> *offsetInit;
|
||||
|
|
|
@ -7,45 +7,30 @@
|
|||
#include "cuCorrNormalizer.h"
|
||||
#include "cuAmpcorUtil.h"
|
||||
|
||||
cuNormalizer::cuNormalizer(int secondaryNX, int secondaryNY, int count)
|
||||
cuNormalizeProcessor*
|
||||
newCuNormalizer(int secondaryNX, int secondaryNY, int count)
|
||||
{
|
||||
// depending on NY, choose different processor
|
||||
if(secondaryNY <= 64) {
|
||||
processor = new cuNormalizeFixed<64>();
|
||||
return new cuNormalizeFixed<64>();
|
||||
}
|
||||
else if (secondaryNY <= 128) {
|
||||
processor = new cuNormalizeFixed<128>();
|
||||
return new cuNormalizeFixed<128>();
|
||||
}
|
||||
else if (secondaryNY <= 256) {
|
||||
processor = new cuNormalizeFixed<256>();
|
||||
return new cuNormalizeFixed<256>();
|
||||
}
|
||||
else if (secondaryNY <= 512) {
|
||||
processor = new cuNormalizeFixed<512>();
|
||||
return new cuNormalizeFixed<512>();
|
||||
}
|
||||
else if (secondaryNY <= 1024) {
|
||||
processor = new cuNormalizeFixed<1024>();
|
||||
return new cuNormalizeFixed<1024>();
|
||||
}
|
||||
else {
|
||||
processor = new cuNormalizeSAT(secondaryNX, secondaryNY, count);
|
||||
return new cuNormalizeSAT(secondaryNX, secondaryNY, count);
|
||||
}
|
||||
}
|
||||
|
||||
cuNormalizer::~cuNormalizer()
|
||||
{
|
||||
delete processor;
|
||||
}
|
||||
|
||||
void cuNormalizer::execute(cuArrays<float> *correlation,
|
||||
cuArrays<float> *reference, cuArrays<float> *secondary, cudaStream_t stream)
|
||||
{
|
||||
processor->execute(correlation, reference, secondary, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
cuNormalizeSAT::cuNormalizeSAT(int secondaryNX, int secondaryNY, int count)
|
||||
{
|
||||
// allocate the work array
|
||||
|
|
|
@ -22,26 +22,14 @@
|
|||
class cuNormalizeProcessor {
|
||||
public:
|
||||
// default constructor and destructor
|
||||
cuNormalizeProcessor() {}
|
||||
~cuNormalizeProcessor() {}
|
||||
cuNormalizeProcessor() = default;
|
||||
virtual ~cuNormalizeProcessor() = default;
|
||||
// execute interface
|
||||
virtual void execute(cuArrays<float> * correlation, cuArrays<float> *reference, cuArrays<float> *secondary, cudaStream_t stream) = 0;
|
||||
};
|
||||
|
||||
class cuNormalizer {
|
||||
private:
|
||||
cuNormalizeProcessor *processor;
|
||||
public:
|
||||
// disable the default constructor
|
||||
cuNormalizer() = delete;
|
||||
// constructor with the secondary dimension
|
||||
cuNormalizer(int secondaryNX, int secondaryNY, int count);
|
||||
// destructor
|
||||
~cuNormalizer();
|
||||
// execute correlation surface normalization
|
||||
void execute(cuArrays<float> *correlation, cuArrays<float> *reference, cuArrays<float> *secondary,
|
||||
cudaStream_t stream);
|
||||
};
|
||||
// factory with the secondary dimension
|
||||
cuNormalizeProcessor* newCuNormalizer(int NX, int NY, int count);
|
||||
|
||||
|
||||
template<int Size>
|
||||
|
|
Loading…
Reference in New Issue