parallel for and threadpools

This is a discussion on parallel for and threadpools within the C++ Programming forums, part of the General Programming Boards category; Hi, if I use an openMP parallel for construct like Code: #pragma omp parallel for num_threads(4) for(int i=0; i<10; ++i){} ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    519

    parallel for and threadpools

    Hi,

    if I use an openMP parallel for construct like
    Code:
    #pragma omp parallel for num_threads(4)
    for(int i=0; i<10; ++i){}
    when are the 4 threads created, after the pragma and therefore eventually very often during process live time or is the run time clever enough to create a ready to use thread pool prior process start up?

    Thanks in advance!

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    That depends on the OMP implementation. I would say that all implementations keep a thread pool handy, since launching and stopping threads is expensive.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21