[PATCH] D114460: [fir] Add fir reduction builder

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 29 02:46:24 PST 2021


clementval added inline comments.


================
Comment at: flang/include/flang/Optimizer/Builder/Runtime/Reduction.h:21
+
+/// Generate call to all runtime routine.
+/// This calls the descriptor based runtime call implementation of the all
----------------
awarzynski wrote:
> clementval wrote:
> > kiranchandramohan wrote:
> > > awarzynski wrote:
> > > > rovka wrote:
> > > > > clementval wrote:
> > > > > > awarzynski wrote:
> > > > > > > rovka wrote:
> > > > > > > > Should we use backticks or something around function names? It reads really strange otherwise.
> > > > > > > > Also, isn't this actually AllDim?
> > > > > > > > Should we use backticks or something around function names? 
> > > > > > > +1
> > > > > > > 
> > > > > > > Also, what is the difference between `genAllDescriptor` and `genAll`? Why do we need both?
> > > > > > The comments are pretty clear on the differences. 
> > > > > But to clarify: the runtime sometimes has different entry points for the same intrinsic, for special cases. In this case, IIUC, there's All and AllDim, both of which implement the ALL intrinsic. If you look in the standard, you'll see there's 2 variants: ALL(MASK) or ALL(MASK, DIM).
> > > > > (...) to clarify (...)
> > > > 
> > > > Many thanks @rovka !
> > > > 
> > > > >  If you look in the standard (...)
> > > > Ah, I see! In fact, I think that it would make a lot of sense to refer to the standard here and to use the notation from there as well (like in Diana's comment).
> > > > 
> > > > > The comments are pretty clear on the differences.
> > > > 
> > > > I disagree. There is `genAllDescriptor` and `genAll`, but there's no reference to any "descriptor" in the comments, arguments or the implementation. Also, both methods seem to "Generate call to all runtime routine", but one returns an `mlir::Value`, whereas the other is `void`. If both basically generate a call, then why are the interfaces completely different? I appreciate the this implementation may depend on the APIs in the runtime, but it still does not explain what this "descriptor" in `genAllDescriptor` is and what are the return values are.
> > > For the descriptor version, the result is in an array for which a descriptor is needed. It is probably created by the runtime.
> > > I disagree. There is genAllDescriptor and genAll, but there's no reference to any "descriptor" in the comments, arguments or the implementation. Also, both methods seem to "Generate call to all runtime routine", but one returns an mlir::Value, whereas the other is void. If both basically generate a call, then why are the interfaces completely different? I appreciate the this implementation may depend on the APIs in the runtime, but it still does not explain what this "descriptor" in genAllDescriptor is and what are the return values are.
> > There is a reference to descriptor in the comment and there is a `result` argument which is the "descriptor". 
> > 
> > 
> Thank you all for clarifying. This is starting to make sense. I still believe that the comments for these hooks should be improved and clarify the underlying logic. Please see my suggestion at the top of this file. WDYT? 
I'm not sure your comment represents what's happening. It describes what happens in the runtime but here we are just interested to generate the call and anything related to the runtime should be documented there. 


================
Comment at: flang/lib/Optimizer/Builder/Runtime/Reduction.cpp:553
+  else if (eleTy.isF80())
+    func = fir::runtime::getRuntimeFunc<ForcedMaxvalReal10>(loc, builder);
+  else if (eleTy.isF128())
----------------
rovka wrote:
> What happens if one of these is actually used before it's implemented in the runtime? Will that be a linker error? Or is it caught sooner?
I guess it will result in a linker error. 


================
Comment at: flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp:224
+
+void checkGenMxxloc(fir::FirOpBuilder &builder,
+    void (*genFct)(fir::FirOpBuilder &, Location, mlir::Value, mlir::Value,
----------------
rovka wrote:
> 
It is actually used for Min and Max that's why it is `Mxx`


================
Comment at: flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp:250
+
+void checkGenMxxlocDim(fir::FirOpBuilder &builder,
+    void (*genFct)(fir::FirOpBuilder &, Location, mlir::Value, mlir::Value,
----------------
rovka wrote:
> 
Same here used for both min and max


================
Comment at: flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp:279
+
+void checkGenMxxvalChar(fir::FirOpBuilder &builder,
+    void (*genFct)(
----------------
rovka wrote:
> 
Same here used for both min and max,


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114460/new/

https://reviews.llvm.org/D114460



More information about the llvm-commits mailing list