-
Notifications
You must be signed in to change notification settings - Fork 126
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
System.Threading.Parallel (experimental) #99
base: master
Are you sure you want to change the base?
Conversation
You could have Foreach take a |
Implemented with 6dcdf8d |
The remaining problem now is that I can't refer to local variables in the functions as only delegates allow doing that. But I find it much more difficult to pass a delegate than a raw function pointer. |
I tried to use delegate to replace function pointer, but it reported a link error on GetFuncPtr():
|
Hm.. I'll see if I can repro that link error. At any rate, GetFuncPtr will fail at runtime if the delegate contains any state (ie: 'this' pointer, captures)... HOWEVER- what I would do is something like this... (totally untested)
And then set up the concurrency::parallel_for_each to call a lambda that calls back through the |
Thanks a lot, I will try it as soon as possible. |
Er- actually forget that. That doesn't actually work. The core idea of using a state struct to wrap up the delegate is the important part. Your implementation of Parallel::ForeachInternal doesn't actually work, either. You must know the element size but you always assume the element size is sizeof(int). Something that WOULD work would be to keep encapsulating the 'args' in the state object as I did, and then use concurrency::parallel_for and pass the index back through the State.Call method and then just index the mArgs when passing through to the mDelegate... |
The length of an Beef array is int32 on x86 and int64 on x64
Add parallel_invoke for 10+ functions Fix arr type corresponding to 730faaf Fix foreach not working
Does beef actually support the "->" operator? I didn't find any thing about that in the docs. |
My mistake, my brain switched to C for a second there. Should just be a dot operator.
The dot operator works for pointers to structs, there's no arrow operator. |
Code is somehow redundant, requires optimizing...
Invoke and For works well, while Foreach causes access violation. I’ll fix it later. |
Passed pointer of elements to C++, instead of elements themselves.
Actually, my previous implementation does work because I passed a array of pointers to the elements instead of the elements themselves, so I don't have to deal with element sizes in C++.
This sounds great and is feasible for Lists and Arrays, but I plan to support non-sequence containers such as Dictionaries and Deques. Thus, I think that passing array of pointers is the only way to implement that. I will eventually make it usable for all containers implementing ICollection (but I noticed that Beef ICollection is not finished yet). |
Fixes on ParallelInvoke to support delegates
I Implemented Threading.Parallel for all platforms, but I would have to modify Dictionary<TKey, TValue> for a little bit to create a overload for dictionaries. |
A very simple PPL implemention of System.Threading.Parallel, untested, may have bugs.
The only problem that cannot be solved is that I cannot get the pointer to each member of an IEnumerable. Otherwise, I can make Parallel.Foreach generic.
An approach to #85.