Click here to Skip to main content
15,883,793 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can find List item click or checkbox click? Pin
David Crow13-Nov-10 15:41
David Crow13-Nov-10 15:41 
GeneralRe: How can find List item click or checkbox click? Pin
«_Superman_»14-Nov-10 4:01
professional«_Superman_»14-Nov-10 4:01 
QuestionFault Address error Pin
MKC00212-Nov-10 21:24
MKC00212-Nov-10 21:24 
AnswerRe: Fault Address error Pin
Stephen Hewitt13-Nov-10 2:27
Stephen Hewitt13-Nov-10 2:27 
AnswerRe: Fault Address error Pin
Code-o-mat13-Nov-10 8:48
Code-o-mat13-Nov-10 8:48 
QuestionCString to double [modified] Pin
john563212-Nov-10 21:10
john563212-Nov-10 21:10 
AnswerRe: CString to double Pin
Stephen Hewitt13-Nov-10 2:30
Stephen Hewitt13-Nov-10 2:30 
QuestionTerminating OpenMP loop early Pin
Damir Valiulin12-Nov-10 12:51
Damir Valiulin12-Nov-10 12:51 
Another poster already asked similar question already (http://www.codeproject.com/Messages/3644795/What-is-the-best-way-to-break-return-from-OpenMP-l.aspx[^]), but I'll ask anyway.

I have a function that checks if a point belongs to an object in array. The loop looks like this:

for (int i=0; i<N; i++)
{
  if (point_is_in_object(obj[i], pt){
    return true;
  }
}
return false;


I parallelized it with OpenMP by adding shared boolean flag found.

bool found = false;
#pragma omp parallel for
for (int i=0; i<N; i++)
{
  if (!found)
  {
    if (point_is_in_object(obj[i], pt){
      found = true;
      #pragma omp flush (found)
    }
  }
}

return found;


Is this a good way to do this? Could this cause access violation when one thread is writing and the other thread is reading memory contents of found flag?

I'm new to OpenMP and don't know much how it operates under the hood. With standard Win32 I would isolate access to found with critical section. Should I do the same here as well and add critical clause?

Thanks
AnswerRe: Terminating OpenMP loop early Pin
Randor 13-Nov-10 1:11
professional Randor 13-Nov-10 1:11 
GeneralRe: Terminating OpenMP loop early Pin
Damir Valiulin15-Nov-10 7:12
Damir Valiulin15-Nov-10 7:12 
QuestionUsing Liberary Module in VS 2008?? Pin
AmbiguousName12-Nov-10 8:44
AmbiguousName12-Nov-10 8:44 
AnswerRe: Using Liberary Module in VS 2008?? Pin
Chris Losinger15-Nov-10 1:03
professionalChris Losinger15-Nov-10 1:03 
QuestionWhich is better? Returning reference or value? Pin
Code-o-mat12-Nov-10 8:18
Code-o-mat12-Nov-10 8:18 
AnswerRe: Which is better? Returning reference or value? Pin
Sauro Viti12-Nov-10 8:41
professionalSauro Viti12-Nov-10 8:41 
GeneralRe: Which is better? Returning reference or value? Pin
Code-o-mat12-Nov-10 10:07
Code-o-mat12-Nov-10 10:07 
AnswerRe: Which is better? Returning reference or value? Pin
Dr.Walt Fair, PE12-Nov-10 10:03
professionalDr.Walt Fair, PE12-Nov-10 10:03 
GeneralRe: Which is better? Returning reference or value? Pin
Code-o-mat12-Nov-10 10:10
Code-o-mat12-Nov-10 10:10 
QuestionHow to get serial number of motherboard using C++ on WINDOWS? Pin
Aseem Sharma12-Nov-10 6:17
Aseem Sharma12-Nov-10 6:17 
AnswerRe: How to get serial number of motherboard using C++ on WINDOWS? Pin
Code-o-mat12-Nov-10 6:48
Code-o-mat12-Nov-10 6:48 
GeneralRe: How to get serial number of motherboard using C++ on WINDOWS? Pin
Aseem Sharma12-Nov-10 18:42
Aseem Sharma12-Nov-10 18:42 
AnswerRe: How to get serial number of motherboard using C++ on WINDOWS? Pin
David Crow12-Nov-10 7:35
David Crow12-Nov-10 7:35 
AnswerRe: How to get serial number of motherboard using C++ on WINDOWS? Pin
Luc Pattyn12-Nov-10 8:00
sitebuilderLuc Pattyn12-Nov-10 8:00 
QuestionRe: How to get serial number of motherboard using C++ on WINDOWS? Pin
Code-o-mat12-Nov-10 10:10
Code-o-mat12-Nov-10 10:10 
AnswerRe: How to get serial number of motherboard using C++ on WINDOWS? Pin
Luc Pattyn12-Nov-10 10:32
sitebuilderLuc Pattyn12-Nov-10 10:32 
GeneralRe: How to get serial number of motherboard using C++ on WINDOWS? Pin
Code-o-mat12-Nov-10 10:44
Code-o-mat12-Nov-10 10:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.