|
Is there a common way to handle such situation?
SomeObject* objects;
omp parallel for
for (i = 0; i < N; i++) {
int res = RunFunction(objects[i]);
if (res)
return res;
}
Once RunFunction failed stop processing and notify application
Чесноков
|
|
|
|
|
I'm no expert on openMP stuff...
can't you just break ? or simply change the loop value so that next iteration will not continue ?
int res;
SomeObject* objects;
omp parallel for
for (i = 0; i < N; i++) {
res = RunFunction(objects[i]);
if (res)
i = N;
}
return res;
Max.
Watched code never compiles.
|
|
|
|
|
break and return are no allowed.
I'm looking for the common practices and patterns in that scenario to not to envent something uncommon.
Чесноков
|
|
|
|
|
I'm no OpenMP expert, but isn't this an example of an algorithm that can't be paralleled as it is written. Imagine two threads, so it runs (0,1), then (2,3), but what if the return value of RunFunction(object[2]) says that the loop should stop, we have probably already executed RunFunction(object[3]).
It is not easy to come up with a way that stops a parallel loop with the same result as stopping a sequential loop.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
it needs to prevent further processing in case of the single error even the next some other parallel returned correctly
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: it needs to prevent further processing in case of the single error even the next some other parallel returned correctly
That's why you want to do it, now you have to find a way to tell the compiler how to do it in one of the standard ways that it knows how to parallelise. Currently you are telling it that if RunFunction(object[n]) is false then it must not execute RunFunction(object[n+1]), and I don't think any compiler will know how to parallelise that.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
the return value of your code corresponds to the logical OR of all those RunFunction invocations. If RunFunction() has no side-effects, you could use a global flag, and even abort all threads once a true value is encountered. If there are side-effects, your code is strictly sequential and cannot be parallellized; at best you could split RunFunction() in a first half without side-effects (that part can be run in parallel), and a second half that produces the side-effects (that part needs to be executed in strict sequence).
|
|
|
|
|
Is there some API to get list of all sockets opened in my process (opened by 3rd party module) and get some usage statistics? (at least last data send/receive timestamp to detect active connections).
Thank you.
|
|
|
|
|
|
Hello everybody,
I have a big understanding problem.
If I write those 2 lines
InvalidateRect(CRect(0,10,0,10));
GetUpdateRect(testrect);
Then "testrect" is empty. Shouldn't it get the values of my InvalidateRect?
Big thanks for any help 
|
|
|
|
|
In fact, your rectangle is empty: CRect constructor accepts, as parameters, rectangle's {left,top, right, bottom}. See CRect constructor at MSDN.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
i m using access database with odbc connection.
here in table i m using a Memo data type.
when i save value upto 255 char in this field its working fine but when i put more than 255 its generate problems.
its gives such type of error.
Mfc internal error: unable to load error string from resource
and generate CDBException at memory location 0x0885fb9c..
please help me for this.
i cant understand what can i do.
thanks in advance.
|
|
|
|
|
Access memo fields only support 255 characters maximum.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
but i think memo field support more than 255 char.
|
|
|
|
|
Happily, what you think has no retrospective effect on the design of the Jet database engine.
It's theoretically possible to store more than 255 bytes in a memo field but there are lots of circumstances in which Access will truncate it to 255 bytes anyway. It treats memo fields like other text fields which have a limit of 255 characters.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
ok now please tell me what can i use for more than 255 char.
|
|
|
|
|
Use an OLE Object field; it's really just for large blobs of binary data.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
please explain me how can i do this.
|
|
|
|
|
Hi,
I have written the an application which configures the DHCP server using c#.
Environment:
Hyper-V Windows 2008 Server R2
API used to crerate subnet is : DHcpCreateSubnet.
Return code: 5
The above return code is received when used for the first time. In second attemp when DHCPCreate subnet is called it succeeds to create the subnet for same IP used as scope address.
For e.g
1st Attempt: Exe is executed first time,.
API used : DHCPCreateSubnet Error code :5 IP used for scope address : 192.168.1.10
2nd Attempt: Exe is executed second time,.
API used : DHCPCreateSubnet Error code :2005 (success), IP used for scope address : 192.168.1.10
Please let me know if you any information on Hyper-V why its is failing for the first time.
Regards
-Ganesh
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
Ganesh_T wrote: I have written the an application which configures the DHCP server using c#.
Then, why do you post your question on the C/C++/MFC forum? The right one is the C# forum...
Ganesh_T wrote: API used to crerate subnet is : DHcpCreateSubnet.
...or you can post the question to the Windows API forum, as you are using one of them through P-Invoke.
|
|
|
|
|
A Visual Studio 2008 console program gets some data in an array of bytes. I want write the data to the console as both ascii and binary. For example if the array contains:
61 62 63 64 65 0 1
The display should look something like:
a b c d e : 61 62 63 64 65 00 01
What data type should I use to hand off to Writeln as in:
Console::WriteLine( "01: {0}", what_data_type );
Edit: To state it better: What would you use to build a string one character at a time?
Thanks for your time
modified on Sunday, October 24, 2010 8:58 PM
|
|
|
|
|
What type is the original array?
61, 62 etc. are hexadecimal representations of a, b etc.
The corresponding ascii value is 97, 98 etc.
If you have a numeric array, you could either convert each item to string using ToString and then use Int32::Parse and Console::WriteLine -
foreach (int i in myarray)
{
int ii = int::Parse(i.ToString(), NumberStyles::HexNumber);
Console::WriteLine("{0} {1:X}", Convert::ToChar(ii), ii);
}
|
|
|
|
|
I am trying to learn to write some TCP/IP code and will receive data as just a bunch of bytes. It can be a char array or a byte array. The important part is suffing the data into some type of string so that I can write it to the display. I'll put text in the left 40 characters replacing non-printables with .. and show the data as hex in the right 40 characters. That way the sender can send anyting and I can see that its being sent and received correctly.
I am using a console based project in Visual Studio C++ just to get something going quickly.
Thanks for your time
|
|
|
|
|
If you have a char array, the code that I posted must pretty much work.
|
|
|
|
|
Then I am missing a few things in your post.
foreach (int i in myarray)
{ int ii = int::Parse(i.ToString(), NumberStyles::HexNumber);
Console::WriteLine("{0} {1:X}", Convert::ToChar(ii), ii);
}
Wyere is myarray referenced?
There is an int on the left side of the =.
I would like to put the data into some kind of a string or character variable then send it out.
The WriteLine will send out a new line for each iteration. WriteLine can be changed to Write, but I still want to build an character based variable.
Thanks for your time
|
|
|
|