Skip to content

Changes to make the examples run on Fresh Install #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"name": "Mac M1 LLVM OpenMP",
"includePath": [
"${workspaceFolder}/**",
"/opt/homebrew/opt/libomp/lib"
"/usr/local/opt/libomp/lib"
],
"defines": [],
"macFrameworkPath": [],
"compilerPath": "/opt/homebrew/opt/llvm/bin/clang++",
"compilerPath": "/usr/local/opt/llvm/bin/clang++",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "clang-x64",
"compilerArgs": []
}],
"version": 4
}
}
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"doublebuffer.metal-shader"
]
}
49 changes: 38 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"configurations": [{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${workspaceFolder}/paper",

},
"configurations": [
{
"name": "MetalAdder benchmark debugging",
"type": "cppdbg",
Expand All @@ -33,6 +24,42 @@
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "Build 02"
}, {
"name": "MetalOperations Chaining debugging",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/02-GeneralArrayOperations/chaining_benchmark.x",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/02-GeneralArrayOperations",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "Build 02 chaining"
}, {
"name": "MetalOperations benchmark paper debugging",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/paper/paper_benchmark_02.x",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/02-GeneralArrayOperations",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "Build benchmark paper 02"
}, {
"name": "2DKernels debugging",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/03-2DKernels/benchmark.x",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/03-2DKernels",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "Build 03"
}
]
}
}
66 changes: 26 additions & 40 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"tasks": [{
"type": "cppbuild",
"label": "Build 01",
"command": "/opt/homebrew/opt/llvm/bin/clang++",
"command": "/usr/local/opt/llvm/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-O2",
// OpenMP includes & configuration
"-L/opt/homebrew/opt/libomp/lib", "-fopenmp",
// Metal includes & configuration
"-L/usr/local/opt/libomp/lib", "-fopenmp",
"-I${workspaceFolder}/metal-cpp", "-fno-objc-arc",
"-framework", "Metal", "-framework", "Foundation", "-framework", "MetalKit",
"-g",
Expand All @@ -28,10 +26,9 @@
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/homebrew/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 01"],
"detail": "compiler: /usr/local/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 01"]
},
// See: https://developer.apple.com/documentation/metal/shader_libraries/building_a_library_with_metal_s_command-line_tools?language=objc
{
"type": "shell",
"label": "Build .air 01",
Expand All @@ -54,14 +51,12 @@
}, {
"type": "cppbuild",
"label": "Build 02 chaining",
"command": "/opt/homebrew/opt/llvm/bin/clang++",
"command": "/usr/local/opt/llvm/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-O2",
// OpenMP includes & configuration
"-L/opt/homebrew/opt/libomp/lib", "-fopenmp",
// Metal includes & configuration
"-L/usr/local/opt/libomp/lib", "-fopenmp",
"-I${workspaceFolder}/metal-cpp", "-fno-objc-arc",
"-framework", "Metal", "-framework", "Foundation", "-framework", "MetalKit",
"-g",
Expand All @@ -81,19 +76,17 @@
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/homebrew/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 02"],
"detail": "compiler: /usr/local/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 02"]
}, {
"type": "cppbuild",
"label": "Build 02",
"command": "/opt/homebrew/opt/llvm/bin/clang++",
"command": "/usr/local/opt/llvm/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-O2",
// OpenMP includes & configuration
"-L/opt/homebrew/opt/libomp/lib", "-fopenmp",
// Metal includes & configuration
"-L/usr/local/opt/libomp/lib", "-fopenmp",
"-I${workspaceFolder}/metal-cpp", "-fno-objc-arc",
"-framework", "Metal", "-framework", "Foundation", "-framework", "MetalKit",
"-g",
Expand All @@ -113,19 +106,17 @@
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/homebrew/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 02"],
"detail": "compiler: /usr/local/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 02"]
}, {
"type": "cppbuild",
"label": "Build benchmark paper 02",
"command": "/opt/homebrew/opt/llvm/bin/clang++",
"command": "/usr/local/opt/llvm/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-O2",
// OpenMP includes & configuration
"-L/opt/homebrew/opt/libomp/lib", "-fopenmp",
// Metal includes & configuration
"-L/usr/local/opt/libomp/lib", "-fopenmp",
"-I${workspaceFolder}/metal-cpp", "-fno-objc-arc",
"-framework", "Metal", "-framework", "Foundation", "-framework", "MetalKit",
"-g",
Expand All @@ -145,8 +136,8 @@
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/homebrew/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 02"],
"detail": "compiler: /usr/local/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 02"]
}, {
"type": "shell",
"label": "Build .air 02",
Expand All @@ -169,14 +160,12 @@
}, {
"type": "cppbuild",
"label": "Build 03",
"command": "/opt/homebrew/opt/llvm/bin/clang++",
"command": "/usr/local/opt/llvm/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-O2",
// OpenMP includes & configuration
"-L/opt/homebrew/opt/libomp/lib", "-fopenmp",
// Metal includes & configuration
"-L/usr/local/opt/libomp/lib", "-fopenmp",
"-I${workspaceFolder}/metal-cpp", "-fno-objc-arc",
"-framework", "Metal", "-framework", "Foundation", "-framework", "MetalKit",
"-g",
Expand All @@ -196,20 +185,17 @@
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/homebrew/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 03"],
"detail": "compiler: /usr/local/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 03"]
}, {
"type": "cppbuild",
"label": "Build benchmark paper 03",
"command": "/opt/homebrew/opt/llvm/bin/clang++",
"command": "/usr/local/opt/llvm/bin/clang++",
"args": [
"-std=c++17",
// "-stdlib=libc++",
"-std=c++11",
"-O2",
// OpenMP includes & configuration
"-L/opt/homebrew/opt/libomp/lib", "-fopenmp",
// Metal includes & configuration
"-L/usr/local/opt/libomp/lib", "-fopenmp",
"-I${workspaceFolder}/metal-cpp", "-fno-objc-arc",
"-framework", "Metal", "-framework", "Foundation", "-framework", "MetalKit",
"-g",
Expand All @@ -229,8 +215,8 @@
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/homebrew/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 03"],
"detail": "compiler: /usr/local/opt/llvm/bin/clang++",
"dependsOn": ["Build .metallib 03"]
}, {
"type": "shell",
"label": "Build .air 03",
Expand All @@ -250,6 +236,6 @@
],
"dependsOn": ["Build .air 03"]

},
}
]
}
}
20 changes: 9 additions & 11 deletions 02-GeneralArrayOperations/ops.metal
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ kernel void inspector(
uint quadgroup_index_in_threadgroup [[quadgroup_index_in_threadgroup]],
uint quadgroups_per_threadgroup [[quadgroups_per_threadgroup]],
uint simdgroup_index_in_threadgroup [[simdgroup_index_in_threadgroup]],
uint simdgroups_per_threadgroup [[simdgroups_per_threadgroup]],
uint thread_execution_width [[thread_execution_width]],
uint simdgroups_per_threadgroup [[simdgroups_per_threadgroup]],
uint thread_index_in_quadgroup [[thread_index_in_quadgroup]],
uint thread_index_in_simdgroup [[thread_index_in_simdgroup]],
uint thread_index_in_threadgroup [[thread_index_in_threadgroup]],
Expand All @@ -88,15 +87,14 @@ kernel void inspector(
store[8] = quadgroups_per_threadgroup;
store[9] = simdgroup_index_in_threadgroup;
store[10] = simdgroups_per_threadgroup;
store[11] = thread_execution_width;
store[12] = thread_index_in_quadgroup;
store[13] = thread_index_in_simdgroup;
store[14] = thread_index_in_threadgroup;
store[15] = thread_position_in_threadgroup;
store[16] = threadgroup_position_in_grid;
store[17] = threadgroups_per_grid;
store[18] = threads_per_simdgroup;
store[19] = threads_per_threadgroup;
store[11] = thread_index_in_quadgroup;
store[12] = thread_index_in_simdgroup;
store[13] = thread_index_in_threadgroup;
store[14] = thread_position_in_threadgroup;
store[15] = threadgroup_position_in_grid;
store[16] = threadgroups_per_grid;
store[17] = threads_per_simdgroup;
store[18] = threads_per_threadgroup;
}

}
18 changes: 8 additions & 10 deletions 03-2DKernels/ops.metal
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ kernel void inspector(
uint quadgroups_per_threadgroup [[quadgroups_per_threadgroup]],
uint simdgroup_index_in_threadgroup [[simdgroup_index_in_threadgroup]],
uint simdgroups_per_threadgroup [[simdgroups_per_threadgroup]],
uint thread_execution_width [[thread_execution_width]],
uint thread_index_in_quadgroup [[thread_index_in_quadgroup]],
uint thread_index_in_simdgroup [[thread_index_in_simdgroup]],
uint thread_index_in_threadgroup [[thread_index_in_threadgroup]],
Expand All @@ -157,15 +156,14 @@ kernel void inspector(
store[8] = quadgroups_per_threadgroup;
store[9] = simdgroup_index_in_threadgroup;
store[10] = simdgroups_per_threadgroup;
store[11] = thread_execution_width;
store[12] = thread_index_in_quadgroup;
store[13] = thread_index_in_simdgroup;
store[14] = thread_index_in_threadgroup;
store[15] = thread_position_in_threadgroup;
store[16] = threadgroup_position_in_grid;
store[17] = threadgroups_per_grid;
store[18] = threads_per_simdgroup;
store[19] = threads_per_threadgroup;
store[11] = thread_index_in_quadgroup;
store[12] = thread_index_in_simdgroup;
store[13] = thread_index_in_threadgroup;
store[14] = thread_position_in_threadgroup;
store[15] = threadgroup_position_in_grid;
store[16] = threadgroups_per_grid;
store[17] = threads_per_simdgroup;
store[18] = threads_per_threadgroup;
}

}