Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kokkos-aware Clad #783

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
082bb20
Modify Clad to use Kokkos views in forward mode
kliegeois Nov 22, 2023
9b9612e
Add parallel_for
kliegeois Nov 30, 2023
9284719
Add Kokkos subviews
kliegeois Dec 8, 2023
65557a9
Add Kokkos examples
kliegeois Dec 12, 2023
322ca21
Add CMakeLists.txt for the Kokkos example and push the generated file
kliegeois Dec 14, 2023
02dd2ce
Start to work on the reverse mode
kliegeois Dec 15, 2023
7e9c540
Propagate derivatives inside Kokkos view
kliegeois Dec 15, 2023
2cd5231
Modify the test to use the generated file
kliegeois Dec 15, 2023
db086a5
Add a first implementation of a deep_copy
kliegeois Dec 15, 2023
ef1d117
Update the implementation of the deep_copy
kliegeois Dec 16, 2023
43fa4d6
Reset _d_a to zero after a reverse deep_copy
kliegeois Dec 19, 2023
092f425
Fix generated deep_copy by removing not needed arguments
kliegeois Dec 19, 2023
1eb525e
Clean a bit of the copy paste
kliegeois Dec 19, 2023
91ec308
Move towards the usage of kokkos_builtin_derivative::parallel_sum ins…
kliegeois Dec 19, 2023
f87ccd2
Move towards the usage of subview
kliegeois Dec 20, 2023
ee88c2e
Update the isKokkosView logic
kliegeois Dec 20, 2023
1118bbe
Use the fact that a Kokkos view is passed by reference
kliegeois Dec 21, 2023
3fe3122
Add a gradient of a 2D->double function
kliegeois Dec 21, 2023
d6c4633
Use the gradient of the 2D-> double function to solve a simple optimi…
kliegeois Dec 21, 2023
814e46d
Reenable a forward test
kliegeois Dec 21, 2023
aef1422
Clean files
kliegeois Dec 21, 2023
230baba
Add a python script to postprocess the generated Derivative.cpp
kliegeois Dec 21, 2023
f5b2f4b
update the gradient descent test
kliegeois Dec 22, 2023
09956bc
add timers
kliegeois Dec 22, 2023
b7f2d71
Modify the test to be run on GPU and generalize the parallel_sum func…
kliegeois Jan 2, 2024
09d3dec
Use more template type member to deduce some of the temporary types
kliegeois Jan 2, 2024
327c88a
Add create_mirror_view
kliegeois Jan 2, 2024
ddd5763
Use f_view in double f(double x, double y)
kliegeois Jan 2, 2024
d01770d
Use a partial template instanciation of ViewSum and ViewAdd
kliegeois Jan 3, 2024
36aec0a
Modify ViewSum and ViewAdd to be compiled with CUDA
kliegeois Jan 3, 2024
281fb5a
parallel_sum to use flat views if contiguous span
kliegeois Jan 3, 2024
06f4ae0
parallel_sum add fences
kliegeois Jan 3, 2024
6ff32fa
start working on lambdas
kliegeois Jan 3, 2024
fa7f261
add a multi layers example
kliegeois Jan 3, 2024
fe14c82
update the multi layer example to run on the GPU
kliegeois Jan 3, 2024
0cbb811
fix one of the lambda warning
kliegeois Jan 4, 2024
6a7bf98
clean a little bit the test
kliegeois Jan 4, 2024
7e82114
add a include dir
kliegeois Jan 4, 2024
f80f4a5
Update the lambda visit
kliegeois Jan 8, 2024
aa6a104
try the isInsideLoop
kliegeois Jan 9, 2024
f0448e5
Use a 2 steps compilation process
kliegeois Jan 9, 2024
492536d
Start working on KokkosViewAccessVisitor
kliegeois Jan 9, 2024
db084ee
Precompute which views need to be recorded
kliegeois Jan 10, 2024
1bf65b1
Copy the required views and restore them before the reverse pass
kliegeois Jan 10, 2024
6ee3054
update the example
kliegeois Jan 10, 2024
c80fc4e
Update DelayedStoreResult
kliegeois Jan 11, 2024
4d0050f
Update BuildVarDecl
kliegeois Jan 11, 2024
a9c0b17
update the example
kliegeois Jan 11, 2024
8d8548c
Start working on the accesses per thread
kliegeois Jan 12, 2024
c023697
Use getBeginLoc to compare view accesses
kliegeois Jan 12, 2024
b9a7a76
Update the example
kliegeois Jan 12, 2024
09e1211
Start to implement the logic
kliegeois Jan 13, 2024
b25d91c
Use isIdenticalStmt
kliegeois Jan 13, 2024
6c62817
Update the example
kliegeois Jan 13, 2024
96eaaa5
nested view accesses
kliegeois Jan 15, 2024
ce5e8af
do not test the safety of a LHS view access of an AssignmentOp
kliegeois Jan 15, 2024
a450d90
use pushCodeSynthesisContext
kliegeois Jan 15, 2024
e45f6d3
use CXXConstructExpr for the captures of the lambda
kliegeois Jan 15, 2024
b6724da
move towards the copy of the lambda operator ()
kliegeois Jan 15, 2024
7d45a90
Add comments on the lambda operators
kliegeois Jan 15, 2024
bd0b9ca
Start the work towards hierarchical parallelism
kliegeois Jan 17, 2024
027dfe6
clean
kliegeois Jan 18, 2024
5d79b2c
remove warning
kliegeois Jan 18, 2024
845a1b3
merged master
kliegeois Jan 18, 2024
14342cb
Update the CMakeLists of the unittests
kliegeois Jan 18, 2024
2bb7bc9
fix a bug
kliegeois Jan 18, 2024
1a5193b
start to add unit tests
kliegeois Jan 19, 2024
21af8c1
towards fixing of the deep_copy test
kliegeois Jan 22, 2024
0fa0dc0
fix kokkos deep_copy test
kliegeois Jan 22, 2024
8a831e9
fix Clad tests
kliegeois Jan 22, 2024
630538c
Fix the construction of the dual team policy
kliegeois Jan 22, 2024
0239a5a
Don't make a std::vector of const SourceLocation
brian-kelley Jan 23, 2024
1b9dead
cleaned
kliegeois Feb 15, 2024
816cfad
Add comments
kliegeois Feb 22, 2024
3a585dd
link Kokkos::kokkos
kliegeois Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ if (NOT CLAD_BUILT_STANDALONE)
include_directories(BEFORE SYSTEM
${CMAKE_CURRENT_BINARY_DIR}/../clang/include
${CMAKE_CURRENT_SOURCE_DIR}/../clang/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../clang/include
)
endif()

