Thread: parallel for and threadpools

  1. #1
    Registered User
    Join Date
    Nov 2006

    parallel for and threadpools


    if I use an openMP parallel for construct like
    #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
    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!

    "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