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

Resource Integration #89

Open
wants to merge 136 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
808172d
adding camp submodule
mdavis36 Sep 25, 2019
ee604ad
Switching camp branch to device, cmake register camp lib
mdavis36 Sep 25, 2019
756b5db
Setting up example context test file
mdavis36 Sep 26, 2019
71f6f6e
Passing context down to ArrayManager::move
mdavis36 Sep 27, 2019
c87454c
passing context to umpire copy
mdavis36 Oct 4, 2019
a34f1e7
setting exec space in gpu forall
mdavis36 Oct 7, 2019
98a56fc
loop over multiple arrays
davidbeckingsale Oct 8, 2019
877c4cd
ExecutionSpace/Platform equivalence operator.
mdavis36 Oct 9, 2019
d7f3e44
Single memory transfer
mdavis36 Oct 10, 2019
2c44762
gpu -> cpu transfer, move blocking
mdavis36 Oct 10, 2019
fac090e
async copies, segfault on print
mdavis36 Oct 10, 2019
61ef0ab
switching to forall loop
mdavis36 Oct 17, 2019
9fe6a04
trying to print
mdavis36 Oct 17, 2019
1ef9f9d
Tweak context exampel
davidbeckingsale Oct 18, 2019
9f85364
Merge branch 'develop' into feature/device-context-integration
davidbeckingsale Oct 18, 2019
7c20b10
print w & w/o context, remove forall debug output
mdavis36 Oct 18, 2019
feaaa51
forcing wait after copy
mdavis36 Oct 18, 2019
b30d107
Fixup logging in ManagedArray
davidbeckingsale Oct 18, 2019
d877248
Update logging in ArrayManager
davidbeckingsale Oct 18, 2019
cc50e35
Merge branch 'feature/device-context-integration' of github.com:LLNL/…
davidbeckingsale Oct 18, 2019
ec14672
Add dummy context example
davidbeckingsale Oct 18, 2019
f073f76
Move simple more complex
davidbeckingsale Oct 18, 2019
0058134
Cleaning context-integration example code
mdavis36 Oct 18, 2019
2344529
Start adding context tests
davidbeckingsale Oct 18, 2019
3de01e2
Removing camp submodule
mdavis36 Oct 21, 2019
52b4599
Check if Cuda is enabled before building Cuda Context examples.
mdavis36 Oct 21, 2019
26f8d0d
Merge branch 'feature/device-context-integration' of github.com:LLNL/…
davidbeckingsale Oct 21, 2019
73d3557
Context namespace -> Resources
mdavis36 Oct 21, 2019
10b2db0
Merge branch 'feature/device-context-integration' of https://github.c…
mdavis36 Oct 21, 2019
94cb802
Update simple example
davidbeckingsale Oct 21, 2019
e169b4c
Merge branch 'feature/device-context-integration' of github.com:LLNL/…
davidbeckingsale Oct 21, 2019
ba87903
Namespace change for tests
mdavis36 Oct 21, 2019
99919f7
Example array size and time change
mdavis36 Oct 21, 2019
b1ed7ac
Fixing Non Cuda build tests.
mdavis36 Oct 21, 2019
33172ef
Fixing no context gpu call
mdavis36 Oct 21, 2019
6ecb678
updating umpire
mdavis36 Oct 21, 2019
7d85179
Dependent context example.
mdavis36 Oct 21, 2019
cab2435
Using context to print on depends example.
mdavis36 Oct 22, 2019
eeb9b82
Fixing all example prints.
mdavis36 Oct 22, 2019
de9f7b6
New wait_on strategy, first pass.
mdavis36 Oct 22, 2019
5897d64
Reducing example array size.
mdavis36 Oct 23, 2019
4f0aebc
Change context on CPU space. Fix test Segfault.
mdavis36 Oct 23, 2019
1b95c0f
Adding non ManagedArray context example
mdavis36 Oct 23, 2019
2f2e578
Example trying to access out of bounds
mdavis36 Oct 24, 2019
2365e1e
Updating umpire
mdavis36 Oct 24, 2019
5d16eff
Updating Umpire
mdavis36 Oct 24, 2019
b3ced7a
Updating Camp with seperated resource/context headers
mdavis36 Oct 25, 2019
5926b9e
Using a list of events for handling multi-context management
mdavis36 Dec 11, 2019
9b72e0b
Adding multi array/context example and reverting last changes.
mdavis36 Jan 8, 2020
1de6885
Working multi context per array
mdavis36 Jan 8, 2020
2001912
Clearing active context/resource list on copy
mdavis36 Jan 8, 2020
27eadce
Enqueuing waits on stream
mdavis36 Jan 8, 2020
a5ca2b5
Merge remote-tracking branch 'origin/develop' into feature/multi-reco…
mdavis36 Jan 9, 2020
7e2ffb5
Changing active context list to an array
mdavis36 Jan 15, 2020
99ba12d
Merge branch 'develop' into feature/device-context-integration
mdavis36 Jan 29, 2020
521505e
Removing commented code for camp submodule
mdavis36 Jan 29, 2020
131a986
Merge branch 'feature/device-context-integration' into feature/multi-…
mdavis36 Jan 29, 2020
abc8d71
Fixing errors when compiling without Cuda/Hip
mdavis36 Jan 30, 2020
5430629
Adding ActiveResourceManager Container class for handling multiple re…
mdavis36 Feb 3, 2020
fbc00a2
Updating Umpire
mdavis36 Feb 5, 2020
9b07d5d
Updating camp Resource objects
mdavis36 Feb 5, 2020
91524d2
Merge branch 'feature/device-context-integration' into feature/multi-…
mdavis36 Feb 5, 2020
1a7148d
Bumping umpire
mdavis36 Feb 19, 2020
72cfa72
Merge branch 'feature/device-context-integration' into feature/multi-…
mdavis36 Feb 19, 2020
a30e67d
Merge branch 'develop' into feature/device-context-integration
mdavis36 Apr 6, 2020
bdb7465
Updating Umpire and BLTv0.3.0
mdavis36 Apr 6, 2020
f20b59d
Fixing benchmark_api header name change.
mdavis36 Apr 6, 2020
6d14af0
Merge branch 'develop' into feature/device-context-integration
mdavis36 May 26, 2020
1a39b70
Fixing failed tests on Managed_Array_Tests.
mdavis36 May 26, 2020
9305308
Trying to unify CHAI move
mdavis36 Jun 4, 2020
f41551e
Printable callback Types and ExecutionSpaces
mdavis36 Jun 5, 2020
00ef5e5
Adding name of array to callback, need to remove later.
mdavis36 Jun 5, 2020
bc0177f
More debug statements
mdavis36 Jun 5, 2020
13095be
Callbacks for managed_array_resource_tests
mdavis36 Jun 5, 2020
6d73a40
Lots of prints for debugging...
mdavis36 Jun 8, 2020
d76456b
Change to stop segfaults, incorrect values returned.
mdavis36 Jun 8, 2020
b1047b8
Make sure PointerRecord is initialized correctly
davidbeckingsale Jun 11, 2020
f0186d4
Bumping Umpire w/ cuda device fix.
mdavis36 Jun 29, 2020
8f63be9
Use pinned host memory when possible if GPU enabled.
mdavis36 Jun 29, 2020
44101f5
Cleaning up resource examples.
mdavis36 Jun 29, 2020
467b43c
Removing print statements from ArrayManager.cpp
mdavis36 Jun 29, 2020
234025b
Moving resource example helper header into util.
mdavis36 Jun 29, 2020
0ca9c6e
Adding Resource tests.
mdavis36 Jun 29, 2020
1c9f650
Re-run tests.
mdavis36 Jul 13, 2020
6373598
Merge branch 'develop' into feature/device-context-integration
mdavis36 Aug 4, 2020
1914a31
Moving m_pointer_record back.
mdavis36 Aug 6, 2020
1385bdd
Pointing Umpire to v3.0.0.
mdavis36 Aug 6, 2020
5e11b4d
Removing old debugging code.
mdavis36 Aug 7, 2020
99c74d0
Removing include vector.
mdavis36 Aug 7, 2020
44a04a4
Removing commented out test.
mdavis36 Aug 7, 2020
71f8c45
Merge branch 'develop' into feature/device-context-integration
davidbeckingsale Aug 11, 2020
bd3f511
Merge branch 'develop' into feature/device-context-integration
mdavis36 Sep 1, 2020
6270fa4
Merge branch 'feature/device-context-integration' into feature/multi-…
mdavis36 Sep 22, 2020
ecd991f
Merge branch 'develop' into feature/device-context-integration
mdavis36 Sep 22, 2020
bc99917
Merge pull request #93 from LLNL/feature/multi-recource-per-array
davidbeckingsale Sep 22, 2020
db37733
merging submodules etc
Nov 23, 2021
d66b267
Merge branch 'develop' into feature/device-context-integration
kab163 Dec 9, 2021
6f3cf8b
change uberenv to also depend on camp
kab163 Dec 14, 2021
0a34106
Merge branch 'feature/device-context-integration' of https://github.c…
kab163 Dec 14, 2021
8246998
changing version of camp in CI
kab163 Dec 14, 2021
e001520
trying to fix camp in CI...
kab163 Dec 15, 2021
c3b06bb
updating from develop
kab163 Dec 15, 2021
0f4cea7
had to change the camp version in umpire package too
kab163 Dec 16, 2021
103d537
changing the tpl job to also depend on correct camp version
kab163 Dec 16, 2021
2188b12
removing the quartz tpl job for now
kab163 Dec 16, 2021
ac7167d
resolving conflicts to merge
kab163 Jul 5, 2022
d53c05f
Add missing files to CMakeLists.txt
adayton1 Nov 17, 2022
54c1f1e
Don't tie CHAI spack package to specific version of CAMP
adayton1 Nov 17, 2022
cb5d1e3
Stylistic fixes
adayton1 Nov 17, 2022
74a4117
Clean up in unit tests
adayton1 Nov 17, 2022
60d254d
Document parameter
adayton1 Nov 17, 2022
0a0c745
Fix GPU simulation mode
adayton1 Nov 29, 2022
13c4e2f
Fix synchronization for unified/pinned memory
adayton1 Mar 29, 2023
cf9a306
Merge branch 'develop' into feature/device-context-integration
adayton1 Apr 14, 2023
cc1eee7
Update to RAJA 2022.10.5
adayton1 Apr 14, 2023
2bebbf7
Fix typo
adayton1 Apr 14, 2023
897f763
More strict checking
adayton1 Apr 14, 2023
2a99083
Use default constructor
adayton1 Apr 14, 2023
cd5e8a5
Reduce duplicate code
adayton1 Apr 14, 2023
3aad2cd
Documentation and clean up
adayton1 Apr 14, 2023
79174e2
More cleanup and documentation
adayton1 Apr 14, 2023
7b0f907
Document more functions
adayton1 Apr 14, 2023
e606ad7
More clean up
adayton1 Apr 14, 2023
7691033
More strict checking
adayton1 Apr 14, 2023
69a5890
Document variables added to PointerRecord
adayton1 Apr 14, 2023
5b7e9df
Remove unnecessary include
adayton1 Apr 14, 2023
17478ef
Clean up
adayton1 Apr 14, 2023
131654f
Reuse move implementation
adayton1 Apr 14, 2023
4844238
Clean up
adayton1 Apr 14, 2023
8f4d31a
Clean up move function
adayton1 Apr 14, 2023
1b1c735
Clean up
adayton1 Apr 14, 2023
e071ca4
Reorder arguments for better intuition
adayton1 Apr 14, 2023
87957a5
Fix execution space unit tests
adayton1 Apr 24, 2023
1303255
Fix ManagedArray<T>::move argument order
adayton1 Apr 24, 2023
a24145a
Add tests back in
adayton1 Apr 24, 2023
67b279d
Attempt to fix ExternalConstructorUnowned test
adayton1 Apr 24, 2023
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
17 changes: 16 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,22 @@ if (CHAI_ENABLE_CUDA OR CHAI_ENABLE_HIP)
NAME chai-example.exe
SOURCES example.cpp
DEPENDS_ON ${chai_umpire_example_depends})

