{"id":11571,"date":"2015-06-25T15:21:01","date_gmt":"2015-06-25T19:21:01","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=11571"},"modified":"2015-06-25T15:21:01","modified_gmt":"2015-06-25T19:21:01","slug":"swift-2-simd","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/06\/25\/swift-2-simd\/","title":{"rendered":"Swift 2: SIMD"},"content":{"rendered":"<p><a href=\"http:\/\/www.russbishop.net\/swift-2-simd\">Russ Bishop<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.russbishop.net\/swift-2-simd\">\n<p>In Swift 1.2 you could <code>@import simd<\/code> but it wouldn&rsquo;t do you much good. The compiler has to map the types to intrinsics, support certain alignment requirements and padding, etc. Swift 1.2 didn&rsquo;t know how to do any of that so vector extensions were basically unusable.<\/p>\n<p>In Swift 2 that has changed. All the types are present and have full operator implementations. They all have handy initializers (vector initialized to a scalar value, a matrix with diagonals set, and so on). They can convert between the C\/Objective-C types quite easily. They have full operator support, including between types so you can multiply a vector and a matrix with wild abandon[&#8230;]<\/p>\n<p>[&#8230;]<\/p>\n<p>Looking at the SIMD results we can see there may still be a branch somewhere but it isn&rsquo;t nearly as expensive. We also see that SIMD is faster all cases and in the worst-case scenario it&rsquo;s three times as fast.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Russ Bishop: In Swift 1.2 you could @import simd but it wouldn&rsquo;t do you much good. The compiler has to map the types to intrinsics, support certain alignment requirements and padding, etc. Swift 1.2 didn&rsquo;t know how to do any of that so vector extensions were basically unusable. In Swift 2 that has changed. All [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[46,138,71,901],"class_list":["post-11571","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-optimization","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=11571"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11571\/revisions"}],"predecessor-version":[{"id":11572,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11571\/revisions\/11572"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=11571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=11571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=11571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}