Vc6.0, where are you going ~~

Source: Internet
Author: User

Recently, many blogs have found that many people use vc6.0 and intel c ++ compiler 9.1 For OpenMp multi-threaded programming. Using this combination, I will perform the following experiments:

 

# Include "stdafx. h"
# Include "omp. h"
# Include <stdio. h>

Int main (int argc, char * argv [])
{
# Pragma omp parallel
For (int I = 0; I <10; I ++)
Printf ("I = % d ThreadId = % d/n", I, omp_get_thread_num ());
Return 0;
}

This is the first running result:

I = 0 ThreadId = 0
I = 5 ThreadId = 1
I = 0 ThreadId = 0
I = 6 ThreadId = 1
I = 1 ThreadId = 0
I = 7 ThreadId = 1
I = 2 ThreadId = 0
I = 8 ThreadId = 1
I = 3 ThreadId = 0
I = 9 ThreadId = 1
I = 4 ThreadId = 0

 

This is the second running result:

I = 0 ThreadId = 0
I = 0 ThreadId = 0
I = 5 ThreadId = 1
I = 1 ThreadId = 0
I = 6 ThreadId = 1
I = 2 ThreadId = 0
I = 7 ThreadId = 1
I = 3 ThreadId = 0
I = 8 ThreadId = 1
I = 4 ThreadId = 0
I = 9 ThreadId = 1

The two running results are incorrect,

I run the above program in vs2005

I = 5 ThreadId = 1
I = 0 ThreadId = 0
I = 6 ThreadId = 1
I = 1 ThreadId = 0
I = 7 ThreadId = 1
I = 2 ThreadId = 0
I = 8 ThreadId = 1
I = 3 ThreadId = 0
I = 9 ThreadId = 1
I = 4 ThreadId = 0

This is the correct running result. My machine is dual-core and two threads are used by default. why is there such an effect? If there is no problem with the program, it can only be the vc6.0 compiler or intel c ++ 9.1. After testing, I used vc6.0 to implement winAPI multi-threaded programs, the result is still incorrect. It indicates that the vc6.0 compiler has a problem with the multithreading mechanism. As for whether there is a problem with intel c ++ 9.1, I cannot try it out, some people say that it is okay to use an intel compiler of a later version. if it is as I said, it seems that OpenMp will only run in the vs environment in the future. vc6.0 will say goodbye to multithreading, but it takes so long for vc6.0. To be honest, it is really fast, and the interface is clear, the font and color are very good, vs2005 is slow, and the font is a little small, I really hope Microsoft can do a vc7.0 or 8.0 copy of The vc6.0 interface, updating the original compiler into vs2008 or intel c ++ 11.1 is a bit of a fantasy, but you really cannot bear vc6.0. I wonder if you have ever encountered such a phenomenon, or if my program is wrong, you can discuss it together .......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.