blt_add_executable(
NAME resource-depends.exe
SOURCES resource-depends.cpp
DEPENDS_ON ${chai_umpire_example_depends})
blt_add_executable(
NAME resource-simple.exe
SOURCES resource-simple.cpp
DEPENDS_ON ${chai_umpire_example_depends})
blt_add_executable(
NAME resource-not-managed.exe
SOURCES resource-not-managed.cpp
DEPENDS_ON ${chai_umpire_example_depends})
blt_add_executable(
NAME resource-multi-array.exe
SOURCES resource-multi-array.cpp
DEPENDS_ON ${chai_umpire_example_depends})
blt_add_executable(
NAME pinned.exe
SOURCES pinned.cpp
Expand Down
52 changes: 52 additions & 0 deletions examples/resource-depends.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016-20, Lawrence Livermore National Security, LLC and CHAI
// project contributors. See the COPYRIGHT file for details.
//
// SPDX-License-Identifier: BSD-3-Clause
//////////////////////////////////////////////////////////////////////////////
#include "camp/resource.hpp"
#include "chai/ManagedArray.hpp"

#include "../src/util/forall.hpp"
#include "../src/util/gpu_clock.hpp"

#include <vector>
#include <utility>


int main()
{
constexpr std::size_t ARRAY_SIZE{1000};
int clockrate{get_clockrate()};

camp::resources::Resource dev1{camp::resources::Cuda{}};
camp::resources::Resource dev2{camp::resources::Cuda{}};
camp::resources::Resource host{camp::resources::Host{}};

chai::ManagedArray<double> array1(ARRAY_SIZE);
chai::ManagedArray<double> array2(ARRAY_SIZE);

auto e1 = forall(&dev1, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
array1[i] = i;
gpu_time_wait_for(10, clockrate);
});

auto e2 = forall(&dev2, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
array2[i] = -1;
gpu_time_wait_for(20, clockrate);
});

