Changeset 3856 in Sophya
- Timestamp:
- Aug 12, 2010, 1:03:17 AM (15 years ago)
- Location:
- trunk/SophyaLib/Manual
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Manual/modifs.tex
r3817 r3856 65 65 V = 2.140 & \hspace{10mm} & Sept-Oct 2009 - NO tag \\ 66 66 V = 2.150 & \hspace{10mm} & Mars 2010 - NO tag \\ 67 V = 2.2 & \hspace{10mm} & Septembre 2010 - tag CVS \\ 67 68 68 69 \end{tabular} … … 93 94 \titre{BuildMgr} 94 95 \begin{itemize} 95 \item[\rond] Juillet 2010 : Ajout de l'option {\tt -arch32} de compilation en 32 bits pour linux 96 \item[\rond] Juillet/Aout 2010 : Ajout des options et arguments suivants au script configure 97 \begin{verbatim} 98 -arch32 de compilation en 32 bits pour linux 99 -followlink pour suivi des liens symboliques lors des recherches 100 de fichiers par find. Pas de suivi des liens par defaut 101 -epip pour chemin de librairies et include file PI (Motif ...) 102 -wgrdl activation compil et link piapp avec GNU-readline 103 \end{verbatim} 104 {\tt -arch32} de compilation en 32 bits pour linux 96 105 \item[\rond] Mars 2010 : Ajout de l'option {\tt -ldble128} dans le script configure pour la gestion conditionnelle 97 106 du flag compilation {\bf SO\_LDBLE128 } dans machdefs.h. Ce flag active la dclaration des nombres en … … 176 185 \titre{NTools} 177 186 \begin{itemize} 187 \item[rond] Aout 2010 : Ajout de la classe d'interpolation lineaire {\bf SLinInterp1D} et programme 188 test Tests/tstinterp.cc 178 189 \item[\rond] Oct 2008 : Instanciation explicite des classes 179 190 \tcls{Image} et \tcls{ArrayFitter} pour T=uint\_4, uint\_8 -
trunk/SophyaLib/Manual/sophya.tex
r3839 r3856 31 31 \newcommand{\carre}{$\Box \ $} 32 32 33 \newcommand{\bitem}[1]{\item[]{\bf #1} } 33 34 34 35 \begin{document} … … 36 37 \begin{titlepage} 37 38 % The title page - top of the page with the title of the paper 38 \titrehp{S ophya \\ An overview}39 \titrehp{SOPHYA user's guide } 39 40 % Authors list 40 41 \auteurs{ … … 48 49 \vspace{1cm} 49 50 \begin{center} 50 {\bf \Large S ophyaVersion: 2.2 (V\_Sep2010) }51 {\bf \Large SOPHYA Version: 2.2 (V\_Sep2010) } 51 52 \end{center} 52 53 \titrebp{1} … … 149 150 \item[] {\bf SysTools/} This module contains classes implementing 150 151 an interface to various OS specific services, such 151 threads and dynamic link/shared library handling.152 as threads and dynamic link/shared library handling. 152 153 153 154 \end{itemize} … … 190 191 SOPHYA library. 191 192 \begin{itemize} 192 \item[] {\bf Tests/} Simple test programs. Many of these test programs can be also used193 as examples for using SOPHYA.193 \item[] {\bf Tests/} Simple test programs. Many of these test programs can also be 194 used as examples for using SOPHYA. 194 195 \item[] {\bf PrgUtil/} Various utility programs (runcxx, scanppf, scanfits, \ldots) 195 196 \item[] {\bf PrgMap/} Programs performing operations on skymaps: projections, … … 225 226 \item[] {\bf DemoPIApp/} Sample scripts and programs for (s)piapp 226 227 interactive analysis tools. 228 \item[] {\bf DemoData/} data files (PPF, FITS \ldots) useful for the (s)piapp 229 user's manual examples. 227 230 \end{itemize} 228 231 229 The following modules contains additional programs or libraries, based on SOPHYA:232 The following modules contains additional programs or libraries, which rely on SOPHYA: 230 233 \begin{itemize} 231 234 \item[] {\bf AnaLC} contains program files extracted from the EROS/PEIDA software 232 235 and adapted to be compiled with SOPHYA. It can be used in particular to read and analyse 233 EROS light curve data files .234 \item[] {\bf LUC} {\bf L}ittle {\bf U}niverse {\bf C}alculatoris a module containing classes to236 EROS light curve data files (fichiers de suivi). 237 \item[] {\bf LUC} ( {\bf L}ittle {\bf U}niverse {\bf C}alculator) is a module containing classes to 235 238 perform basic computation related to the universe geometry (FRW metric). 239 \item[] {\bf SimLSS} Tools for the {\bf Sim}ulation and analysis of cosmological 240 {\bf L}arge {\bf S}cale {\bf S}tructures 241 \item[] {\bf PIPhoto} is an interface module for (s)piapp and ImageMagick for 242 import/export of graphics in image format (jpeg, gif \ldots) in piapp. 236 243 \item[] {\bf PMixer/} skymixer and related programs. This module is {\bf obsolete}. 237 244 \end{itemize} … … 360 367 classes / methods in SOPHYA. \\ 361 368 A major exception is the reference sharing mechanism, where different instances 362 of a class may share dmemory locations. This reference sharing mechanism has been369 of a class may share memory locations. This reference sharing mechanism has been 363 370 made thread-safe in SOPHYA, from version V=2.1. \\ 364 371 As a consequence, different execution threads can access non overlapping sub-arrays … … 367 374 NTuple and DataTable objects can be activated, on an object per object basis. \\ 368 375 The {\tt ZThread, ZMutex \ldots} classes in the {\bf SysTools } module offer a relatively 369 easy way of writing multi-threaded programs .376 easy way of writing multi-threaded programs (See \ref{mtpsop}). 370 377 371 378 \subsection{the runcxx program} … … 848 855 849 856 \subsection{Pseudo-random number generators} 850 \index{Random numbers} 857 \index{Random numbers} \label{randgen} 851 858 \begin{figure}[hbt] 852 859 \dclsbb{ AnyDataObj }{ RandomGeneratorInterface } … … 937 944 int N = 10; 938 945 // B.2- Compute and print a sequence of random number, 939 // should be compared to the sequ ance A.5946 // should be compared to the sequence A.5 940 947 for(int i=0; i<N; i++) 941 948 cout << "-- I=" << i << " rand_flat01= " << rgr.Flat01() … … 971 978 \item Capability to handle {\bf large - multidimensional - dense} 972 979 arrays, for numerical data types. Although we have used templates, for 973 data type specialisation, the actual code, apart inline functions is974 not in header files. Instead, we use explicit instanciation, and the980 data type specialisation, the actual code, apart from inline functions is 981 not in the header files. Instead, we use explicit instanciation, and the 975 982 compiled code for the various numerical types of arrays is the 976 983 library . … … 1125 1132 The services provided in other modules, such as {\bf LinAlg} should 1126 1133 be preferred in such cases. 1134 1135 \subsubsection{TVectors and std::vector} 1136 SOPHYA \tcls{TVector} objects can be constructed or filled from \tcls{std::vector} objects. 1137 TVector objects can also be converted to std::vector. 1138 \begin{verbatim} 1139 TVector(const vector<T>& v, short lcv=BaseArray::AutoVectorType); 1140 TVector<T>::FillFr(const vector<T>& v,bool noresize=false); 1141 TVector<T>::FillTo(vector<T>& v,bool addtoend=false); 1142 \end{verbatim} 1143 1144 In addition, \tcls{std::vector} objects can be written to, read from PPF streams 1145 through the class \tcls{PPFWrapperSTLVector} (file ppfwrapstlv.h). The std::vector 1146 PPF handler is currently registered for the following data types: \\ 1147 \hspace*{5mm} {\tt string, int\_2, uint\_2, int\_4, uint\_4, int\_8, uint\_8 } \\ 1148 \hspace*{5mm} {\tt r\_4 , r\_8, complex$<$r\_4$>$ , complex$<$r\_8$>$ } 1127 1149 1128 1150 \subsection{Working with sub-arrays and Ranges} … … 1695 1717 (float/double).They are arranged in columns. Each line is often called an event. 1696 1718 These objects are frequently used to analyze data. 1697 The piapp graphicals tools can plot a column against an other one1698 with respect to various selection cuts. \\1719 The piapp interactive analysis tool can be used to create 1D, 2D and 3D plots using the date from 1720 NTuples and DataTables. \\ 1699 1721 Here is an example of creation and filling~: 1700 1722 \begin{verbatim} … … 1818 1840 \end{verbatim} 1819 1841 1820 \subsection{ Writing, viewing \dots}1842 \subsection{Persistence and visualisation } 1821 1843 %% 1822 1844 Histogram and NTuple/DataTable objects have PPF handlers and 1823 can be written to or read from PPF files. Sophya graphical tool (spiapp) can1824 automatically display and operate on allthese objects.1845 can be written to or read from PPF files. Sophya interactive analysis tool 1846 (spiapp) can automatically display and operate on all of these objects. 1825 1847 The following example shows how to write the previously created objects 1826 1848 into such a file~: … … 1842 1864 fitting, sorting and ODE solving. FFTs are also provided (Mayer,FFTPack). 1843 1865 1844 \subsection{Fitting} 1866 \subsection{Optimisation and parameter fitting} 1867 \subsubsection{GeneralFit: non linear fitting} 1845 1868 \index{Fitting} \index{Minimisation} 1846 1869 Fitting is done with two classes {\tt GeneralFit} and {\tt GeneralFitData} … … 1908 1931 in the HTML pages of the Sophya manual. 1909 1932 1910 \subs ection{Simplex method}1933 \subsubsection{Simplex method} 1911 1934 The class {\bf MinZSimplex} implements the simplex method for non linear 1912 optimization / minimization. See the SOPHYA manual for more information. 1935 optimization / minimization. See the SOPHYA reference manual and the 1936 Tests/tsimplex.cc for more information. 1937 1938 \subsection{Interpolation} 1939 \index{Interpolation} \index{SLinInterp1D} 1940 The class {\bf SLinInterp1D} (file slininterp.h) can be used for linear 1D interpolation. 1941 \begin{verbatim} 1942 #include "slininterp.h" 1943 #include "srandgen.h" 1944 ... 1945 vector<double> ys; 1946 double xmin = 0.5; 1947 double xmax = 0.; 1948 for(int i=0; i<=12; i++) { 1949 xmax = xmin+i*0.1; 1950 yreg.push_back(sin(xmax)*cos(2.2*xmax)); 1951 } 1952 SLinInterp1D interpYR(xmin, xmax, yreg); 1953 cout << interpYR 1954 for(int i=0; i<=12; i++) { 1955 double x = drand01()*2.; 1956 cout << " Interpol result for X=" << x << " -> " << interpYR(x) 1957 << " ?= " << sin(x)*cos(2.2*x) << endl; 1958 } 1959 \end{verbatim} 1960 The {\bf CSpline} and {\bf CSpline2} classes perform one dimensional and two dimensional spline interpolation. 1913 1961 1914 1962 \subsection{Polynomial} … … 2064 2112 2065 2113 \subsection{Thread management classes} 2066 \index{ZThread} \index{ZMutex} 2114 \index{ZThread} \index{ZMutex} \label{thrcls} 2067 2115 A basic interface to POSIX threads is also provided 2068 2116 through the \index{threads} {\bf ZThread}, {\bf ZMutex} and {\bf ZSync} … … 2079 2127 zt1.setAction(fun1, arg[1]); 2080 2128 ZThread zt2; 2081 zt2.setAction(fun2, arg[ 1]);2129 zt2.setAction(fun2, arg[2]); 2082 2130 cout << " Starting threads ... " << endl; 2083 2131 zt1.start(); … … 2088 2136 \end{verbatim} 2089 2137 The classes {\bf ZMutex} \index{mutex} and {\bf ZSync} can be used 2090 to perform synchronisation and signaling between threads. 2091 Example multithread programs using these classes can be found in 2092 the {\bf Tests} module : \\ 2093 \hspace{10mm} {\tt zthr.cc , tmtdt.cc , tmtrnd.cc } 2138 to perform synchronisation and signaling between threads. Each {\bf ZMutex} object 2139 contains a pair of mutex and condition variable. 2140 The {\bf ParallelExecutor } class can be used for parallel simultaneous execution 2141 of several function of objects inheriting from {\bf ParallelTaskInterface}. 2142 Some hints about parallel programming and usage of these classes can be found in 2143 \index{ParallelExecutor} \index{ ParallelTaskInterface } 2144 \ref{mtpsop}. 2094 2145 2095 2146 \begin{figure}[hbt] 2147 \dclsa{ParallelExecutor} 2148 \dclsbb{ParallelTaskInterface}{ParallelTaskFunction} 2096 2149 \dclsbb{ZThread}{ParalExThread} 2097 \dclsa{ ParallelExecutor}2150 \dclsa{ZMutex} 2098 2151 \end{figure} 2099 %% CHECK 2100 {\bf \large DECRIRE l'utilisation des nouvelles classes ParallelExecutor ... } 2152 2101 2153 2102 2154 \subsection{Dynamic linker and C++ compiler classes} … … 2150 2202 The command language provides variable manipulation through the usual 2151 2203 {\tt \$varname} vector variable and arithmetic expression extensions, as well 2152 as the control and test blocs. 2204 as the control and test blocs. A description of this command interpreter syntax 2205 and possibilities can be found in the (s)piapp user's guide. 2153 2206 \begin{verbatim} 2154 2207 #include "commander.h" … … 2277 2330 \end{verbatim} 2278 2331 2279 \subsection{Writing, viewing \dots } 2280 2281 All these objects have been design to be written to or read from a persistant file. 2282 The following example shows how to write the previously created objects 2332 \subsection{Persistence and visualisation } 2333 The different SkyMap objects have PPF handlers and written to or read from PPF files. 2334 The following example shows how to save the previously created objects 2283 2335 into such a file~: 2284 2336 \begin{verbatim} … … 2300 2352 \end{verbatim} 2301 2353 2302 Sophya graphical tools(spiapp) can automatically display and operate2303 all these objects. 2354 Sophya interactive analysis tool (spiapp) can automatically display and operate 2355 on SkyMap objects. 2304 2356 2305 2357 \newpage … … 2333 2385 \subsection{Module SkyT} 2334 2386 \index{RadSpectra} \index{SpectralResponse} 2387 \begin{center} 2388 {\bf \large THIS MODULE NEEDS EXTENSIVE CHECKING/DEBUGGING AND REDESIGN } 2389 \end{center} 2335 2390 The SkyT module is composed of two types of classes: 2336 2391 \begin{itemize} … … 2432 2487 \begin{enumerate} 2433 2488 \item Saving an array and a HealPix map to a Fits file 2489 \index{HEALPix-FITS} 2434 2490 \begin{verbatim} 2435 2491 #include "fitsioserver.h" … … 2482 2538 %%% 2483 2539 \item DataTable objects can be read from and written to FITS files as ASCII or 2484 binary tables. The example belo show reading the DataTable created in the example2540 binary tables. The example below show reading the DataTable created in the example 2485 2541 in section \ref{datatables} from a PPF file and saving it to a fits file. 2542 \index{DataTable-FITS} 2486 2543 \begin{verbatim} 2487 2544 #include "swfitsdtable.h" … … 2513 2570 \end{figure} 2514 2571 2572 \subsection{Fits Array I/O in chunk } 2573 Array read/write from/to FITS files (Image HDU) is rather straightforward, in particular thanks to 2574 the overloaded stream operators, as in the examples given above and here: 2575 \index{Array-FITS} 2576 \begin{verbatim} 2577 // ---- Writing an array to fits file 2578 // Create and open a fits file named myfile.fits 2579 FitsInOutFile fos("!myarr.fits", FitsInOutFile ::Fits_Create); 2580 TArray<r_8> a(50,30); 2581 // ... fill the array 2582 // Write the array to file 2583 fos << a; 2584 2585 // ---- Reading an array from file myarr.fits 2586 // Open the fits file for reading 2587 FitsInOutFile fis("myarr.fits", FitsInOutFile::Fits_RO); 2588 TArray<r_8> a; 2589 // Read in the array 2590 fis >> a; 2591 \end{verbatim} 2592 2593 It is also possible to write arrays FITS Image HDU in chunks or read arrays in chunk, 2594 using the following methods : \\ 2595 \begin{verbatim} 2596 void FitsArrayHandler<T>::ReadAtOffset(FitsInOutFile& is, sa_size_t* offset); 2597 void FitsArrayHandler<T>::WriteAtOffset(FitsInOutFile& os, sa_size_t* offset); 2598 \end{verbatim} 2599 The sample code below show how a FITS file corresponding to a 3D data cube of $5\times4\times3$ elements 2600 can be created and written as a series of 2D slices: 2601 \begin{verbatim} 2602 // Make sure FitsIOServer module is initialised : 2603 FitsIOServerInit(); 2604 // Open/create the output file, named mycube.fits (overwrite it) 2605 FitsInOutFile fos("!mycube.fits", FitsInOutFile ::Fits_Create); 2606 // Define the cube size 2607 LONGLONG size[3] = {5,4,3}; 2608 // Create a 2D array corresponding to an x-y cube slice 2609 TArray<int_4> slice(size[0], size[1]); 2610 // Create an IMAGE HDU: cube size and slice data type 2611 fos.CreateImageHDU(FitsTypes::ImageType(slice(0,0)), 3, size); 2612 // initialize the array content 2613 slice = RegularSequence(); 2614 // Create a Fits handler for the array 2615 FitsArrayHandler<int_4> fh(slice); 2616 // Write the 3 slices to the file 2617 sa_size_t offset[3]; 2618 offset[0]=0; offset[1]=0; 2619 for(int k=0;k<size[2]; k++) { 2620 slice += (int_4)(k*100); 2621 offset[2]=k; 2622 fh.WriteAtOffset(fos,offset); 2623 } 2624 \end{verbatim} 2625 The example below show how to read arrays from Image HDU in chunk: 2626 \begin{verbatim} 2627 // Make sure FitsIOServer module is initialised : 2628 FitsIOServerInit(); 2629 // Open the existing file mycube.fits for reading 2630 FitsInOutFile fis("mycube.fits", FitsInOutFile::Fits_RO); 2631 // Get the array size 2632 int naxis=BASEARRAY_MAXNDIMS; 2633 LONGLONG axes[BASEARRAY_MAXNDIMS]; 2634 fis.GetImageHDUInfo(naxis, axes); 2635 // Read in the data as 2D slices 2636 TArray<int_4> slice(axes[0], axes[1]); 2637 FitsArrayHandler<int_4> fh(slice); 2638 sa_size_t offset[3]; 2639 offset[0]=0; offset[1]=0; 2640 for(int k=0;k<axes[2]; k++) { 2641 offset[2]=k; 2642 fh.ReadAtOffset(fis,offset); 2643 cout << " Slice k=" << k << " Sx=" << axes[0] << " Sy=" << axes[1] << endl; 2644 slice.Print(cout,slice.Size()); cout << endl; 2645 } 2646 \end{verbatim} 2647 2515 2648 \subsection{SwFitsDataTable and other classes} 2516 2649 \label{SwFitsDataTable} … … 2583 2716 Depending on the configuration options during library build, only 2584 2717 transforms on double precision data might be available. 2585 2586 \section{Multi-thread and parallel programming with Sophya} 2587 2718 Usage example: 2719 \begin{verbatim} 2720 int nx=500, ny=500; 2721 TArray<r_8> img(nx, ny); 2722 // fill in the image 2723 .... 2724 // Compute Fourier transform of the image 2725 TArray< complex<r_8> > fourimg; 2726 FFTWServer ffts; 2727 ffts.setNormalize(true); 2728 ffts.FFTForward(img, fourimg); 2729 // perform some filtering in Fourier domain 2730 // modifying the fourier coefficients fourimg 2731 ... 2732 // Compute back the new (filtered) image 2733 TArray<r_8> img2(nx, ny); 2734 ffts.FFTBackward(fourimg, img2); 2735 \end{verbatim} 2736 2737 \section{Multi-thread and parallel programming with SOPHYA} 2738 \label{mtpsop} 2739 A general introduction to parallel programming model in the Shared Memory multi-Processor 2740 systems and the POSIX thread model is well beyond the scope of this 2741 document. Interested readers can find some introductory texts on the following 2742 web pages: 2743 \begin{enumerate} 2744 \item Symmetric multiprocessing, \\ 2745 \href{http://en.wikipedia.org/wiki/Symmetric\_multiprocessing } {http://en.wikipedia.org/wiki/Symmetric\_multiprocessing } 2746 \item POSIX Threads Tutorial {\it Mark Hays, Software Interest Group }\\ 2747 \href{ http://math.arizona.edu/\~swig/documentation/pthreads/ } {http://math.arizona.edu/\~swig/documentation/pthreads/} 2748 \item POSIX Threads Programming {\it Blaise Barney, Lawrence Livermore National Laboratory } \\ 2749 \href{ https://computing.llnl.gov/tutorials/pthreads/ } {https://computing.llnl.gov/tutorials/pthreads/ } 2750 \end{enumerate} 2751 In this section, we present some tips and example, focusing on the use of SOPHYA thread management classes. 2752 Few examples of multithread programs using these classes can be found in the {\bf Tests} module : \\ 2753 \hspace{10mm} {\tt zthr.cc , tmtdt.cc , tmtrnd.cc } 2754 2755 \subsection{General guidelines} 2756 \begin{enumerate} 2757 \item In general, most classes in SOPHYA are inherently thread-safe, as they do not have global (static) data class 2758 members and methods operate on instance data members. This is in particular the case of data objects 2759 in SOPHYA: \\ 2760 \tcls{NDataBlock}. \tcls{TArray}, Histo, DataTable, NTuple, \tcls{SphericalMap} \ldots \\ 2761 This means that different instances of these classes can be used within threads without any precaution. 2762 The SOPHYA reference sharing mechanism being itself thread safe. 2763 \item Once the handlers have been registered, the SOPHYA persistence mechanism is in principle thread safe, 2764 as long as I/O is performed on different files in different threads. Synchronisation through mutex should 2765 be implemented if the same PPF file (PInPersist/POutPersist object) is being used in different threads. 2766 \item If you want to use the same NTuple or DataTable or SwPPFDataTable object in different threads, you have 2767 to call the method {\tt SetThreadSafe()} on the corresponding object: 2768 \begin{verbatim} 2769 ---> Set fg=true for thread safe operations 2770 void NTuple::SetThreadSafe(bool fg); 2771 void BaseDataTable::SetThreadSafe(bool fg); 2772 \end{verbatim} 2773 \item Some computation functions or classes in SOPHYA use currently global data and are not thread-safe. 2774 FFTPackServer, FFTWServer and SphericalTransform servers are not thread safe. FFTWServer is not currently 2775 thread safe as the creation of fftw\_plan is not thread safe in fftw library. 2776 \item the cfitsio library is not thread safe, making the services of the FitsIOServer NON thread-safe 2777 \item Many functions in the standard libraries are NOT thread-safe. This is the case of the usual random generators. 2778 Refer to section \ref{randgen} for using random generators in multi-thread applications. 2779 \end{enumerate} 2780 2781 \subsection{Using ZThread and ZMutex } 2782 \begin{itemize} 2783 \item Define and implement a class inheriting from the {\bf ZThread} class (zthread.h). 2784 This class should overwrite the {\tt virtual void ZThread::run() } method of the base class 2785 which has to perform the actual computation. 2786 At the end of the computation in the {\tt run()} method, the {\tt setRC(int rc) } can be called to set 2787 the return code of the thread object. 2788 \item If the actual computation is performed by a function having a single {\tt void *} argument, 2789 the ZThread base class can directly be used. See the example in paragraph \ref{thrcls}. 2790 \item The actual thread is created by the {\tt start()} method. This method has to be called 2791 on each ZThread object to perform the computation. The {\tt start() } method return immediately 2792 after the creation of the underlying thread object. 2793 \item The method {\tt join() } can be used to wait for the thread termination. 2794 \item {\bf ZMutex} objects should be used to control to data (memory location) shared 2795 by several threads. These ZMutex objects would usually be attributes (data members) of the 2796 ZThread objects or classes used by the ZThread objects. Consider a variable {\tt int count } 2797 which is accessed by two different threads. Thread A changes (increment or decrement for example) 2798 the value of {\tt count}, while thread B waits until {\tt count} reaches a given threshold, before 2799 performing some actions and resetting {\tt count}. Access to {\tt count} should be protected by 2800 a ZMutex object; The actual code would then look like: 2801 \begin{verbatim} 2802 // count and its associated ZMutex declaration 2803 int count = 0; 2804 int threshold=10; 2805 ZMutex mex; 2806 ....... 2807 // ----- Code executed by thread A 2808 mex.lock(); 2809 count++; 2810 mex.unlock(); 2811 mex.signal(); 2812 // Alternatively, mex.broadcast() can be called to wake up 2813 // several threads waiting on the ZMutex condition variable 2814 ....... 2815 // ----- Code executed by thread B 2816 mex.lock(); 2817 while (count<threshold) mex.wait(); 2818 // here, count has reached or exceeded the threshold 2819 // Do some action, and reset count 2820 count=0; 2821 mex.unlock(); 2822 \end{verbatim} 2823 \end{itemize} 2824 2825 \subsection{Using ParallelExecutor } 2826 The {\bf ParallelExecutor } class (parlex.h) objects can be used to perform a computation divided into 2827 parts which can be performed independently and in parallel in different threads. A typical 2828 would be the application of a complex function to all elements in an array. 2829 \begin{itemize} 2830 \item Define and implement a class inheriting from the {\bf ParallelTaskInterface} class. This class should 2831 implement the pure virtual method {\tt int execute(int tid)}. {\tt tid} is the thread identifier, or rank in the 2832 set of parallel threads assigned to perform the computation. The first thread has a rank=0 and 2833 {\tt ParallelTaskInterface::getNbParallelThreads() } method can be used to find the total 2834 number of threads assigned to the task in the parallel execution context. 2835 \item Create an {\bf ParallelExecutor} object passing to it the ParallelTask object and the number of 2836 threads, or alternatively, a vector of ParallelTask object pointers. 2837 \item The set of threads are started by calling the {\tt ParallelExecutor::start() } method. The created threads 2838 will be in a waiting state, until the {\tt ParallelExecutor::execute() } is called. 2839 \item The call to {\tt execute() } triggers the execution of the {\tt ParallelTask::execute(tid) } methods 2840 for all of the parallel threads in the context. The {\tt execute() } method returns when all the threads 2841 have finished executing the {\tt ParallelTask::execute(tid) } . 2842 \item The threads will then be again in a waiting state, ready for a new call to {\tt execute() }. 2843 The threads will terminate when the ParallelExecutor object is destroyed. 2844 \end{itemize} 2845 2846 \begin{verbatim} 2847 // Class MyTask implements ParallelTaskInterface 2848 MyTask ptask(...); 2849 // Create a parallel execution context with 4 threads 2850 ParallelExecutor parex(ptask,4); 2851 // Start the threads 2852 parex.start(); 2853 // Loop over several data sets that 2854 int NDS=5; 2855 for(int i=0; i<NDS; i++ { 2856 // Prepare the data 2857 ... 2858 // Do the parallel computation 2859 parex.execute(); 2860 } 2861 \end{verbatim} 2862 2588 2863 \newpage 2589 2864 \section{Building and installing Sophya} 2590 2865 \subsection{Supported platforms} 2591 Presently, the SOPHYA and PI libraries and tools ha sbeen compiled and tested with2866 Presently, the SOPHYA and PI libraries and tools have been compiled and tested with 2592 2867 the following compiler/platform pairs: 2593 2868 … … 2645 2920 {\tt \$SOPHYABASE} environment variable. 2646 2921 2647 \subsection{Build instructions}2922 \subsection{Build and install procedure} 2648 2923 \label{build} 2649 2924 The build procedure has two main steps: … … 2656 2931 \end{enumerate} 2657 2932 2658 {\tt BuildMgr/configure } is a c-shell script with a number of arguments: 2933 {\tt BuildMgr/configure } is a c-shell script with a number of arguments. Please note 2934 that this is NOT an autoconf generated script, but a custom c-shell script and it does 2935 not create the makefiles. The c-shell (or tcsh) must be accessible to run this script. 2659 2936 \begin{verbatim} 2660 2937 csh> ./configure -h 2661 2938 configure [-sbase SOPHYABASE] [-scxx SOPHYACXX] [-incln] 2662 2939 [-minc mymake.inc] [-compopt 'cc/cxxOptions'] 2663 [-arch64] [-arch32] [-sasz64] [-ldble128] [-nofpic] [-nothsafe] [-boundcheck] [-sodebug] 2664 [-extp dir1 -extp dir2 ...] [-extip dir1 -extip dir2 ... ] [-extlp dir1 -extlp dir2 ... ] 2940 [-arch64] [-arch32] [-sasz64] [-ldble128] 2941 [-nofpic] [-nothsafe] [-boundcheck] [-sodebug] 2942 [-extp dir1 -extp dir2 ...] [-extip dir1 -extip dir2 ... ] 2943 [-extlp dir1 -extlp dir2 ... ] [-followlink] 2665 2944 [-noextlib] [-noext fits] [-noext fftw] [-noext lapack] [-noext astro] 2666 [-noPI] [-slballinone]2667 2945 [-alsofftwfloat] [-usefftw2] [-uselapack2] 2946 [-wgrdl] [-epip mdir1 -epip mdir2 ...] [-noPI] [-slballinone] 2668 2947 (See SOPHYA manual/web pages for a detailed description of configure options) 2669 2948 \end{verbatim} 2670 2949 \begin{itemize} 2671 \item[] -sbase : define SOPHYA installation base directory. \$SOPHYABASE is used 2672 if not specified. 2673 \item[] -scxx : selects the C++ compiler. \$SOPHYACXX s used 2674 if not specified. 2675 \item[] -incln : creates symbolic link for include files, instead of copying them. 2676 \item[] -minc : give an explicit name for the file used to generate 2677 \$SOPHYABASE/include/sophyamake.inc. If {\tt -minc} is not specified, one of 2678 the files in BuildMgr/ directory is selected, based on the system name and the 2679 compiler {\tt Linux\_g++\_make.inc , OSF1\_cxx\_make.inc , AIX\_xlC\_make.inc \ldots} 2680 \item[] -compopt : additional compiler options \\[2mm] 2681 \item[] -arch64 : select/force 64 bits compilation mode. This is the default on 64 bits Linux systems and AIX. 2682 \item[] -arch32 : select/force 32 bits compilation mode. useful on 64 bits Linux systems or AIX 2683 \item[] -sasz64 : select 8 byte (64 bits) size for array indices, useful if you need to allocate an manipulate 2684 large arrays, with more than $2^32$ elements along a single array dimension. 2685 \item[] -ldble128 : set the flags activating {\tt long double} (128 bits) arrays. \\[2mm] 2686 \item[] -nofpic : disable -fPIC (Position Independent Code) generation flag 2687 \item[] -nothsafe : disable thread-safety procedures in SOPHYA : reference sharing \ldots. 2688 ( activate the conditional compilation flag {\tt SO\_NOTHSAFE } ) 2689 \item[] -boundcheck : compile SOPHYA and bound checking activated when accessing array elements 2690 ( activate conditional compilation flag {\tt SO\_BOUNDCHECKING } ) 2691 \item[] -sodebug : activate conditional compilation flag {\tt SOPHYA\_DEBUG } \\[2mm] 2692 \item[] -extp : Adds the specied path to the search path of the external libraries 2693 include files and archive library. 2694 \item[] -extip : Adds the specied path to the search path of the external libraries 2695 include files. 2696 \item[] -extp : Adds the specied path to the search path of the external libraries 2697 archive (libxxx.a). 2698 \item[] -noextlib : Disable compiling of modules referencing external libraries. 2699 \item[] -noext : Disable compiling of the specified module (with reference to external 2700 library : {\tt -noext fits , -noext fftw -noext lapack -noext astro } \\[2mm] 2701 \item[] -usefftw2: Use FFTW V2 instead of the default FFTW V3 - A preprocessor 2702 flag will be defined in sspvflags.h 2703 \item[] -uselapack2: Lapack V2 is being used (defaulr V3) - A preprocessor 2704 flag will be defined in sspvflags.h 2705 \item[] -alsofftwfloat : compile single precision (float) version of the Fourier 2950 \item General parameters and options: \\[1mm] 2951 {\bf -sbase {\it path} } define SOPHYA installation base directory. \$SOPHYABASE is used 2952 if not specified \\ 2953 {\bf -scxx {\it cmd} } selects the C++ compiler. \$SOPHYACXX is used if not specified. \\ 2954 {\bf -incln } creates symbolic link for include files, instead of copying them. \\ 2955 {\bf -minc {\it filename} } give an explicit name for the file used as the seed to create the file \\ 2956 {\tt \$SOPHYABASE/include/sophyamake.inc}. \hspace{2mm} 2957 If -minc is not specified, one of the files in BuildMgr/ directory is selected, based on the 2958 system name and the compiler: \\ 2959 {\tt Linux\_g++\_make.inc , OSF1\_cxx\_make.inc , AIX\_xlC\_make.inc \ldots} \\ 2960 {\bf -compopt {\it opt} } can be used to specify additional compiler options 2961 \item Conditional compilation flags related to SOPHYA configuration (see {\tt machdefs.h} )\\[1mm] 2962 {\bf -arch64 } select/force 64 bits compilation mode. This is the default on 64 bits Linux systems and AIX. \\ 2963 {\bf -arch32 } select/force 32 bits compilation mode. useful on 64 bits Linux systems or AIX. \\ 2964 {\bf -sasz64 } select 8 byte (64 bits) size for array indices, useful if you need to allocate an manipulate 2965 large arrays, with more than $2^32$ elements along a single array dimension. \\ 2966 {\bf -ldble128 } set the flags activating {\tt long double} (128 bits) arrays. \\ 2967 {\bf -nofpic } disable -fPIC (Position Independent Code) generation flag \\ 2968 {\bf -nothsafe } disable thread-safety protection procedures in SOPHYA : reference sharing \ldots. 2969 ( activate the conditional compilation flag {\tt SO\_NOTHSAFE } ) \\ 2970 {\bf -boundcheck } compile SOPHYA with bound checking activated when accessing array elements 2971 ( conditional compilation flag {\tt SO\_BOUNDCHECKING } ) \\ 2972 {\bf -sodebug } activate conditional compilation flag {\tt SOPHYA\_DEBUG } for debugging the library. 2973 \item External libraries \\[1mm] 2974 {\bf -extp {\it path} } Adds the specified path to the search path of the external libraries 2975 include files and archive library. \\ 2976 {\bf -extip {\it path} } Adds the specified path to the search path of the external libraries 2977 include files. \\ 2978 {\bf -extlp {\it path} } Adds the specified path to the search path of the external libraries 2979 archive (libxxx.a). \\ 2980 {\bf -followlink} follow symbolic links when searching for include files and libraries 2981 (-L option of the find command). default: don't follow symbolic links. \\ 2982 {\bf -noextlib } Disable compilation of all modules referencing external libraries. \\ 2983 {\bf -noext {\it modname} } Disable compiling of the specified module (with reference to external 2984 library : {\tt -noext fits , -noext fftw -noext lapack -noext astro } \\ 2985 {\bf -usefftw2 } Use FFTW V2 instead of the default FFTW V3 - A preprocessor 2986 flag will be defined in sspvflags.h \\ 2987 {\bf -uselapack2 } Use Lapack V2 istead of the default V3 - A preprocessor 2988 flag will be defined in sspvflags.h \\ 2989 {\bf -alsofftwfloat } compile single precision (float) version of the Fourier 2706 2990 transform methods (module IFFTW, class FFTWServer). A preprocessor 2707 2991 flag will be defined in sspvflags.h and float version of the FFTW library 2708 2992 (libfftw3f.a) will be linked with SOPHYA, in addition to the default double 2709 precision library (libfftw3.a). 2710 \item[] -noPI : has currently no effect 2711 \item[] -slballinone: A single shared library for all SOPHYA, PI and external library interface 2712 modules will be build. A compilation flag 2713 will be defined in sspvflags.h . \\ See also target {\tt slballinone} below. 2993 precision library (libfftw3.a). \\ 2994 {\bf -slballinone} Use of a single shared library for all SOPHYA, PI and 2995 external library interface modules. A compilation flag 2996 will be defined in sspvflags.h . See also target {\tt slballinone} below. 2997 \item PI and piapp specific options \\[1mm] 2998 {\bf -wgrdl } compile and link piapp with GNU readline library \\ 2999 {\bf -epip {\it path} } Adds the specified path to the search path for include 3000 files and libraries for Motif, and GNU readline, if applicable. \\ 3001 {\bf -noPI } ignore PI modules 2714 3002 \end{itemize} 2715 3003 2716 {\large \bf configure steps } \\[1mm] 3004 \subsubsection{Configure steps } 3005 2717 3006 The configure script performs the following actions : 2718 3007 \begin{enumerate} … … 2729 3018 \end{enumerate} 2730 3019 2731 {\large \bf Example } \\[1mm] 3020 \subsubsection{Compile and install, an example } 2732 3021 2733 3022 In the example below, we assume that we want to install Sophya from a … … 2846 3135 \end{itemize} 2847 3136 2848 3137 \subsection{Test programs} 3138 The module {\bf Tests} contains a number of test programs: 3139 \begin{enumerate} 3140 \item {\bf tobjio } tests part of SOPHYA persistence (PPF files) 3141 \begin{verbatim} 3142 csh> tobjio A 3143 ===> check the created file tobjio.ppf using scanppf 3144 csh> scanppf tobjio.ppf 3145 csh> tobjio B 3146 ===> OK if RC=0 3147 \end{verbatim} 3148 \item {\bf arrt } and {\bf carrt} perform some checks on TArray modules, including I/O, 3149 sub-array extraction, array conversion and memory organisation, as well as array operations. 3150 \begin{verbatim} 3151 csh> arrt check 3152 csh> carrt ac 3153 csh> carrt oso 3154 csh> carrt odo 3155 ===> OK if RC=0 3156 csh> carrt ace 3157 ===> OK if RC=9 (throw an exception) 3158 \end{verbatim} 3159 \item {\bf spar } is a TArray performance measurement tool 3160 \begin{verbatim} 3161 csh> time spar 2 10 800 1000 3162 csh> time spar 2 1000 80 100 3163 \end{verbatim} 3164 \item {\bf tssqmx } checks DiagonalMatrix, SymmetricMatrix and LowerTriangularMatrix classes 3165 \begin{verbatim} 3166 csh> tssqmx d 3167 csh> tssqmx s 3168 csh> tssqmx t 3169 ===> OK if RC=0 3170 \end{verbatim} 3171 \item {\bf ttimestamp } and {\bf tnt } perform some checks on various SOPHYA objects ( DVList, TimeStamp, NTuple \ldots) 3172 \begin{verbatim} 3173 csh> ttimestamp 3174 ===> OK if RC=0 3175 csh> tnt d 3176 ===> DVList test, check the output 3177 csh> tnt n 3178 ===> NTuple test, check the output 3179 csh> tnt DT 3180 ===> DataTable test, check the output 3181 csh> tnt DT 3182 ===> SwPPFDataTable test, check the output 3183 \end{verbatim} 3184 \item {\bf tfft } checks the operation of FFTPackServer and FFTWServer in 1D transforms 3185 \begin{verbatim} 3186 # FFTPackServer tests in double 3187 csh> tfft 1531 P D 0 50 0.0002 3188 csh> tfft 1220 P D 0 50 0.0002 3189 ===> OK if RC=0 3190 # FFTPackServer tests in float 3191 csh> tfft 1531 P F 0 50 0.0002 3192 csh> tfft 1220 P F 0 50 0.0002 3193 ===> OK if RC=0 3194 # FFTWServer tests in double 3195 csh> tfft 1531 W D 0 50 0.0002 3196 csh> tfft 1220 W D 0 50 0.0002 3197 ===> OK if RC=0 3198 \end{verbatim} 3199 \item {\bf lpk} checks the LinAlg interface module 3200 \begin{verbatim} 3201 csh> lpk inverse 100,100 0 3202 ===> OK if RC=0 3203 csh> lpk linsolve 100,100 0 3204 ===> OK if RC=0 3205 csh> lpk lss 100,50 0 3206 ===> OK if RC=0 3207 csh> lpk svd 100,50 0 3208 ===> OK if RC=0 3209 ## These checks can be combined in a single call to lpk 3210 csh> lpk all 100,50 0 3211 \end{verbatim} 3212 \item {\bf tmtdt } tests several aspects of SOPHYA : threads (ZThread, ZMutex \ldots), DataTables \ldots 3213 \begin{verbatim} 3214 csh> tmtdt NT 50000 2 3215 ===> OK if RC=0 3216 csh> tmtdt DT 50000 2 3217 ===> OK if RC=0 3218 csh> tmtdt SWPPF 50000 2 3219 ===> OK if RC=0 3220 # cfitsio is NOT thread safe, test SwFitsDataTable with a single thread 3221 csh> tmtdt SWFITS 50000 1 3222 \end{verbatim} 3223 3224 \end{enumerate} 2849 3225 2850 3226 \newpage
Note:
See TracChangeset
for help on using the changeset viewer.