- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am writting code in C90 and using cilkplus. I use a library which define TRY, CATCH macros to simulate the try catch behaviour similar to C++. Now the following piece of code compiles and runs as expected:
int j ;
for ( j=0; j<some_constant; ++j)
{
TRY {
//some code which throws exception
} CATCH(SQLException) {
//some action.
}
END_TRY;
}
but when the same code is run wth cilk_for keword, I get compile error
The code:
int j ;
cilk_for ( j=0; j<some_constant; ++j)
{
TRY {
//some code which throws exception
} CATCH(SQLException) {
//some action.
}
END_TRY;
}
Error:
main.c: In function __cilk_for_001:
main.c:459:4: error: Can not spawn call to function that returns twice
line 459 is the end of scope for cilk_for loop.
I know that we are allowed to use try catch in C++ code so I even tried C++ but therre also the compiler gave the same error message.
Any help appriciated!!
Thanks.
Additional information:
The macros are defined in databse connection pooling library libzdb written in c.
int j ;
for ( j=0; j<some_constant; ++j)
{
TRY {
//some code which throws exception
} CATCH(SQLException) {
//some action.
}
END_TRY;
}
but when the same code is run wth cilk_for keword, I get compile error
The code:
int j ;
cilk_for ( j=0; j<some_constant; ++j)
{
TRY {
//some code which throws exception
} CATCH(SQLException) {
//some action.
}
END_TRY;
}
Error:
main.c: In function __cilk_for_001:
main.c:459:4: error: Can not spawn call to function that returns twice
line 459 is the end of scope for cilk_for loop.
I know that we are allowed to use try catch in C++ code so I even tried C++ but therre also the compiler gave the same error message.
Any help appriciated!!
Thanks.
Additional information:
The macros are defined in databse connection pooling library libzdb written in c.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Aman,
Exception support is not fully implemented in CIlk Plus GCC.
Thanks,
Balaji V. Iyer.
Exception support is not fully implemented in CIlk Plus GCC.
Thanks,
Balaji V. Iyer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following is an excerpt from cilk pluss manual (http://www.google.com/url?sa=t&rct=j&q=try%20catch%20cilk_for&source=web&cd=3&ved=0CFgQFjAC&url=http%3A%2F%2Fsoftware.intel.com%2Ffile%2F28680&ei=hUIPUIjVKoreqAGF94DwDw&usg=AFQjCNG7y2OGBpiRK4b-dcyU4WIK1OOKNA&cad=rja) :
If an exception is thrown from within a
cilk_for loop body (and not handled within the same
iteration), then some of the loop iterations may not run. Unlike a serial execution, it is not
completely predictable which iterations will run and which will not. No iteration (other than the one
throwing the exception) is aborted in the middle.
In the same manual there are examples which show implementation using of try catch block. Can you suggest some work around this The error itself is pretty unexplanatory.
If an exception is thrown from within a
cilk_for loop body (and not handled within the same
iteration), then some of the loop iterations may not run. Unlike a serial execution, it is not
completely predictable which iterations will run and which will not. No iteration (other than the one
throwing the exception) is aborted in the middle.
In the same manual there are examples which show implementation using of try catch block. Can you suggest some work around this The error itself is pretty unexplanatory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The easiest thing to try would be to take your try/catch block and put it into it's own function, and invoke that in your loop.
- Barry
- Barry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would you please explain what do you mean by writting your own try catch block. I could not get what you mean, I am new to these situation, but if you can give me some reference (or an example) on what you suggested I can make my way through. Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What I told you to do was to put the try/catch block in it's own function. Here's the code you posted:
int j ; cilk_for ( j=0; jModify the code by putting the try/catch block in it's own function. Something like:
void do_try_catch_block() { TRY { //some code which throws exception } CATCH(SQLException) { //some action. } END_TRY; } int j ; cilk_for ( j=0; jOf course you'll have to pass a bunch of parameters into the function, but this should isolate the exception handling from the lambda function the compiler will make out of the cilk_for loop body.
- Barry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this:
int unhandledCatch = 0;
int j ;
cilk_for ( j=0; j<some_constant; ++j)
{
TRY {
//some code which throws exception
} CATCH(SQLException) {
//some action.
} CATCH(...) {
// unhandled catch to avoid implicit throw return
unhandledCatch = 1;// or your choice
}
END_TRY;
}
if(unhandledCatch)
... // do something here
Jim Dempsey
int unhandledCatch = 0;
int j ;
cilk_for ( j=0; j<some_constant; ++j)
{
TRY {
//some code which throws exception
} CATCH(SQLException) {
//some action.
} CATCH(...) {
// unhandled catch to avoid implicit throw return
unhandledCatch = 1;// or your choice
}
END_TRY;
}
if(unhandledCatch)
... // do something here
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page