[GEANT-5] Optimise TGeoCone for vector processing Created: 29/Apr/13 Updated: 20/Feb/14 Due: 08/May/13 Resolved: 20/Feb/14 Status: Project: Component/s: Affects Version/s: Fix Version/s: Closed Geant detector simulation system Vector navigator None Type: Reporter: Resolution: Labels: Remaining Estimate: Time Spent: Original Estimate: Task Federico Carminati Done None Not Specified Attachments: None Priority: Assignee: Votes: Critical Marilena Bandieramonte 0 Not Specified Not Specified GeantV_TGeoCone_Vectorization.pdf Comments Comment by Marilena Bandieramonte [ 17/Jul/13 ] Hi Sandro, could you please explain me the meaning of the BenchTGeoxxx test output? Thanks, Marilena Comment by Sandro Christian Wenzel [ 17/Jul/13 ] Hi Marilena, in general the benchmark classes time the four important functions "Contains", "Safety", "DistFromInside", "DistFromOutside". The meaning of the number columns in output from the BenchTGeoxxx programs is hence the following: VECTORSIZE TIMECONTAINS RELATIVESPEEDUP TIMESAFETY RELATIVESPEEDUP TIMEDISTFROMIN RELATIVESPEEDUP TIMEDISTFROMOUT RELATIVESPEEDUP If two block if such number appear, it should be noted that the first block is from measuring the standard root libGeom classes in an outer loop ( see file PerformanceTesterT.h ) and the second block is timing from using the vectorized ( and SIMD optimized ) geometry ( see file VecPerfmanceTesterT.h ). Comment by Marilena Bandieramonte [ 17/Jul/13 ] thank you! Comment by Marilena Bandieramonte [ 19/Jul/13 ] Geant5- Vc implementation of TGeoConeSeg_v::Contains_v method Comment by Marilena Bandieramonte [ 19/Jul/13 ] Geant5- Vc implementation of TGeoCone_v::Contains_v method Comment by Federico Carminati [ 23/Jul/13 ] Any news on this issue? Comment by Marilena Bandieramonte [ 11/Sep/13 ] I'm working on the vectorization of the TGeoCone::Safety function and I find a dependency on the TGeoShape::SafetySeg function. I could solve calling trivially the same function in a for loop or I could implement the corresponding vectorized function. Is there someone else who is in charge of the vectorization of the TGeoShape class? Comment by Sandro Christian Wenzel [ 12/Sep/13 ] Hi Marilena, No one else is working on the TGeoShape class but since really only TGeoCone is using this functionality, I would suggest that you momentarily provide an implementation in TGeoCone_v and I will later move it to TGeoShape in the root repository. Comment by Marilena Bandieramonte [ 18/Oct/13 ] Hi everybody, could please someone confirm that the currently used version of the TGeoShape::SafetySeg() function is the following? Double_t TGeoShape::SafetySeg(Double_t r, Double_t z, Double_t r1, Double_t z1, Double_t r2, Double_t z2, Bool_t outer) { // Compute distance from point of coordinates (r,z) to segment (r1,z1):(r2,z2) Double_t crossp = (z2-z1)(r-r1)-(z-z1)(r2-r1); crossp *= (outer) ? 1. : -1.; // Positive crossp means point on the requested side of the (1,2) segment if (crossp < 0) { if (((z-z1)*(z2-z)) > 0) return 0; return TGeoShape::Big(); } // Compute (1,P) dot (1,2) Double_t c1 = (z-z1)(z2-z1)+(r-r1)(r2-r1); // Negative c1 means point (1) is closest if (c1<1.E-10) return TMath::Sqrt((r-r1)(r-r1)+(z-z1)(z-z1)); // Compute (2,P) dot (1,2) Double_t c2 = (z-z2)(z2-z1)+(r-r2)(r2-r1); // Positive c2 means point (2) is closest if (c2>-1.E-10) return TMath::Sqrt((r-r2)(r-r2)+(z-z2)(z-z2)); // The closest point is between (1) and (2) c2 = (z2-z1)(z2-z1)+(r2-r1)(r2-r1); // projected length factor with respect to (1,2) length Double_t alpha = c1/c2; Double_t rp = r1 + alpha*(r2-r1); Double_t zp = z1 + alpha*(z2-z1); return TMath::Sqrt((r-rp)(r-rp)+(z-zp)(z-zp)); } thank you, Marilena Comment by Sandro Christian Wenzel [ 21/Oct/13 ] Yes, by looking at the Root source code, it seems that this is the implementation. Why do you ask? Comment by Marilena Bandieramonte [ 21/Oct/13 ] Cause I've implemented the vectorized version of this function (that I need inside the TGeoCone_v::Safety_v) but it seems to have problems with the test. So I was wondering if it's the correct and actually used version. Comment by Marilena Bandieramonte [ 29/Oct/13 ] Hi, I'm working on the TGeoCone::DistFromInside function and I'm wondering why in the trivially vectorized version the function is called with this parameters: distance[i] = TGeoCone::DistFromInside(point, dir, 3, step[i], 0); Comment by Federico Carminati [ 19/Feb/14 ] Hello, we decided that this task was to be closed. Marilena, can you please do so with an appropriate message explaining what is the final status and the reason for closing? Best, Comment by Marilena Bandieramonte [ 20/Feb/14 ] The work of Vc vectorization on classes TGeoCone and TGeoConeSeg has been successfully carried out regarding the functions Contains() and Safety(). Were obtained gains, in terms of speed-up, of factor 5 and 4 respectively for the Safety() function and Contains() in the TGeoCone class, and speedup equals to 3 and 2.5 for the respective functions of the TGeoConeSeg class. The implementation of DistFromIn() and DistFromOut() functions presents, currently, a number of recursive function calls, which obviate the vectorization effort. Therefore, this task is closed because we have acquired sufficient knowledge about the possible advantages of vectorization with Vc. This task will be moved to the task of implementing a vectorized version of the Cone and ConeSeg in the context of the VecGeom/USolids implementation. Comment by Marilena Bandieramonte [ 20/Feb/14 ] I've attached a file with the report on the work done. Best, Marilena Generated at Tue Feb 09 19:42:32 CET 2016 using JIRA 6.4.9#64024sha1:1f1084e06c9893c77549621edbccfecfaa68be5d.