- Timestamp:
- May 20, 2000, 6:27:38 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DocHFI_L2/sdg.tex
r794 r1015 8 8 % Extension de symboles mathematiques 9 9 \usepackage{amssymb} 10 11 % package a mettre pour faire du pdf 12 \usepackage{palatino} 10 13 11 14 % Definition de taille de page … … 23 26 \begin{titlepage} 24 27 \vspace{1cm} 25 \rule{110 mm}{0.5 mm}\makebox[50 mm]{\bf Planck HFI L2} 28 \vspace{1cm} 29 \makebox[34mm][c]{\includegraphics[width=3cm]{hfi_icon_vsmall.eps}} 30 \raisebox{12mm}{\rule{80 mm}{0.5 mm}\makebox[50 mm]{\bf Planck HFI L2}} 31 \vspace{2cm} 26 32 \vspace{2cm} 27 33 \begin{center} … … 37 43 {É. Aubourg} & {\tt aubourg@hep.saclay.cea.fr} \\ 38 44 % {É. Lesquoy} & {\tt lesquoy@hep.saclay.cea.fr} \\ 39 %{C. Magneville} & {\tt cmv@hep.saclay.cea.fr} \\45 {C. Magneville} & {\tt cmv@hep.saclay.cea.fr} \\ 40 46 \end{tabular} 41 47 … … 51 57 52 58 \newpage 53 % \tableofcontents54 59 55 60 \section{Introduction} 56 61 We intend to gather gradually in this document the guidelines 57 for the development of Planck HFI Level 2 data processing software s.62 for the development of Planck HFI Level 2 data processing software. 58 63 We assume throughout this document that C++ is the baseline option 59 64 as the programming language for the development of Planck HFI 60 Level 2 processing software. 61 62 \section{Integration of software modules in different languages} 63 We review here some of the problems which may arise when integrating software 64 modules written in other languages into C++ programs. 65 66 \subsection{C and C++} 65 Level 2 processing software, we review here briefly some of 66 the properties of the C++ and Java language and interoperability 67 with other language, mainly C and Fortran. 68 69 70 \section{C++} 71 {\bf C++ \ } is an object-oriented programming language which 72 has been developed by extending the {\bf C \ } language. 73 Some of the additional possibilities incorporated in C++ are: 74 \begin{itemize} 75 \item Introduction of object and classes 76 \item function overloading 77 \item Operator overloading 78 \item function and operator inlining 79 \item virtual functions (polymorphism) 80 \item public, protected and private members 81 \item dynamic memory management operators 82 \item Exception handling 83 \item generic (template) function and classes 84 \end{itemize} 85 86 We discuss here the some of the problems and solutions arising when 87 integrating software modules written in other languages into C++ programs. 88 89 \subsection{Calling C code from C++} 67 90 C++ extends the possibilities offered by the C language. 68 91 All of the C language data types and function call syntax are thus … … 75 98 int fo(double a, double b); 76 99 \end{verbatim} 77 Using {\bf C }, one would have written:100 Using {\bf C \ }, one would have written: 78 101 \begin{verbatim} 79 102 int foi(int a); … … 83 106 C++ compilers use internally a name containing the encoding of the 84 107 argument list. In order to instruct the compiler to use simple 85 names, {\bf C } functions should be declared as \\108 names, {\bf C \ } functions should be declared as \\ 86 109 {\tt extern "C" }. This is usually included in the header 87 110 file (.h). In the example above, the header file (.h) file … … 99 122 \end{verbatim} 100 123 101 \subsection{ Fortran andC++}124 \subsection{Calling Fortran code from C++} 102 125 Fortran is a simple language and uses only basic data types. 103 126 Although the exact mapping between Fortran and C/C++ basic data types … … 137 160 \end{verbatim} 138 161 139 The case of character string arguments in fortran subroutines162 The case of character string arguments in Fortran subroutines 140 163 needs a bit more attention, and the string length needs to be passed 141 164 as an additional integer type argument. 142 As with {\bf C } functions, fortran functions or subroutines143 have to be de lared {\tt extern "C"} to be used within {\bf C++}144 programs. {\bf C/C++ } driver routines can easily be written for145 extensively used fortran modules, simplifying calling sequences.146 147 It should also be noted that the fortran support libraries have to be165 As with {\bf C \ } functions, Fortran functions or subroutines 166 have to be declared {\tt extern "C"} to be used within {\bf C++ \ } 167 programs. {\bf C/C++ \ } driver routines can easily be written for 168 extensively used Fortran modules, simplifying calling sequences. 169 170 It should also be noted that the Fortran support libraries have to be 148 171 included for the link with the C++ driver. 149 It is also possible to translate the whole fortran source code150 into {\bf C } code using {\bf f2c} program. The call syntax172 It is also possible to translate the whole Fortran source code 173 into {\bf C \ } code using {\bf f2c \ } program. The call syntax 151 174 will be exactly the same as with a Fortran compiler, and 152 175 {\tt libf2c.a} should be used when linking the program. 153 176 154 It is very difficult to use C++ classes directly from fortran.155 However, high level functionalities based on a C++ libra y can156 be wrapped in a fortran style function which can be157 called from fortran. One looses of course many of the177 It is very difficult to use C++ classes directly from Fortran. 178 However, high level functionalities based on a C++ library can 179 be wrapped in a Fortran style function which can be 180 called from Fortran. One looses of course many of the 158 181 possibilities offered by underlying C++ library. 159 182 … … 220 243 221 244 245 \section{Java} 246 Java \footnote{Information on the Java platform and language 247 can be found at {\bf http://java.sun.com} } 248 is a rather recent object-oriented programming language. It is 249 based on the concept of a virtual machine, and a very extended 250 standard library. 251 252 Java compilers produce "byte-codes" that are interpreted in a virtual 253 machine (JVM). Thus, pure Java programs are platform-independent and 254 portable. The very extended libraries that are available for the 255 language make it a very good choice for user interfaces, network 256 programming, distributed objects, database access. Numeric 257 computation libraries start to appear but are still in early stages 258 of development. 259 260 The Java language is strongly typed, with dynamic typing information. 261 It is dynamic in essence as class bytecodes can be loaded into the 262 JVM on request. 263 It uses a garbage collector for memory management. Memory leaks and 264 memory access errors cannot exist. All this makes debugging easier 265 than with C++. 266 267 The overhead of interpreting the bytecodes in the virtual machine is 268 alleviated by the development of "JIT" (Just In Time) compilers, that 269 do a dynamic compilation. Java programs are typically 3 times slower 270 than their equivalent in C++, but the exact figure might vary between 271 1 and 5 depending on the type of program. 272 273 Two features convenient for numeric library development and usage 274 present in C++ are missing in Java: templates and operator overloading. 275 Typically, a single code cannot be specialised for 276 floats and doubles automatically, and one must write, if A, B and C 277 are matrices, {\tt C = A.mult(B) instead of C = A*B} . 278 279 \subsection{Calling C/C++ code from Java } 280 281 A Java library (JNI, Java Native Interface) allows to call C/C++ code 282 from Java programs. Of course, portability is then lost. 283 Methods in Java objects can be declared {\tt native}. A tool then 284 produces C/C++ headers for coding these methods in C/C++. This code 285 can call existing C/C++/Fortran code, and even map the Java object to 286 a C++ object. 287 288 Because the layout of objects in memory is not fixed in the JVM 289 specifications, all accesses to methods and member variables are done 290 through interface pointers. Accessing arrays can imply a copy of the 291 array on input, and a copy back on return if the array was modified. 292 293 Since Java memory management is garbage-collector-based, C/C++ 294 programs that want to hold references to Java objects, or create Java 295 objects, must interact with the garbage collector explicitly. 296 297 JNI allows also C/C++ programs to instantiate a JVM and Java objects, 298 and access them. 299 300 \subsection{Java and CORBA} 301 302 Another solution to call C++ objects from Java, or vice-versa, is to 303 use CORBA. CORBA is a standard distributed objects framework, and 304 Java 2 comes with a CORBA-2 compliant ORB (Object Request Broker), 305 JavaIDL. 306 307 Objects distributed through CORBA must have their interface defined 308 in a specific language, IDL. Tools then creates stubs for any 309 language, as well as implementation skeletons. 310 311 An object can then physically exist on a machine, implemented in C++, 312 and be manipulated remotely through Java stubs, as if it were a local 313 Java object. CORBA offers thus language-independent distributed 314 objects. 315 316 It adds overhead compared to JNI, because of the presence of a 317 network layer, but offers more functionality. In particular, the C++ 318 objects are platform-dependent, but the Java code that uses them, 319 being pure Java code, remains portable. 320 321 222 322 \newpage 223 323 \appendix 224 324 225 \section{ The C++ language}325 \section{C++ standard and compilers} 226 326 \vspace{5 mm} 227 {\bf C++} is a very powerful Object Oriented language.228 It has been developped by extending the {\bf C} language,229 keeping in mind the efficiency and performance,230 as well as easy integration with existing softwares.231 It incorporates new possibilities such as:232 233 \begin{itemize}234 \item Introduction of object and classes235 \item function overloading236 \item Operator overloading237 \item function and operator inlining (optimisation)238 \item virtual functions (polymorphism)239 \item public, protected and private members240 \item dynamic memory management operators241 \item Exception handling242 \item generic (template) function and classes243 \end{itemize}244 327 245 328 {\bf C++} can be considered now as a mature language. 246 C++ class library covering various areas, including247 numerical data processing are available as freeware248 or commercial products. Many software tools feature249 a standard C++ API.250 \par \vspace{3mm}251 329 The current standard for C++ and C are defined by 252 330 \footnote{Available from {\bf http://www.ansi.org/ } }: 253 331 \begin{itemize} 254 \item[] {\bf ISO/IEC 14882-1998(E) } Programming languages -- C++255 \item[] {\bf ANSI/ISO 9899-1990 } for Programming Languages C332 \item[] {\bf ISO/IEC 14882-1998(E) \ } Programming languages -- C++ 333 \item[] {\bf ANSI/ISO 9899-1990 \ } for Programming Languages C 256 334 \end{itemize} 257 335 258 259 \newpage 260 \section{C++ compilers} 261 262 263 Powerful compilers are available on most platforms, 264 including: 336 Powerful compilers are available on most platforms, including: 265 337 266 338 \begin{itemize}
Note:
See TracChangeset
for help on using the changeset viewer.