bzr branch
http://darksoft.org/webbzr/tomo/pyhst
28
by csa
Use pinned result buffer to perform device2host memory transfer parallel with computations, add ESRF copyright information in files appeared after redesign |
1 |
/*
|
78
by Suren A. Chilingaryan
Add COPYING and fix license statements |
2 |
* The PyHST program is Copyright (C) 2002-2011 of the
|
3 |
* European Synchrotron Radiation Facility (ESRF) and
|
|
4 |
* Karlsruhe Institute of Technology (KIT).
|
|
28
by csa
Use pinned result buffer to perform device2host memory transfer parallel with computations, add ESRF copyright information in files appeared after redesign |
5 |
*
|
6 |
* PyHST is free software: you can redistribute it and/or modify it
|
|
7 |
* under the terms of the GNU General Public License as published by the
|
|
8 |
* Free Software Foundation, either version 3 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* hst is distributed in the hope that it will be useful, but
|
|
12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
14 |
* See the GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License along
|
|
17 |
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18 |
*/
|
|
19 |
||
18
by csa
Big redesign (early commit) |
20 |
#ifndef _PYHST_RECONSTRUCTOR_H
|
21 |
#define _PYHST_RECONSTRUCTOR_H
|
|
22 |
||
23 |
#include "hst_setup.h" |
|
32
by csa
Fix crash in FFTW3 initialization and cleanup in multi-threaded case |
24 |
#include "hw_thread.h" |
18
by csa
Big redesign (early commit) |
25 |
|
26 |
typedef struct HSTReconstructorT *HSTReconstructorPtr; |
|
27 |
typedef struct HSTReconstructorContextT *HSTReconstructorContextPtr; |
|
22
by csa
Timing reporting, few bug fixes |
28 |
typedef const struct HSTReconstructorContextT *HSTReconstructorConstContextPtr; |
18
by csa
Big redesign (early commit) |
29 |
|
30 |
/* Set of functions provided by reconstruction modules */
|
|
22
by csa
Timing reporting, few bug fixes |
31 |
typedef const char *HSTConstString; |
32 |
||
30
by csa
Multi-GPU, Multi-CPU, and Hybrid modes support |
33 |
typedef HSTReconstructorContextPtr (*HSTCreateFunction)(HSTReconstructorPtr prototype, HSTSetup *setup, int id); |
32
by csa
Fix crash in FFTW3 initialization and cleanup in multi-threaded case |
34 |
typedef int (*HSTInitFunction)(HSTReconstructorContextPtr ctx, HWThread thr); |
18
by csa
Big redesign (early commit) |
35 |
typedef void (*HSTFreeFunction)(HSTReconstructorContextPtr ctx); |
36 |
typedef void (*HSTDestroyFunction)(HSTReconstructorContextPtr ctx); |
|
20
by csa
do more correct initialization |
37 |
typedef int (*HSTConfigureFunction)(HSTReconstructorContextPtr ctx, HSTChanged what_changed); |
18
by csa
Big redesign (early commit) |
38 |
typedef int (*HSTPreprocessFunction)(HSTReconstructorContextPtr ctx, float *result_slice, const float *sinograms); |
39 |
typedef int (*HSTReconstructFunction)(HSTReconstructorContextPtr ctx, float *result_slice, const float *sinograms); |
|
40 |
typedef int (*HSTPostprocessFunction)(HSTReconstructorContextPtr ctx, float *result_slice, const float *sinograms); |
|
151
by Suren A. Chilingaryan
Multislice mode: preload into the GPU memory complete slices |
41 |
typedef int (*HSTSendFunction)(HSTReconstructorContextPtr ctx, const float *sinograms); |
42 |
typedef int (*HSTWaitFunction)(HSTReconstructorContextPtr ctx); |
|
22
by csa
Timing reporting, few bug fixes |
43 |
typedef HSTConstString (*HSTGetReconstructorTitle)(HSTReconstructorConstContextPtr ctx); |
44 |
typedef HSTConstString *(*HSTGetTimersFunction)(HSTReconstructorConstContextPtr ctx, double *timers); |
|
18
by csa
Big redesign (early commit) |
45 |
|
58
by Suren A. Chilingaryan
Re-engineering of OpenCL detection |
46 |
enum HSTReconstructorFlagsT { |
47 |
HST_RECONSTRUCTOR_USE_CPU = 1, |
|
48 |
HST_RECONSTRUCTOR_USE_GPU = 2 |
|
49 |
};
|
|
50 |
||
51 |
typedef enum HSTReconstructorFlagsT HSTReconstructorFlags; |
|
22
by csa
Timing reporting, few bug fixes |
52 |
/**
|
53 |
* Reconstructor module prototype describing the module capabilities and
|
|
54 |
* providing table of virtual functions
|
|
55 |
*/
|
|
18
by csa
Big redesign (early commit) |
56 |
struct HSTReconstructorT { |
22
by csa
Timing reporting, few bug fixes |
57 |
int devices; //!< Number of computational devices (CPU cores, standalone GPU units, ...) |
58 |
||
59 |
HSTGetReconstructorTitle get_title; //!< Function (mandatory) |
|
60 |
||
61 |
HSTCreateFunction create_context; //!< Allocates memory for context (mandatory) |
|
62 |
HSTInitFunction init_context; //!< Initializes context (mandatory) |
|
63 |
HSTFreeFunction free_context; //!< Releases allocated resources (mandatory) |
|
64 |
HSTDestroyFunction destroy_context; //!< Destroys context (mandatory) |
|
20
by csa
do more correct initialization |
65 |
|
22
by csa
Timing reporting, few bug fixes |
66 |
HSTConfigureFunction configure; //!< Called then some of parameters are changed (optional) |
151
by Suren A. Chilingaryan
Multislice mode: preload into the GPU memory complete slices |
67 |
|
68 |
HSTSendFunction send; |
|
22
by csa
Timing reporting, few bug fixes |
69 |
HSTReconstructFunction preprocess; //!< Preprocessor/Filtering step (optional) |
70 |
HSTReconstructFunction reconstruct; //!< Backprojection step (mandatory) |
|
71 |
HSTReconstructFunction postprocess; //!< Postprocessing step (optional) |
|
151
by Suren A. Chilingaryan
Multislice mode: preload into the GPU memory complete slices |
72 |
HSTWaitFunction wait; //!< Only after this function the results are guaranteed to be in the specified buffer |
22
by csa
Timing reporting, few bug fixes |
73 |
|
74 |
HSTGetTimersFunction get_timers; //!< Returns timing information (optional) |
|
18
by csa
Big redesign (early commit) |
75 |
};
|
76 |
typedef struct HSTReconstructorT HSTReconstructor; |
|
77 |
||
22
by csa
Timing reporting, few bug fixes |
78 |
/**
|
79 |
* The global properties of reconstructor context. The implementations (cpu/cuda/...) are extending
|
|
80 |
* this context with additional properties.
|
|
81 |
*/
|
|
18
by csa
Big redesign (early commit) |
82 |
struct HSTReconstructorContextT { |
22
by csa
Timing reporting, few bug fixes |
83 |
HSTReconstructor recon; //!< Copy of HSTReconstructor prototype |
84 |
HSTSetup *setup; //!< Pointer on current HST setup |
|
85 |
||
151
by Suren A. Chilingaryan
Multislice mode: preload into the GPU memory complete slices |
86 |
float *saved_slice; //!< The sinograms for this slice were send to device during the last iteration |
87 |
const float *saved_sino; |
|
22
by csa
Timing reporting, few bug fixes |
88 |
int processed_slices; //!< Number of slices processed by the module |
18
by csa
Big redesign (early commit) |
89 |
};
|
90 |
||
91 |
typedef struct HSTReconstructorContextT HSTReconstructorContext; |
|
92 |
||
93 |
# ifdef __cplusplus
|
|
94 |
extern "C" { |
|
95 |
# endif
|
|
96 |
||
22
by csa
Timing reporting, few bug fixes |
97 |
|
98 |
/**
|
|
99 |
* Initializes global portion of reconstructor context. This function should
|
|
100 |
* be called from reconstructor initialization code (init_context function)
|
|
101 |
*
|
|
102 |
* before any other action
|
|
103 |
* @param ctx is uninitialized HSTReconstructor context
|
|
104 |
* @param recon is a pointer on reconstruction module prototype
|
|
105 |
* @param setup is a pointer on structure holding HST parameters
|
|
106 |
* @result non-zero error code in the case of error
|
|
107 |
*/
|
|
18
by csa
Big redesign (early commit) |
108 |
int hst_reconstructor_init_context(HSTReconstructorContext *ctx, HSTReconstructor *recon, HSTSetup *setup); |
22
by csa
Timing reporting, few bug fixes |
109 |
|
110 |
/**
|
|
111 |
* Cleans up the global portion of reconstructor context. This function
|
|
112 |
* should be called from reconstructor cleanup code (free_context function)
|
|
113 |
* just before it returns control to the caller.
|
|
114 |
*
|
|
115 |
* @param ctx is cleaned reconstructor context
|
|
116 |
*/
|
|
18
by csa
Big redesign (early commit) |
117 |
void hst_reconstructor_free_context(HSTReconstructorContext *ctx); |
118 |
||
119 |
||
120 |
/**
|
|
121 |
* Default postprocessing routine
|
|
122 |
* @param ctx is initialized HST context
|
|
123 |
* @param slice is reconstructed slice
|
|
124 |
* @param sinograms is containing all sinograms for that slice
|
|
22
by csa
Timing reporting, few bug fixes |
125 |
* @result non-zero error code in the case of error
|
18
by csa
Big redesign (early commit) |
126 |
*/
|
127 |
int hst_reconstructor_postprocess_slice(HSTReconstructorContext *ctx, float *slice, const float *sinograms); |
|
128 |
||
129 |
# ifdef __cplusplus
|
|
130 |
}
|
|
131 |
# endif
|
|
132 |
||
133 |
||
134 |
#define HST_RECONSTRUCTOR(ctx) ((HSTReconstructor*)ctx)
|
|
135 |
||
30
by csa
Multi-GPU, Multi-CPU, and Hybrid modes support |
136 |
#define hst_reconstructor_create(prototype, setup, id) prototype->create_context(prototype, setup, id)
|
32
by csa
Fix crash in FFTW3 initialization and cleanup in multi-threaded case |
137 |
#define hst_reconstructor_init(ctx, thr) HST_RECONSTRUCTOR(ctx)->init_context(ctx, thr)
|
18
by csa
Big redesign (early commit) |
138 |
#define hst_reconstructor_free(ctx) HST_RECONSTRUCTOR(ctx)->free_context(ctx)
|
139 |
#define hst_reconstructor_destroy(ctx) HST_RECONSTRUCTOR(ctx)->destroy_context(ctx)
|
|
140 |
||
22
by csa
Timing reporting, few bug fixes |
141 |
#define hst_reconstructor_get_title(ctx) HST_RECONSTRUCTOR(ctx)->get_title(ctx)
|
142 |
#define hst_reconstructor_get_timers(ctx, timers) (HST_RECONSTRUCTOR(ctx)->get_timers?HST_RECONSTRUCTOR(ctx)->get_timers(ctx, timers):NULL)
|
|
18
by csa
Big redesign (early commit) |
143 |
|
144 |
#endif /* _PYHST_RECONSTRUCTOR_H */ |