Skip to content

Commit d27c6f3

Browse files
committed
MPSMatrixMultiplication: Version 1.0, 2016-09-13
First release The Metal Performance Shaders Framework provides functions for performing generalized matrix multiplication. This sample illustrates how to create MPSMatrix objects and compute their product using MPSMatrixMultiplication compute kernels.
1 parent 59522d1 commit d27c6f3

File tree

9 files changed

+658
-0
lines changed

9 files changed

+658
-0
lines changed

MPSMatrixMultiplication/LICENSE.txt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Sample code project: MPSMatrixMultiplication: Creating and Multiplying Matrices in Metal
2+
Version: 1.0
3+
4+
IMPORTANT: This Apple software is supplied to you by Apple
5+
Inc. ("Apple") in consideration of your agreement to the following
6+
terms, and your use, installation, modification or redistribution of
7+
this Apple software constitutes acceptance of these terms. If you do
8+
not agree with these terms, please do not use, install, modify or
9+
redistribute this Apple software.
10+
11+
In consideration of your agreement to abide by the following terms, and
12+
subject to these terms, Apple grants you a personal, non-exclusive
13+
license, under Apple's copyrights in this original Apple software (the
14+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
15+
Software, with or without modifications, in source and/or binary forms;
16+
provided that if you redistribute the Apple Software in its entirety and
17+
without modifications, you must retain this notice and the following
18+
text and disclaimers in all such redistributions of the Apple Software.
19+
Neither the name, trademarks, service marks or logos of Apple Inc. may
20+
be used to endorse or promote products derived from the Apple Software
21+
without specific prior written permission from Apple. Except as
22+
expressly stated in this notice, no other rights or licenses, express or
23+
implied, are granted by Apple herein, including but not limited to any
24+
patent rights that may be infringed by your derivative works or by other
25+
works in which the Apple Software may be incorporated.
26+
27+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
28+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
29+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
30+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
31+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
32+
33+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
34+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
37+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
39+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
40+
POSSIBILITY OF SUCH DAMAGE.
41+
42+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
94175FA11D481ADF00ED77E6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94175FA01D481ADF00ED77E6 /* AppDelegate.swift */; };
11+
94175FA31D481ADF00ED77E6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94175FA21D481ADF00ED77E6 /* ViewController.swift */; };
12+
94175FA61D481ADF00ED77E6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 94175FA41D481ADF00ED77E6 /* Main.storyboard */; };
13+
94175FA81D481ADF00ED77E6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 94175FA71D481ADF00ED77E6 /* Assets.xcassets */; };
14+
94175FAB1D481ADF00ED77E6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 94175FA91D481ADF00ED77E6 /* LaunchScreen.storyboard */; };
15+
/* End PBXBuildFile section */
16+
17+
/* Begin PBXFileReference section */
18+
94175F9D1D481ADF00ED77E6 /* MPSMatrixMultiplication.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MPSMatrixMultiplication.app; sourceTree = BUILT_PRODUCTS_DIR; };
19+
94175FA01D481ADF00ED77E6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
20+
94175FA21D481ADF00ED77E6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
21+
94175FA51D481ADF00ED77E6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
22+
94175FA71D481ADF00ED77E6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
23+
94175FAA1D481ADF00ED77E6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
24+
94175FAC1D481ADF00ED77E6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
25+
B5CBACE41D48AC4600FF2CE7 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
26+
/* End PBXFileReference section */
27+
28+
/* Begin PBXFrameworksBuildPhase section */
29+
94175F9A1D481ADF00ED77E6 /* Frameworks */ = {
30+
isa = PBXFrameworksBuildPhase;
31+
buildActionMask = 2147483647;
32+
files = (
33+
);
34+
runOnlyForDeploymentPostprocessing = 0;
35+
};
36+
/* End PBXFrameworksBuildPhase section */
37+
38+
/* Begin PBXGroup section */
39+
94175F941D481ADF00ED77E6 = {
40+
isa = PBXGroup;
41+
children = (
42+
B5CBACE41D48AC4600FF2CE7 /* README.md */,
43+
94175F9F1D481ADF00ED77E6 /* MPSMatrixMultiplication */,
44+
94175F9E1D481ADF00ED77E6 /* Products */,
45+
);
46+
sourceTree = "<group>";
47+
};
48+
94175F9E1D481ADF00ED77E6 /* Products */ = {
49+
isa = PBXGroup;
50+
children = (
51+
94175F9D1D481ADF00ED77E6 /* MPSMatrixMultiplication.app */,
52+
);
53+
name = Products;
54+
sourceTree = "<group>";
55+
};
56+
94175F9F1D481ADF00ED77E6 /* MPSMatrixMultiplication */ = {
57+
isa = PBXGroup;
58+
children = (
59+
94175FA01D481ADF00ED77E6 /* AppDelegate.swift */,
60+
94175FA21D481ADF00ED77E6 /* ViewController.swift */,
61+
94175FA41D481ADF00ED77E6 /* Main.storyboard */,
62+
94175FA71D481ADF00ED77E6 /* Assets.xcassets */,
63+
94175FA91D481ADF00ED77E6 /* LaunchScreen.storyboard */,
64+
94175FAC1D481ADF00ED77E6 /* Info.plist */,
65+
);
66+
path = MPSMatrixMultiplication;
67+
sourceTree = "<group>";
68+
};
69+
/* End PBXGroup section */
70+
71+
/* Begin PBXNativeTarget section */
72+
94175F9C1D481ADF00ED77E6 /* MPSMatrixMultiplication */ = {
73+
isa = PBXNativeTarget;
74+
buildConfigurationList = 94175FAF1D481ADF00ED77E6 /* Build configuration list for PBXNativeTarget "MPSMatrixMultiplication" */;
75+
buildPhases = (
76+
94175F991D481ADF00ED77E6 /* Sources */,
77+
94175F9A1D481ADF00ED77E6 /* Frameworks */,
78+
94175F9B1D481ADF00ED77E6 /* Resources */,
79+
);
80+
buildRules = (
81+
);
82+
dependencies = (
83+
);
84+
name = MPSMatrixMultiplication;
85+
productName = MPSMatrixMultiplication;
86+
productReference = 94175F9D1D481ADF00ED77E6 /* MPSMatrixMultiplication.app */;
87+
productType = "com.apple.product-type.application";
88+
};
89+
/* End PBXNativeTarget section */
90+
91+
/* Begin PBXProject section */
92+
94175F951D481ADF00ED77E6 /* Project object */ = {
93+
isa = PBXProject;
94+
attributes = {
95+
LastSwiftUpdateCheck = 0800;
96+
LastUpgradeCheck = 0800;
97+
ORGANIZATIONNAME = "Apple Inc.";
98+
TargetAttributes = {
99+
94175F9C1D481ADF00ED77E6 = {
100+
CreatedOnToolsVersion = 8.0;
101+
ProvisioningStyle = Automatic;
102+
};
103+
};
104+
};
105+
buildConfigurationList = 94175F981D481ADF00ED77E6 /* Build configuration list for PBXProject "MPSMatrixMultiplication" */;
106+
compatibilityVersion = "Xcode 3.2";
107+
developmentRegion = English;
108+
hasScannedForEncodings = 0;
109+
knownRegions = (
110+
en,
111+
Base,
112+
);
113+
mainGroup = 94175F941D481ADF00ED77E6;
114+
productRefGroup = 94175F9E1D481ADF00ED77E6 /* Products */;
115+
projectDirPath = "";
116+
projectRoot = "";
117+
targets = (
118+
94175F9C1D481ADF00ED77E6 /* MPSMatrixMultiplication */,
119+
);
120+
};
121+
/* End PBXProject section */
122+
123+
/* Begin PBXResourcesBuildPhase section */
124+
94175F9B1D481ADF00ED77E6 /* Resources */ = {
125+
isa = PBXResourcesBuildPhase;
126+
buildActionMask = 2147483647;
127+
files = (
128+
94175FAB1D481ADF00ED77E6 /* LaunchScreen.storyboard in Resources */,
129+
94175FA81D481ADF00ED77E6 /* Assets.xcassets in Resources */,
130+
94175FA61D481ADF00ED77E6 /* Main.storyboard in Resources */,
131+
);
132+
runOnlyForDeploymentPostprocessing = 0;
133+
};
134+
/* End PBXResourcesBuildPhase section */
135+
136+
/* Begin PBXSourcesBuildPhase section */
137+
94175F991D481ADF00ED77E6 /* Sources */ = {
138+
isa = PBXSourcesBuildPhase;
139+
buildActionMask = 2147483647;
140+
files = (
141+
94175FA31D481ADF00ED77E6 /* ViewController.swift in Sources */,
142+
94175FA11D481ADF00ED77E6 /* AppDelegate.swift in Sources */,
143+
);
144+
runOnlyForDeploymentPostprocessing = 0;
145+
};
146+
/* End PBXSourcesBuildPhase section */
147+
148+
/* Begin PBXVariantGroup section */
149+
94175FA41D481ADF00ED77E6 /* Main.storyboard */ = {
150+
isa = PBXVariantGroup;
151+
children = (
152+
94175FA51D481ADF00ED77E6 /* Base */,
153+
);
154+
name = Main.storyboard;
155+
sourceTree = "<group>";
156+
};
157+
94175FA91D481ADF00ED77E6 /* LaunchScreen.storyboard */ = {
158+
isa = PBXVariantGroup;
159+
children = (
160+
94175FAA1D481ADF00ED77E6 /* Base */,
161+
);
162+
name = LaunchScreen.storyboard;
163+
sourceTree = "<group>";
164+
};
165+
/* End PBXVariantGroup section */
166+
167+
/* Begin XCBuildConfiguration section */
168+
94175FAD1D481ADF00ED77E6 /* Debug */ = {
169+
isa = XCBuildConfiguration;
170+
buildSettings = {
171+
ALWAYS_SEARCH_USER_PATHS = NO;
172+
CLANG_ANALYZER_NONNULL = YES;
173+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
174+
CLANG_CXX_LIBRARY = "libc++";
175+
CLANG_ENABLE_MODULES = YES;
176+
CLANG_ENABLE_OBJC_ARC = YES;
177+
CLANG_WARN_BOOL_CONVERSION = YES;
178+
CLANG_WARN_CONSTANT_CONVERSION = YES;
179+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
180+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
181+
CLANG_WARN_EMPTY_BODY = YES;
182+
CLANG_WARN_ENUM_CONVERSION = YES;
183+
CLANG_WARN_INT_CONVERSION = YES;
184+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
185+
CLANG_WARN_UNREACHABLE_CODE = YES;
186+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
187+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
188+
COPY_PHASE_STRIP = NO;
189+
DEBUG_INFORMATION_FORMAT = dwarf;
190+
ENABLE_STRICT_OBJC_MSGSEND = YES;
191+
ENABLE_TESTABILITY = YES;
192+
GCC_C_LANGUAGE_STANDARD = gnu99;
193+
GCC_DYNAMIC_NO_PIC = NO;
194+
GCC_NO_COMMON_BLOCKS = YES;
195+
GCC_OPTIMIZATION_LEVEL = 0;
196+
GCC_PREPROCESSOR_DEFINITIONS = (
197+
"DEBUG=1",
198+
"$(inherited)",
199+
);
200+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
201+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
202+
GCC_WARN_UNDECLARED_SELECTOR = YES;
203+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
204+
GCC_WARN_UNUSED_FUNCTION = YES;
205+
GCC_WARN_UNUSED_VARIABLE = YES;
206+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
207+
MTL_ENABLE_DEBUG_INFO = YES;
208+
ONLY_ACTIVE_ARCH = YES;
209+
SDKROOT = iphoneos;
210+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
211+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
212+
};
213+
name = Debug;
214+
};
215+
94175FAE1D481ADF00ED77E6 /* Release */ = {
216+
isa = XCBuildConfiguration;
217+
buildSettings = {
218+
ALWAYS_SEARCH_USER_PATHS = NO;
219+
CLANG_ANALYZER_NONNULL = YES;
220+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
221+
CLANG_CXX_LIBRARY = "libc++";
222+
CLANG_ENABLE_MODULES = YES;
223+
CLANG_ENABLE_OBJC_ARC = YES;
224+
CLANG_WARN_BOOL_CONVERSION = YES;
225+
CLANG_WARN_CONSTANT_CONVERSION = YES;
226+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
227+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
228+
CLANG_WARN_EMPTY_BODY = YES;
229+
CLANG_WARN_ENUM_CONVERSION = YES;
230+
CLANG_WARN_INT_CONVERSION = YES;
231+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
232+
CLANG_WARN_UNREACHABLE_CODE = YES;
233+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
234+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
235+
COPY_PHASE_STRIP = NO;
236+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
237+
ENABLE_NS_ASSERTIONS = NO;
238+
ENABLE_STRICT_OBJC_MSGSEND = YES;
239+
GCC_C_LANGUAGE_STANDARD = gnu99;
240+
GCC_NO_COMMON_BLOCKS = YES;
241+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
242+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
243+
GCC_WARN_UNDECLARED_SELECTOR = YES;
244+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
245+
GCC_WARN_UNUSED_FUNCTION = YES;
246+
GCC_WARN_UNUSED_VARIABLE = YES;
247+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
248+
MTL_ENABLE_DEBUG_INFO = NO;
249+
SDKROOT = iphoneos;
250+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
251+
VALIDATE_PRODUCT = YES;
252+
};
253+
name = Release;
254+
};
255+
94175FB01D481ADF00ED77E6 /* Debug */ = {
256+
isa = XCBuildConfiguration;
257+
buildSettings = {
258+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
259+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
260+
DEVELOPMENT_TEAM = "";
261+
INFOPLIST_FILE = MPSMatrixMultiplication/Info.plist;
262+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
263+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.MPSMatrixMultiplication";
264+
PRODUCT_NAME = "$(TARGET_NAME)";
265+
SWIFT_VERSION = 3.0;
266+
};
267+
name = Debug;
268+
};
269+
94175FB11D481ADF00ED77E6 /* Release */ = {
270+
isa = XCBuildConfiguration;
271+
buildSettings = {
272+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
273+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
274+
DEVELOPMENT_TEAM = "";
275+
INFOPLIST_FILE = MPSMatrixMultiplication/Info.plist;
276+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
277+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.MPSMatrixMultiplication";
278+
PRODUCT_NAME = "$(TARGET_NAME)";
279+
SWIFT_VERSION = 3.0;
280+
};
281+
name = Release;
282+
};
283+
/* End XCBuildConfiguration section */
284+
285+
/* Begin XCConfigurationList section */
286+
94175F981D481ADF00ED77E6 /* Build configuration list for PBXProject "MPSMatrixMultiplication" */ = {
287+
isa = XCConfigurationList;
288+
buildConfigurations = (
289+
94175FAD1D481ADF00ED77E6 /* Debug */,
290+
94175FAE1D481ADF00ED77E6 /* Release */,
291+
);
292+
defaultConfigurationIsVisible = 0;
293+
defaultConfigurationName = Release;
294+
};
295+
94175FAF1D481ADF00ED77E6 /* Build configuration list for PBXNativeTarget "MPSMatrixMultiplication" */ = {
296+
isa = XCConfigurationList;
297+
buildConfigurations = (
298+
94175FB01D481ADF00ED77E6 /* Debug */,
299+
94175FB11D481ADF00ED77E6 /* Release */,
300+
);
301+
defaultConfigurationIsVisible = 0;
302+
defaultConfigurationName = Release;
303+
};
304+
/* End XCConfigurationList section */
305+
};
306+
rootObject = 94175F951D481ADF00ED77E6 /* Project object */;
307+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
Application delegate for the App
7+
*/
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
var window: UIWindow?
15+
}

0 commit comments

Comments
 (0)