Expand Down
21 changes: 21 additions & 0 deletions include/clad/Differentiator/CladUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ namespace clad {
clang::DeclContext* GetOutermostDC(clang::Sema& semaRef,
clang::DeclContext* DC);

clang::Expr* GetUnresolvedLookup(clang::Sema& semaRef,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASTContext can be obtained through Sema. We don't need to pass both of them to a function.

clang::ASTContext& C,
std::string NS,
std::string FN);

/// Creates a `StringLiteral` node to represent string literal
/// "`str`".
///
Expand All @@ -174,6 +179,22 @@ namespace clad {
/// otherwise returns false.
bool HasAnyReferenceOrPointerArgument(const clang::FunctionDecl* FD);

/// Returns true if `constructedTypeName` is a string describing Kokkos::TeamPolicy type.
bool IsKokkosTeamPolicy(const std::string constructedTypeName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'constructedTypeName' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
bool IsKokkosTeamPolicy(const std::string constructedTypeName);
bool IsKokkosTeamPolicy(std::string constructedTypeName);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps kokkos specific functions should be in a separate namespace altogether?


/// Returns true if `constructedTypeName` is a string describing Kokkos::TeamThreadRange,
/// Kokkos::ThreadVectorRange, or Kokkos::TeamVectorRange type.
bool IsKokkosRange(const std::string constructedTypeName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'constructedTypeName' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
bool IsKokkosRange(const std::string constructedTypeName);
bool IsKokkosRange(std::string constructedTypeName);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass std::string as const std::string& instead of const std::string. const in parameters not being passed as reference is meaningless for the caller.


/// Returns true if `constructedTypeName` is a string describing Kokkos::Member type.
bool IsKokkosMember(const std::string constructedTypeName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'constructedTypeName' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
bool IsKokkosMember(const std::string constructedTypeName);
bool IsKokkosMember(std::string constructedTypeName);


/// Returns true if `constructedTypeName` is a string describing Kokkos::View type.
bool IsKokkosView(const std::string constructedTypeName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'constructedTypeName' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
bool IsKokkosView(const std::string constructedTypeName);
bool IsKokkosView(std::string constructedTypeName);


/// Returns true if `T` is a Kokkos::View type.
bool IsKokkosView(clang::QualType T);

/// Returns true if `T` is a reference, pointer or array type.
///
/// \note Please note that this function returns true for array types as
Expand Down
Loading
Loading