PPL Parallel_for crashes - VS2010 vr. VS11
-
יום חמישי 26 אפריל 2012 21:23
Code that I had previously written with the PPL library in VS2010 now crashes randomly under V11. Has then been changes that I'm not aware of or are there any known issues
#include <amp.h>
#include <ppl.h>
using namespace concurrency;
void __stdcall float_to_char(long w, long h, float* buf, unsigned char* buf2) {
parallel_for((int)0, (int)h, [&](int y) {
int offset=(w*y);
for (int x=0;x<w;x++){
buf2[offset]=buf[offset];
offset++;
}
});
}
כל התגובות
-
יום שישי 27 אפריל 2012 21:42
This appears to be the same problem as with Parallel_For_each
The code crashes even if all of the inside body is commented out, so it's not a code problem.
However I was able to compile and run the parallel_for_each code finally when I found that we had an XP compatibilty flag set, which isn't the case here. Quick dumb question while I'm there? Will the parallel_for, which was previously handled by PPL, now only run in Windows 8? I'm on 7.
Unhandled exception at at 0x75BAB9BC Microsoft C++ exception: Concurrency::scheduler_resource_allocation_error at memory location 0x0018F094.
//
// Hand it off to the OS:
//
EHTRACE_EXIT;
#if defined(_M_X64) && defined(_NTSUBSET_)
RtlRaiseException( (PEXCEPTION_RECORD) &ThisException );
#else
RaiseException( ThisException.ExceptionCode,
ThisException.ExceptionFlags,
ThisException.NumberParameters,
(PULONG_PTR)&ThisException.params );
#endif
} <-- This was the break point in the debugger... -
שבת 28 אפריל 2012 02:01
Hi Dan,
I think we may need more context on how to invoke your function.
Simply put it into the main function in following way , it won't repro on VS11 Beta or our most recent internal version.
#include <amp.h> #include <ppl.h> using namespace concurrency; void __stdcall float_to_char(long w, long h, float* buf, unsigned char* buf2) { parallel_for((int)0, (int)h, [&](int y) { int offset=(w*y); for (int x=0;x<w;x++){ buf2[offset]=buf[offset]; offset++; } }); } int main() { float *buffer = new float[10000]; unsigned char *buffer2 = new unsigned char [10000]; for (int i = 0; i < 1000; i++) { // try 1000 times float_to_char(100, 100, buffer, buffer2); } return 0; }
Hong -
שבת 28 אפריל 2012 15:33
I'm calling from VB. There, I said it. I know, I'm evil.
-
שבת 28 אפריל 2012 17:27Sorry for the sarcasm. Sometimes us old guys just have to support old code.
-
שבת 28 אפריל 2012 20:35
I couldn't get this to crash in a C project. So, back to the drawing board on what's going on.
#include <amp.h>
#include <ppl.h>
using namespace concurrency;
void __stdcall float_to_char(long w, long h, float* buf, unsigned char* buf2) {
parallel_for((int)0, (int)h, [&](int y) {
int offset=(w*y);
for (int x=0;x<w;x++){
buf2[offset]=(unsigned char) buf[offset];
offset++;
}
});
}
int main()
{
int w=320;
int h=200;
float *buffer = new float[w*h];
unsigned char *buffer2 = new unsigned char [w*h];
for (int i = 0; i < 1000; i++)
{
// try 1000 times
float_to_char(w, h, buffer, buffer2);
}
//free memory
delete [] buffer;
delete [] buffer2;
return 0;
} -
יום ראשון 29 אפריל 2012 17:51
Ok, a few more questions. Both AMP and PPL seem to define their own concurrency namespaces. What exactly am I using when I use Parallel_for under VS11? Previously when I compiled under 2010, I used the /MT flag, I didn't need to include additional dependencies. Under 11 I needed to supply the AMP related dll. Since I was able to compile and run the above example, I'm assuming that is the only additional dependency I need. So, I'm probably barking up the wrong tree.
-
יום שני 30 אפריל 2012 16:48בעלים
Hi Dan,
parallel_for is PPL.
1. Can this be repro-ed without the /MT flag?
2. Can you take a look at the global objects? do you have any global objects related to the concurrency namespace? You might be crossing dll boundaries (i.e. allocating in one and freeing in the other).
Regards,
Rahul V. Patil
-
יום שלישי 01 מאי 2012 22:43
So far I can't make any of it that uses Parallel_for not crash no matter what I do when I call from VB6. This is code that has been stable for months under VS2010.
And no I don't think I'm crossing any dll boundries. I just have these few functions in a dll and that's it.
-
יום רביעי 02 מאי 2012 00:08בעלים
Hi Dan,
We have a hunch. There was a bug in the Developer preview, when mixing C++ AMP and PPL. Can you try excluding amp.h (and other amp related code)?
If it still fails, please feel free to email me. [ r_ a_ h_ u_ l d o t p_ a_ t_ i_ l a t m_ i_ c_ r_ o_ s_ o_ f_ t_ d o t c_ o_ m (delete all underscores and spaces; replace dot with ‘.’ and at with ‘@’).]
Thanks for your patience!
Rahul V. Patil
-
יום רביעי 02 מאי 2012 18:55I'm planning on trying a single function DLL with just PPL and a fresh VB project and see if I get different results. It's just 3 or 4 items down the list of things to do right now.
-
יום חמישי 03 מאי 2012 18:52
I can't simplify much more than this. This is the whole DLL, minus the .def file that defines the one function...
This crashes consistently whenever I call from VB (old VB, not .net). This is code that compiles and runs fine with 2010. And in 11 it's causing an exception before the code on the inside is being executed. even if I comment it out, it still crashes.
#include <Windows.h>
#include <ppl.h>
using namespace concurrency;
//function prototype
void __stdcall float_to_char(long w, long h, float* buf, unsigned char* buf2);
//dll entry point
BOOL WINAPI DllEntryPoint (HINSTANCE hDLL, DWORD dwReason,
LPVOID Reserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
break;
}
case DLL_PROCESS_DETACH:
{
break;
}
}
return TRUE;
}
//our function
void __stdcall float_to_char(long w, long h, float* buf, unsigned char* buf2) {
parallel_for((int)0, (int)h, [&](int y) {
int offset=(w*y);
for (int x=0;x<w;x++){
buf2[offset]=(unsigned char) buf[offset];
offset++;
}
});
}
- נערך על-ידי Dan Ritchie יום חמישי 03 מאי 2012 18:53
-
יום חמישי 03 מאי 2012 19:30
I've compiled this with the /MD flag and it is now functioning.
- הוצע כתשובה על-ידי DanielMothMicrosoft Employee, Owner יום שישי 11 מאי 2012 06:08
- סומן כתשובה על-ידי DanielMothMicrosoft Employee, Owner יום חמישי 17 מאי 2012 03:58