Skip to content

Commit 9f94a52

Browse files
committed
Another approach to test
1 parent 0991c48 commit 9f94a52

File tree

4 files changed

+80
-47
lines changed

4 files changed

+80
-47
lines changed

examples/Example_get_apr.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,25 @@ int runAPR(cmdLineOptions options) {
148148
int main(int argc, char **argv) {
149149

150150
//input parsing
151-
cmdLineOptions options;
152-
153-
options = read_command_line_options(argc, argv);
154-
std::vector<std::future<int>> fv;
155-
fv.emplace_back(std::async(std::launch::async, [=]{ return runAPR(options); }));
156-
fv.emplace_back(std::async(std::launch::async, [=]{ return runAPR(options); }));
157-
fv.emplace_back(std::async(std::launch::async, [=]{ return runAPR(options); }));
158-
int n = 3;
159-
std::cout << "Waintig..." <<std::endl;
160-
for (int i = 0; i < fv.size()*3; ++i) {
161-
fv[i % n].wait();
162-
fv[i % n] = std::async(std::launch::async, [=]{ return runAPR(options); });
163-
}
164-
165-
for (int i = 0; i < fv.size(); ++i) fv[i].wait();
166-
167-
std::cout << "DONE!" <<std::endl;
168-
return fv[0].get();
151+
cmdLineOptions options = read_command_line_options(argc, argv);
152+
153+
// std::vector<std::future<int>> fv;
154+
// fv.emplace_back(std::async(std::launch::async, [=]{ return runAPR(options); }));
155+
// fv.emplace_back(std::async(std::launch::async, [=]{ return runAPR(options); }));
156+
// fv.emplace_back(std::async(std::launch::async, [=]{ return runAPR(options); }));
157+
// int n = 2;
158+
// fv[0].
159+
// std::cout << "Waintig..." <<std::endl;
160+
// for (int i = 0; i < fv.size()*3; ++i) {
161+
// fv[i % n].wait();
162+
// fv[i % n] = std::async(std::launch::async, [=]{ return runAPR(options); });
163+
// }
164+
//
165+
// for (int i = 0; i < fv.size(); ++i) fv[i].wait();
166+
//
167+
// std::cout << "DONE!" <<std::endl;
168+
169+
return runAPR(options);
169170
}
170171

171172

src/algorithm/APRConverter.hpp

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef __APR_CONVERTER_HPP__
1010
#define __APR_CONVERTER_HPP__
1111

12+
#include <list>
13+
1214
#include "data_structures/APR/APR.hpp"
1315
#include "data_structures/Mesh/PixelData.hpp"
1416
#include "io/TiffUtils.hpp"
@@ -234,38 +236,68 @@ inline bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, PixelD
234236
APRTimer t(true);
235237
t.start_timer(" =========== ALL");
236238
{
237-
GpuProcessingTask<ImageType> gpt1(image_temp, local_scale_temp, par, bspline_offset, (*apr).level_max());
238-
gpt1.doAll();
239-
}
240-
t.stop_timer();
241-
method_timer.stop_timer();
242-
#endif
243239

244-
method_timer.start_timer("initialize_particle_cell_tree");
245-
iPullingScheme.initialize_particle_cell_tree(aAPR.apr_access);
246-
method_timer.stop_timer();
247240

248-
method_timer.start_timer("compute_local_particle_set");
249-
get_local_particle_cell_set(local_scale_temp, local_scale_temp2);
250-
method_timer.stop_timer();
241+
std::vector<GpuProcessingTask<ImageType>> gpts;
251242

252-
method_timer.start_timer("compute_pulling_scheme");
253-
iPullingScheme.pulling_scheme_main();
254-
method_timer.stop_timer();
243+
int n = 3;
244+
for (int i = 0; i < n; ++i) {
245+
gpts.emplace_back(GpuProcessingTask<ImageType>(image_temp, local_scale_temp, par, bspline_offset, (*apr).level_max()));
246+
gpts.back().sendDataToGpu();
247+
gpts.back().processOnGpu();
248+
}
255249

256-
method_timer.start_timer("downsample_pyramid");
257-
std::vector<PixelData<T>> downsampled_img;
258-
//Down-sample the image for particle intensity estimation
259-
downsamplePyrmaid(input_image, downsampled_img, aAPR.level_max(), aAPR.level_min());
260-
method_timer.stop_timer();
250+
for (int i = 0; i < n * 2; ++i) {
251+
int c = i % n;
252+
gpts[c].getDataFromGpu();
253+
254+
// in theory we get new data and send them to task
255+
gpts[c].sendDataToGpu();
256+
gpts[c].processOnGpu();
257+
258+
init_apr(aAPR, input_image);
259+
iPullingScheme.initialize_particle_cell_tree(aAPR.apr_access);
260+
PixelData<float> lst(local_scale_temp, true);
261+
get_local_particle_cell_set(lst, local_scale_temp2);
262+
iPullingScheme.pulling_scheme_main();
263+
PixelData<T> inImg(input_image, true);
264+
std::vector<PixelData<T>> downsampled_img;
265+
downsamplePyrmaid(inImg, downsampled_img, aAPR.level_max(), aAPR.level_min());
266+
aAPR.apr_access.initialize_structure_from_particle_cell_tree(aAPR.parameters, iPullingScheme.getParticleCellTree());
267+
aAPR.get_parts_from_img(downsampled_img, aAPR.particles_intensities);
268+
}
269+
std::cout << "Total n ENDED" << std::endl;
261270

262-
method_timer.start_timer("compute_apr_datastructure");
263-
aAPR.apr_access.initialize_structure_from_particle_cell_tree(aAPR.parameters, iPullingScheme.getParticleCellTree());
271+
}
272+
t.stop_timer();
264273
method_timer.stop_timer();
274+
#endif
265275

