Changeset 518 for sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models
- Timestamp:
- Jul 2, 2009 4:51:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2008/SC_ParaCrystal_v40.ipf
r516 r518 98 98 99 99 100 101 // Threaded version 102 // Threaded XOP = 2.46 s 103 // non-threaded XOP = 4.48s (1.8x speedup) 104 // non-threaded, non-XOP = 39.8 s 105 // overall = x 16 speedup ! 106 // 107 Function SC_ParaCrystal(cw,yw,xw) : FitFunc 108 Wave cw,yw,xw 109 110 // Variable t1=StopMSTimer(-2) 111 112 113 /////// NO threading ///////// 114 //#if exists("SC_ParaCrystalX") 115 // yw = SC_ParaCrystalX(cw,xw) 116 //#else 117 // yw = fSC_ParaCrystal(cw,xw) 118 //#endif 119 120 121 ///// THREADING /////// 122 123 124 #if exists("SC_ParaCrystalX") 125 126 Variable npt=numpnts(yw) 127 Variable i,nthreads= ThreadProcessorCount 128 variable mt= ThreadGroupCreate(nthreads) 129 130 for(i=0;i<nthreads;i+=1) 131 // Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 132 ThreadStart mt,i,SC_ParaCrystal_T(cw,yw,xw,(i*npt/nthreads),((i+1)*npt/nthreads-1)) 133 endfor 134 135 do 136 variable tgs= ThreadGroupWait(mt,100) 137 while( tgs != 0 ) 138 139 variable dummy= ThreadGroupRelease(mt) 140 141 //// to return just Z(q), undo the form factor calculation 142 // Variable latticeScale 143 // latticeScale = 4*(4/3)*pi*(cw[3]^3)/((cw[1]*(2^0.5))^3) 144 // 145 // yw /= SphereForm_SC(cw[3],cw[4]-cw[5],xw)*latticeScale 146 //// 147 148 #else 149 yw = fSC_ParaCrystal(cw,xw) // Igor code is NOT threaded, for lots of good reasons 150 #endif 151 152 // Print "elapsed time = ",(StopMSTimer(-2) - t1)/1e6 153 154 return(0) 155 End 156 157 158 100 159 // nothing to change here 101 160 // … … 103 162 // simply calls the original single point calculation with 104 163 // a wave assignment (this will behave nicely if given point ranges) 105 Function SC_ParaCrystal(cw,yw,xw) : FitFunc 164 // 165 // Threaded Version 166 ThreadSafe Function SC_ParaCrystal_T(cw,yw,xw,p1,p2) : FitFunc 106 167 Wave cw,yw,xw 107 168 Variable p1,p2 169 170 // Variable t1=StopMSTimer(-2) 171 108 172 #if exists("SC_ParaCrystalX") 109 yw = SC_ParaCrystalX(cw,xw)173 yw[p1,p2] = SC_ParaCrystalX(cw,xw) 110 174 #else 111 yw = fSC_ParaCrystal(cw,xw)175 yw[p1,p2] = fSC_ParaCrystal(cw,xw) // shouldn't ever see this... 112 176 #endif 177 178 // Print "elapsed time = ",(StopMSTimer(-2) - t1)/1e6 179 113 180 return(0) 114 181 End 182 183 184 185 186 187 115 188 116 189
Note: See TracChangeset
for help on using the changeset viewer.