Ignore:
Timestamp:
Oct 23, 2007 5:13:28 PM (15 years ago)
Author:
srkline
Message:

The Cylinder_2D calculation is now threaded (it's the only threaded function so far)

Plus a few interface tweaks on the Setup panel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Models_2D/Cylinder_2D.ipf

    r182 r185  
    7676        parameters_Cyl2D[7] = "Sigma of polydisp in Theta [rad]" 
    7777        parameters_Cyl2D[8] = "Sigma of polydisp in Phi [rad]" 
    78         parameters_Cyl2D[9] = "Sigma of polydisp in Radius [Angstroem]" 
     78        parameters_Cyl2D[9] = "Sigma of polydisp in Radius [A]" 
    7979 
    8080        Edit parameters_Cyl2D,coef_Cyl2D                                         
     
    114114// simply calls the original single point calculation with 
    115115// a wave assignment (this will behave nicely if given point ranges) 
     116// 
     117// NON-THREADED IMPLEMENTATION 
     118// 
     119//Function Cylinder2D(cw,zw,yw,xw) : FitFunc 
     120//      Wave cw,zw,yw,xw 
     121//       
     122//#if exists("Cylinder_2D_Dist") 
     123//      zw = Cylinder_2D_Dist(cw,yw,xw) 
     124//#else 
     125//      Abort "You do not have the SANS Analysis XOP installed" 
     126//#endif 
     127//      return(0) 
     128//End 
     129// 
     130 
     131//threaded version of the function 
     132ThreadSafe Function Cylinder2D_T(cw,zw,yw,xw,p1,p2) 
     133        WAVE cw,zw,yw,xw 
     134        Variable p1,p2 
     135         
     136        zw[p1,p2]= Cylinder_2D_Dist(cw,yw,xw) 
     137 
     138//      return stopMSTimer(-2)          // time when we finished 
     139        return 0 
     140End 
     141 
     142//function that is actually a wrapper to dispatch the calculation to N threads 
     143// 
    116144Function Cylinder2D(cw,zw,yw,xw) : FitFunc 
    117145        Wave cw,zw,yw,xw 
    118146         
    119 #if exists("Cylinder_2D_Dist") 
    120         zw = Cylinder_2D_Dist(cw,yw,xw) 
    121 #else 
    122         Abort "You do not have the SANS Analysis XOP installed" 
    123 #endif 
     147        Variable npt=numpnts(yw) 
     148        Variable i,nthreads= ThreadProcessorCount 
     149        variable mt= ThreadGroupCreate(nthreads) 
     150 
     151        for(i=0;i<nthreads;i+=1) 
     152//              Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 
     153                ThreadStart mt,i,Cylinder2D_T(cw,zw,yw,xw,(i*npt/nthreads),((i+1)*npt/nthreads-1)) 
     154        endfor 
     155 
     156        do 
     157                variable tgs= ThreadGroupWait(mt,100) 
     158        while( tgs != 0 ) 
     159 
     160        variable dummy= ThreadGroupRelease(mt) 
     161         
    124162        return(0) 
    125163End 
Note: See TracChangeset for help on using the changeset viewer.