Fh kokkos b spline#3
Conversation
Fixed indentation for formatting
Fix indentation for the nested loops
Indentation fix
Fixed the indentation
Fixed the indentation and formatting
…simLandIceMeshGen into fh_Kokkos_BSpline
| /*template<typename ExecutionSpace> | ||
| BSplineKokkos<ExecutionSpace>::BSplineKokkos(int orderC, std::vector<double>& ctrlPtsC, std::vector<double>& knotsC, std::vector<double>& weightsC) { | ||
| order = orderC; | ||
| //Allocate appropriate view space based on the number of control points, copy the data over to view | ||
| ctrlPts("ctrlPts", ctrlPtsC.size()); | ||
| for (int i = 0; i < ctrlPtsC.size(); i++) { | ||
| ctrlPts(i) = ctrlPtsC[i]; | ||
| } | ||
| //Same for knots and weights | ||
| knots("knots", knotsC.size()); | ||
| for (int i = 0; i < knotsC.size(); i++) { | ||
| knots(i) = knotsC[i]; | ||
| } | ||
|
|
||
| weights("weights", weightsC.size()); | ||
| for (int i = 0; i < weightsC.size(); i++) { | ||
| weights(i) = weightsC[i]; | ||
| } | ||
| //Call the calculateDerivCoeff() to populate | ||
| //1st and 2nd deriavtive views | ||
|
|
||
| //NOTE: UNCOMMENT THIS ONCE ALL IN FRONT ARE RESOLVED | ||
| //calculateDerivCoeff(); | ||
|
|
||
| }*/ | ||
|
|
||
|
|
||
| /*template<typename ExecutionSpace> | ||
| void BSplineKokkos<ExecutionSpace>::calculateDerivCoeff() { | ||
| //Calculate first order derivative | ||
| //Allocate space for ctrlPts_1stD | ||
| ctrlPts_1stD("ctrlPts1Derivative", ctrlPts.extent(0)-1); | ||
| for (int i = 1; i < ctrlPts.extent(0); i++) { | ||
| double delta = double(order - 1)/(knots(i+order-1)-knots(i)); | ||
| ctrlPts_1stD(i) = ((ctrlPts(i) - ctrlPts(i-1)*delta)); | ||
|
|
||
| } | ||
|
|
||
| //Calculate second order derivative | ||
| //Allocate space for ctrlPts_2ndD | ||
| ctrlPts_2ndD("ctrlPts2Derivative", ctrlPts.extent(0)-2); | ||
| for (int i = 0; i < ctrlPts_1stD.extent(0); i++) { | ||
| double delta = double(order - 2) / (knots(i+order-1)-knots(i+1)); | ||
| ctrlPts_2ndD(i) = ((ctrlPts_1stD(i) - ctrlPts_1stD(i-1))*delta); | ||
| } | ||
| //TODO: find another way to verify the size of the second derivative view | ||
|
|
||
| }*/ | ||
|
|
||
| //Explicit instantiation of the templated class for Kokkos::serial | ||
| //template class BSplineKokkos<Kokkos::Serial>; |
There was a problem hiding this comment.
please remove code that is commented out
| Kokkos::deep_copy(cPOffset, host_cPOffsetV); | ||
| Kokkos::deep_copy(knotsOffset, host_knotsOffsetV); | ||
|
|
||
| //TO DO: Work on calculate derivative coeff |
There was a problem hiding this comment.
I think this 'todo' comment can be removed.
| } | ||
|
|
||
| void calculateDerivCoeff() { | ||
| //Moved here from the .cpp file since it uses <ExecutionSpace> |
There was a problem hiding this comment.
please remove this comment
| @@ -0,0 +1 @@ | |||
| #include "BSplineKokkos2D.h" | |||
There was a problem hiding this comment.
please remove this file (BSplineKokkos2D.cpp) and its entry in the CMakeLists.txt file
| #include<string> | ||
|
|
||
| template<typename ExecutionSpace> | ||
|
|
There was a problem hiding this comment.
please remove this blank line
| //printSpline(kokkosBSP); | ||
| std::vector<double> evalAt = {0, 0.2, 0.41, 0.5, 0.66, 0.73, 0.75, 0.89, 0.94, 1}; | ||
|
|
||
| for (int i = 0; i < 10; i++) { |
There was a problem hiding this comment.
use the length of the evalAt array instead of hardcoding 10
| for (int i = 0; i < 10; i++) { | ||
| double derivX = serialBSP.x.evalFirstDeriv(evalAt[i]); | ||
| double derivY = serialBSP.y.evalFirstDeriv(evalAt[i]); | ||
| std::vector<double> kokkos1stDeriv = kokkosBSP.eval1stDeriv({evalAt[i]}, 0); |
There was a problem hiding this comment.
Are we only loading test csv files with one spline?
Will this work on the GPU? From what I can see, we only have one eval1stDeriv(...) interface and it returns a kokkos view and not a std::vector.
There was a problem hiding this comment.
Please remove this file and BSplineKokkos.cpp. I assume we will only proceed with the version that uses rank 2 kokkos views. As such, after these are removed, we should also remove the 2D suffix from the BSplineKokkos2D.[cpp|h] file names.
There was a problem hiding this comment.
Given that this testing the rank 1 kokkos view implementation, and I assume the rank 2 kokkos view implementation is fully functional, this test file should be removed.
There was a problem hiding this comment.
this file should be removed assuming we are removing the other rank 1 implementations/tests
|
@hsiehhRPI Was clang-format ran on this? I saw some long lines (>80 chars) that I would have expected it to break into multiple lines. |
cwsmith
left a comment
There was a problem hiding this comment.
Please carefully review the comments on the rank 1 implementation/tests/etc and ensure that they are addressed in the rank 2 version if the same code exists there.
This branch included Kokkos version of the BSpline inplementation. The main file is BSplineKokkos2D.h which contains Kokkos version of the BSpline that utilize 2D view for control points. 1st and 2nd derivative evaluation are implemented.