dev1.wait_for(&e2);

forall(&dev1, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
array1[i] *= array2[i];
gpu_time_wait_for(10, clockrate);
});

array1.move(chai::CPU, &dev1);

forall(&host, 0, 10, [=] CHAI_HOST_DEVICE (int i) {
printf("%f ", array1[i]);
});
printf("\n");
}
50 changes: 50 additions & 0 deletions examples/resource-multi-array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016-20, Lawrence Livermore National Security, LLC and CHAI
// project contributors. See the COPYRIGHT file for details.
//
// SPDX-License-Identifier: BSD-3-Clause
//////////////////////////////////////////////////////////////////////////////
#include "camp/resource.hpp"
#include "chai/ManagedArray.hpp"

#include "../src/util/forall.hpp"
#include "../src/util/gpu_clock.hpp"

#include <vector>
#include <utility>


int main()
{
constexpr std::size_t ARRAY_SIZE{1000};
int clockrate{get_clockrate()};

chai::ManagedArray<double> array1(ARRAY_SIZE);

camp::resources::Resource dev1{camp::resources::Cuda{}};
camp::resources::Resource dev2{camp::resources::Cuda{}};


auto e1 = forall(&dev1, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
if (i % 2 == 0) {
array1[i] = i;
gpu_time_wait_for(10, clockrate);
}
});

