Upload
vanthien
View
240
Download
12
Embed Size (px)
Citation preview
Visual Studio 2013 제대로 파헤쳐 보기!
11월의 주제
C++ 개발자와 함께하는Visual Studio 2013-한국 마이크로소프트 기술 에반젤리스트 김명신 부장
- Facebook/Twitter : @himskim
2014++ 흐름This ISO C++ 개선사이클:
더욱더빠르고예측가능하도록개선
융통성있게 concurrent /decoupled 등을라이브러리를제공하고언어확장도지원
C++ 은살아숨쉬는언어
Visual C++는 C++14 을목표로하고있습니다. 그래서 C++11과 C++ 14
를같이구현하고있습니다. 당연히모든표준을구현할것이지만
개발자에게가장가치있는기능부터우선적으로구현하고자합니다.
때문에 generic lambda와같은 C++14의주요기능을 C++11의다른기
능보다우선적으로구현하는경우도있습니다.
Herb Sutter - Microsoft Partner Program Manager
// Initialize elements of an aggregate (array, struct, union)// in any orderunion struct
intintint
struct // .m2==0int
string flip(string s){
reverse(begin(s), end(s));return s;
}
int _tmain(int argc, _TCHAR* argv[]){
vector<future<string>> v;
v.push_back(async([] { return flip(" emocleW"); }));v.push_back(async([] { return flip(" ot"); }));v.push_back(async([] { return flip("\ndlrow ++C wen"); }));
for (auto &e : v){
cout << e.get();}return 0;
}
// C++11class MyClass {
int _size;int *_data;
public:MyClass() : _size(0), _data(nullptr) {}MyClass(int size) : _size(size) {} // 이런 _data 초기화를 누락!!
};// C++14class MyClass {
int _size = 0;int *_data = nullptr;
public:MyClass() {} // _size, _data 이미 초기화MyClass(int size) : _size(size) {} // _data는 이미 초기화
};
http_client client(L"http://www.myhttpserver.com");
http_request request(methods::GET);
client.request(request).then([](http_response response)
{
// Perform actions here to inspect the HTTP response...
if(response.status_code() == status_codes::OK)
{
}
});
void RequestJSONValue(){
http_client client(L"http://www.myhttpserver.com");client.request(methods::GET).then([](http_response response){
if(response.status_code() == status_codes::OK){
return response.extract_json();}
// Handle error cases, for now return null json value...return task_from_result(json::value());
}).then([](json::value v){
// Perform actions here to process the JSON value...});
}
Modern C++ Code EditorScrollbarPeek DefinitionEvent HandlerToggle HeaderFormattingBrace CompletionNavigate-To
170
100
40
0.50
50
100
150
200
First Time Switch (sec) Subsequent Switches (sec)
Time to switch configuration
Visual Studio 2012 Visual Studio 2013
Performance Optimization RecapCompilation Unit Optimizations• /O2 and friends
Whole Program Optimizations• /GL and /LTCG
Profile-Guided Optimizations• /LTCG:PGI and /LTCG:PGO
루프내에서만의 Vectorization을넘어서VS 2012:• 루프내에서만 “vector” instruction 사용
VS 2013 추가• Statement level vectorization
• Permutation of perfect loop nests
• Range propagation optimizations
• Support for more operations: min/max, converts, shifts, byteswap, averaging
• Reductions into array elements
• __restrict support for vector alias checking
• Improvements to data dependence analysis
• C++ pointer vectorization
• Gather / scatter optimizations
for (i = 0; i < 1000; i++) {A[i] = B[i] + C[i];
}
+
r1 r2
r3
add r3, r1, r2
SCALAR(1 operation)
v1 v2
v3+
vectorlength
vadd v3, v1, v2
VECTOR(N operations)
Vector Calling Conventionstruct Particle {
__m256 x;__m256 y;__m256 z;__m256 w;
};Particle __vectorcall foo(Particle a, __m256 scale){Particle t;
t.x = _mm256_mul_ps(a.x, scale);t.y = _mm256_mul_ps(a.y, scale);t.z = _mm256_mul_ps(a.z, scale);t.w = _mm256_mul_ps(a.w, scale);
return t;}
Reduces instruction count
Minimizes stack allocation
Use /Gv for whole module