- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I am running this program, it will return wrong results, which are shown in the comments.
#include <iostream>
#include <vector>
int main()
{
size_t n = 1000000000;
std::vector<double> V(n);
std::cout << V.size() << std::endl;
// output: 1000000000
std::cout << V.size() << std::endl;
// output: 18446744073635809792
std::cout << V.capacity() << std::endl;
// output: 1000000000
return 0;
}
icc for Mac
Version 19.0.1.144 Build 20181018
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
these are results from my executions:
vahoang@orcsle147:/tmp$ icpc t.cpp
vahoang@orcsle147:/tmp$ ./a.out
1000000000
1000000000
1000000000
$ cat t.cpp
#include <iostream>
#include <vector>
int main()
{
size_t n = 1000000000;
std::vector<double> V(n);
std::cout << V.size() << std::endl;
// output: 1000000000
std::cout << V.size() << std::endl;
// output: 18446744073635809792
std::cout << V.capacity() << std::endl;
// output: 1000000000
return 0;
}
vahoang@orcsle147:/tmp$ icc -V
Version 19.0.1.144 Build 20181018
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But my results are still wrong:
iMac:Documents x$ icpc test.cpp
iMac:Documents x$ ./a.out
1000000000
18446744073635809792
1000000000
iMac:Documents x$ icc -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.1.144 Build 20181018
Copyright (C) 1985-2018 Intel Corporation. All rights reserved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The program will show the right results only with "icpc -O1 test.cpp" instruction. If I use '-O2' or the higher optimization option, the results will be wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you tell me what are the specifications of your computer and your default optimization option?
Viet Hoang (Intel) wrote:these are results from my executions:
vahoang@orcsle147:/tmp$ icpc t.cpp
vahoang@orcsle147:/tmp$ ./a.out
1000000000
1000000000
1000000000$ cat t.cpp
#include <iostream>
#include <vector>int main()
{
size_t n = 1000000000;
std::vector<double> V(n);
std::cout << V.size() << std::endl;
// output: 1000000000
std::cout << V.size() << std::endl;
// output: 18446744073635809792std::cout << V.capacity() << std::endl;
// output: 1000000000
return 0;
}vahoang@orcsle147:/tmp$ icc -V
Version 19.0.1.144 Build 20181018
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I accidentally compiled at -O1; I am now seeing at -O2. I'll report this bug to our Developer.
Thanks,
Viet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have submitted this bug: CMPLRIL0-30860
Thanks,
Viet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK
Viet Hoang (Intel) wrote:I have submitted this bug: CMPLRIL0-30860
Thanks,
Viet
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page