auto e2 = forall(&dev2, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
if (i % 2 == 1) {
gpu_time_wait_for(20, clockrate);
array1[i] = i;
}
});

array1.move(chai::CPU, &dev1);

camp::resources::Resource host{camp::resources::Host{}};

forall(&host, 0, 10, [=] CHAI_HOST_DEVICE (int i) {
printf("%f ", array1[i]);
});
printf("\n");
}
52 changes: 52 additions & 0 deletions examples/resource-not-managed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016-20, Lawrence Livermore National Security, LLC and CHAI
// project contributors. See the COPYRIGHT file for details.
//
// SPDX-License-Identifier: BSD-3-Clause
//////////////////////////////////////////////////////////////////////////////
#include "camp/resource.hpp"

#include "../src/util/forall.hpp"
#include "../src/util/gpu_clock.hpp"

#include <vector>
#include <utility>


int main()
{
constexpr std::size_t ARRAY_SIZE{1000};
int clockrate{get_clockrate()};

camp::resources::Resource dev1{camp::resources::Cuda{}};
camp::resources::Resource dev2{camp::resources::Cuda{}};
camp::resources::Resource host{camp::resources::Host{}};

float * d_array1 = dev1.allocate<float>(1000);
float * d_array2 = dev2.allocate<float>(1000);
float * h_array1 = host.allocate<float>(1000);

auto e1 = forall(&dev1, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
d_array1[i] = i;
gpu_time_wait_for(10, clockrate);
});

auto e2 = forall(&dev2, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
d_array2[i] = -1;
gpu_time_wait_for(20, clockrate);
});

