forked from ComputationalRadiationPhysics/redGrapes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5_access_demotion.cpp
56 lines (45 loc) · 1.38 KB
/
5_access_demotion.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright 2019 Michael Sippel
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <thread>
#include <chrono>
#include <iostream>
#include <redGrapes/redGrapes.hpp>
#include <redGrapes/resource/ioresource.hpp>
#include <redGrapes/scheduler/default_scheduler.hpp>
namespace rg = redGrapes;
int main( int, char*[] )
{
spdlog::set_level(spdlog::level::trace);
rg::init();
rg::IOResource< int > a;
rg::emplace_task(
[]( auto a )
{
std::cout << "f1 writes A" << std::endl;
std::this_thread::sleep_for( std::chrono::seconds(1) );
std::cout << "f1 now only reads A" << std::endl;
rg::update_properties(
rg::TaskProperties::Patch::Builder()
.remove_resources({ a.write() })
.add_resources({ a.read() })
);
std::this_thread::sleep_for( std::chrono::seconds(1) );
std::cout << "f1 done" << std::endl;
},
a.write()
);
rg::emplace_task(
[]( auto a )
{
std::cout << "f2 reads A" << std::endl;
std::cout << "f2 done" << std::endl;
},
a.read()
);
rg::finalize();
return 0;
}