266-
method_timer.start_timer("sample_particles");
267-
aAPR.get_parts_from_img(downsampled_img,aAPR.particles_intensities);
268-
method_timer.stop_timer();
276+
// method_timer.start_timer("initialize_particle_cell_tree");
277+
// iPullingScheme.initialize_particle_cell_tree(aAPR.apr_access);
278+
// method_timer.stop_timer();
279+
//
280+
// method_timer.start_timer("compute_local_particle_set");
281+
// get_local_particle_cell_set(local_scale_temp, local_scale_temp2);
282+
// method_timer.stop_timer();
283+
//
284+
// method_timer.start_timer("compute_pulling_scheme");
285+
// iPullingScheme.pulling_scheme_main();
286+
// method_timer.stop_timer();
287+
//
288+
// method_timer.start_timer("downsample_pyramid");
289+
// std::vector<PixelData<T>> downsampled_img;
290+
// //Down-sample the image for particle intensity estimation
291+
// downsamplePyrmaid(input_image, downsampled_img, aAPR.level_max(), aAPR.level_min());
292+
// method_timer.stop_timer();
293+
//
294+
// method_timer.start_timer("compute_apr_datastructure");
295+
// aAPR.apr_access.initialize_structure_from_particle_cell_tree(aAPR.parameters, iPullingScheme.getParticleCellTree());
296+
// method_timer.stop_timer();
297+
//
298+
// method_timer.start_timer("sample_particles");
299+
// aAPR.get_parts_from_img(downsampled_img,aAPR.particles_intensities);
300+
// method_timer.stop_timer();
269301

270302
computation_timer.stop_timer();
271303

src/algorithm/ComputeGradientCuda.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public:
257257
boundaryLen{(2 /*two first elements*/ + 2 /* two last elements */) * image.x_num * image.z_num},
258258
boundary{nullptr, boundaryLen, iStream}
259259
{
260-
std::cout << "\n=============== GpuProcessingTaskImpl ===================\n\n";
260+
// std::cout << "\n=============== GpuProcessingTaskImpl ===================\n\n";
261261
std::cout << iCpuImage << std::endl;
262262
std::cout << iCpuLevels << std::endl;
263263
std::cout << "\n\n\n";
@@ -297,7 +297,7 @@ public:
297297

298298
~GpuProcessingTaskImpl() {
299299
cudaStreamDestroy(iStream);
300-
std::cout << "\n============== ~GpuProcessingTaskImpl ===================\n\n";
300+
// std::cout << "\n============== ~GpuProcessingTaskImpl ===================\n\n";
301301
}
302302
};
303303

src/misc/CudaMemory.cuh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ inline cudaError_t checkCuda(cudaError_t result) {
2323
inline void* getPinnedMemory(size_t aNumOfBytes) {
2424
void *memory = nullptr;
2525
cudaError_t result = checkCuda(cudaMallocHost(&memory, aNumOfBytes) );
26-
std::cout << "Allocating pinned memory " << aNumOfBytes << " at " << memory << " result " << result << std::endl;
26+
// std::cout << "Allocating pinned memory " << aNumOfBytes << " at " << memory << " result " << result << std::endl;
2727
return memory;
2828
};
2929

3030
inline void freePinnedMemory(void *aMemory) {
31-
std::cout << "Freeing pinned memory " << aMemory << std::endl;
31+
// std::cout << "Freeing pinned memory " << aMemory << std::endl;
3232
cudaFreeHost(aMemory);
3333
}
3434

0 commit comments

Comments
 (0)