dev1.wait_for(&e2);

forall(&dev1, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
d_array1[i] *= d_array2[i];
gpu_time_wait_for(10, clockrate);
});

dev1.memcpy(h_array1, d_array1, sizeof(float) * 1000);

forall(&host, 0, 10, [=] CHAI_HOST_DEVICE (int i) {
printf("%f ", h_array1[i]);
});
printf("\n");
}
57 changes: 57 additions & 0 deletions examples/resource-simple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016-20, Lawrence Livermore National Security, LLC and CHAI
// project contributors. See the COPYRIGHT file for details.
//
// SPDX-License-Identifier: BSD-3-Clause
//////////////////////////////////////////////////////////////////////////////
#include "../src/util/forall.hpp"
#include "../src/util/gpu_clock.hpp"

#include "chai/ManagedArray.hpp"
#include "camp/resource.hpp"

#include <vector>
#include <utility>


int main()
{

constexpr int NUM_ARRAYS = 16;
constexpr std::size_t ARRAY_SIZE{100};

std::vector<chai::ManagedArray<double>> arrays;
camp::resources::Resource host{camp::resources::Host{}};


int clockrate{get_clockrate()};

for (std::size_t i = 0; i < NUM_ARRAYS; ++i) {
arrays.push_back(chai::ManagedArray<double>(ARRAY_SIZE));
}

for (auto array : arrays) {
forall(&host, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
array[i] = i;
});
}

for (auto array : arrays) {
camp::resources::Resource resource{camp::resources::Cuda{}};

forall(&resource, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
array[i] = array[i] * 2.0;
gpu_time_wait_for(20, clockrate);
});

array.move(chai::CPU, &resource);
}

for (auto array : arrays) {
forall(&host, 0, ARRAY_SIZE, [=] CHAI_HOST_DEVICE (int i) {
if (i == 25) {
printf("array[%d] = %f \n", i, array[i]);
}
});
}
}
7 changes: 5 additions & 2 deletions scripts/spack_packages/chai/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ class Chai(CMakePackage, CudaPackage, ROCmPackage):
multi=False, description='Tests to run')

depends_on('umpire')
depends_on('raja', when="+raja")

depends_on('umpire@main', when='@main')

depends_on('camp')
depends_on('camp@main', when='@main')

depends_on('raja', when="+raja")
depends_on('raja@main', when="@main+raja")

depends_on('cmake@3.14:', type='build')
Expand Down
90 changes: 90 additions & 0 deletions src/chai/ActiveResourceManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and CHAI
// project contributors. See the COPYRIGHT file for details.
//
// SPDX-License-Identifier: BSD-3-Clause
//////////////////////////////////////////////////////////////////////////////
#ifndef CHAI_ActiveResourceManager_HPP
#define CHAI_ActiveResourceManager_HPP

#include "camp/resource.hpp"

#include <array>
#include <vector>

namespace chai
{

/*!
* \Class to store list of Resource pointers. Holds data on the stack
* until a certain threshold, then uses heap memory.
*/
class ActiveResourceManager {

/*!
* Size of array on the stack.
*/
static constexpr int BASE_SIZE = 16;

/*!
* Base array on the stack.
*/
std::array<camp::resources::Resource*, BASE_SIZE> m_res_base;

/*!
* Heap container for extra resources if more than BASE_SIZE pushed.
*/
std::vector<camp::resources::Resource*> m_res_overflow;

/*!
* Current number of active resources in the list.
*/
int m_size = 0;

public:
/*!
* Default constructor.
*/
ActiveResourceManager() = default;

/*!
* Return current size of the resource list.
*
* \return The current size of the resource list.
*/
int size();

/*!
* Push a new resource onto the list.
*
* \param res The resource to add.
*/
void push_back(camp::resources::Resource* res);

/*!
* Clear all values on the heap and set m_size to 0.
*/
void clear();

/*!
* Check if empty.
*
* \return Whether or not the resource manager is empty.
*/
bool is_empty() const;

/*!
* Get resource at given index.
*
* \param i The index at which to get a resource.
*
* \return The resource at the given index.
*/
camp::resources::Resource* operator [](int i) const;
};

} // end of namespace chai

#include "chai/ActiveResourceManager.inl"

#endif // CHAI_ActiveResourceManager_HPP
Loading