Comments (5)
Delegate operations can't contain blocking code---the lock() call may block. You can wrap it in a spawn() call to spawn a new task, which will be able to block.
from grappa.
There's also the version of call
that takes a Mutex
of some sort and creates a heap-allocated continuation if it has to block: https://github.com/uwsampa/grappa/blob/master/system/Delegate.hpp#L159
I can't find any instances where it was used. I think I planned to use it in GlobalVector
, but ended up manually using SuspendedDelegate
: https://github.com/uwsampa/grappa/blob/master/system/GlobalVector.hpp#L146
We do have an alternate version of call
that creates a task so it can be suspended, but as the documentation for that method indicates, this can be a problem because there's a chance of running out of workers, leading to deadlock (which happened frequently whenever I tried spawning dependent tasks inside of other tasks), so I encourage you to tread very lightly there.
from grappa.
@bholt could you show me a example how to use the version of call
that takes a Mutex
to try lock on remote mutex? I am confused about the way this functions works after reading the code.
Actually, I just want a function that lock( GlobalAddress<Mutex> m )
does, but I found that I can't use this function to lock on remote mutex since there is just a CHECK(false)
.
https://github.com/uwsampa/grappa/blob/master/system/Mutex.hpp#L106
from grappa.
It's definitely pretty wonky. I meant to wrap it in some nicer functions but never got around to it. It was intended to be as general-purpose as possible, so it takes 2 lambdas: one lambda is like a delegate, but its only purpose is to return a pointer to the Mutex that you want to lock/wait on. Then, when the mutex is unlocked, the second lambda parameter will get invoked, which should probably lock the mutex. But due to me being lazy a long time ago, you also have to return something non-void. So, long story short, I think this should work to do a remote lock as a blocking delegate:
GlobalAddress<Mutex> mptr = /* get global address somehow */;
bool result = delegate::call(mptr.core(),
// runs on remote node; computes local pointer to mutex
// (in this case just getting the pointer component of the
// GlobalAddress, but could be whatever you want)
[mptr]{ return mptr.pointer(); },
// runs once the mutex is unlocked; should probably lock it,
// but then you can also do whatever other work you want,
// such as returning a value from this remote node.
// in this case I just return "true" (have to return something)
[](Mutex* m){
lock(m);
return true;
});
(caveat: I haven't tested this beyond making sure it compiles)
from grappa.
So, this function must return something non-void? Now I know how to deal with my remote mutex, Thank you!
from grappa.
Related Issues (20)
- Compiling grappa with gcc 4.8.3 HOT 3
- beamer_bfs results are always zero
- Signal 11 error on multiple machines HOT 2
- problem to execute a delegate call in send_heap_message HOT 4
- Cannot build grappa applications HOT 17
- Each task process only use one CPU? HOT 6
- Grappa 500 performance number HOT 5
- Running BFS with big(er) graphs HOT 17
- problem to implement multithreaded Grappa HOT 1
- /opt/grappa/include/Grappa/Tasking.hpp:234:3: error: use of undeclared identifier 'on_exit' HOT 2
- Question about global_alloc HOT 3
- Problems to compile PageRank test HOT 5
- Is state_timer still in use?
- applications/pagerank cannot run ? HOT 1
- how to specify parameters to allocate distributed memory HOT 4
- Signal 11 error HOT 5
- sort.exe error 'Address out of locale shared range!'
- Delegation order HOT 1
- HashJoin.hpp has an undefined function: combine()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grappa.