diff --git a/404.html b/404.html index ad8e6ad..1f22824 100644 --- a/404.html +++ b/404.html @@ -101,6 +101,43 @@ + + + + +
\u3053\u306e\u30b5\u30a4\u30c8\u306f\u79c1\u304c\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u3057\u3066\u3044\u308bOSS\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3068\u30d6\u30ed\u30b0\u3092\u63b2\u8f09\u3057\u3066\u3044\u307e\u3059\u3002
\u3054\u610f\u898b\u3001\u3054\u611f\u60f3\u306fGitHub\u306eIssue\u307e\u305f\u306fX(\u65e7Twitter)\u306b\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002
\u3053\u306e\u8a18\u4e8b\u306fperf\u3092\u4f7f\u3044\u305f\u3044\u304c\u3001\u4f55\u3089\u304b\u306e\u7406\u7531\u3067/proc/sys/kernel/perf_event_paranoid\u3092\u5909\u66f4\u3067\u304d\u306a\u3044\u65b9\u5411\u3051\u3067\u3059\u3002Ubuntu 22.04\u3067\u691c\u8a3c\u6e08\u307f\u3067\u3059\u3002
perf
/proc/sys/kernel/perf_event_paranoid
\u4ee5\u4e0b\u3092\u4eee\u5b9a\u3057\u307e\u3059\u3002
\u307e\u305a\u3001perf\u304c\u3042\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u3067\u3082\u69cb\u3044\u307e\u305b\u3093\u3002
# which perf\n/usr/bin/perf\n# cd /usr/bin\n
\u6b21\u306b\u3001perf_users\u3068\u3044\u3046\u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3057\u3001\u3053\u306e\u30b0\u30eb\u30fc\u30d7\u306bperf\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u3063\u3066\u3001perf\u3092\u5b9f\u884c\u3067\u304d\u308b\u30e6\u30fc\u30b6\u30fc\u3092\u5236\u9650\u3067\u304d\u307e\u3059\u3002
perf_users
# sudo groupadd perf_users\n# ls -alhF\n-rwxr-xr-x 2 root root 11M Oct 19 15:12 perf\n# chgrp perf_users perf\n# ls -alhF\n-rwxr-xr-x 2 root perf_users 11M Oct 19 15:12 perf\n# chmod o-rwx perf\n# ls -alhF\n-rwxr-x--- 2 root perf_users 11M Oct 19 15:12 perf\n
perf\u306b\u5fc5\u8981\u306a\u6a29\u9650\u3092\u4e0e\u3048\u3001perf_users\u306e\u30e1\u30f3\u30d0\u30fc\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002
# setcap \"cap_perfmon=ep\" perf\n# setcap -v \"cap_perfmon=ep\" perf\nperf: OK\n# getcap perf\nperf cap_perfmon=ep\n
Linux\u3067\u306f\u3001\u7279\u6a29\u3092\u30b1\u30fc\u30d1\u30d3\u30ea\u30c6\u30a3(capabilities)\u3068\u547c\u3070\u308c\u308b\u3001\u7570\u306a\u308b\u5358\u4f4d\u306b\u5206\u5272\u3057\u3066\u3044\u3066\u3001\u975e\u7279\u6a29\u30e6\u30fc\u30b6\u30fc\u306e\u30d7\u30ed\u30bb\u30b9\u3084\u30d5\u30a1\u30a4\u30eb\u306b\u5bfe\u3057\u3066\u30b9\u30ec\u30c3\u30c9\u6bce\u306b\u500b\u5225\u306b\u6709\u52b9\u307e\u305f\u306f\u7121\u52b9\u306b\u51fa\u6765\u307e\u3059\u3002
CAP_PERFMON\u3068\u3044\u3046\u30b1\u30fc\u30d1\u30d3\u30ea\u30c6\u30a3\u3092\u6301\u3063\u305f\u975e\u7279\u6a29\u30d7\u30ed\u30bb\u30b9\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u306b\u95a2\u3057\u3066\u7279\u6a29\u3092\u6301\u3064\u30d7\u30ed\u30bb\u30b9\u3068\u3057\u3066\u6271\u308f\u308c\u307e\u3059\u3002CAP_PERFMON\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u306e\u305f\u3081\u306b\u5fc5\u8981\u306a\u6700\u5c0f\u9650\u306e\u7279\u6a29\u3057\u304b\u6301\u305f\u305a\u3001\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u306e\u305f\u3081\u306e\u5b89\u5168\u306a\u65b9\u6cd5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002
CAP_PERFMON
\u3088\u308a\u8a73\u3057\u304f\u8abf\u3079\u305f\u3044\u6642\u306f\u5fc5\u8981\u306a\u7279\u6a29\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001/proc/kallsyms\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30ab\u30fc\u30cd\u30eb\u7a7a\u9593\u306e\u30e1\u30e2\u30ea\u30a2\u30c9\u30ec\u30b9\u3092\u8aad\u307f\u305f\u3044\u6642\u306fCAP_SYSLOG\u30b1\u30fc\u30d1\u30d3\u30ea\u30c6\u30a3\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002
/proc/kallsyms
CAP_SYSLOG
=ep\u306f\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u30b1\u30fc\u30d1\u30d3\u30ea\u30c6\u30a3\u306e\u8a2d\u5b9a\u3067\u3001\u30b9\u30ec\u30c3\u30c9\u8d77\u52d5\u6642\u306bCAP_PERFMON\u3092\u6709\u52b9\u306b\u3059\u308b\u3068\u3044\u3046\u8a2d\u5b9a\u3089\u3057\u3044\u3067\u3059\u3002
=ep
Linux v5.9\u4ee5\u524d\u3067\u306fCAP_SYS_PTRACE\u304c\u5fc5\u8981\u3067\u3057\u305f\u304c\u3001\u305d\u308c\u4ee5\u964d\u3067\u306f\u5fc5\u8981\u3042\u308a\u307e\u305b\u3093\u3002
CAP_SYS_PTRACE
\u53c2\u8003\u306e\u8a18\u4e8b\u304c\u6d88\u3048\u305f\u6642\u306b\u5099\u3048\u3066\u3001Apple\u306e\u30c6\u30f3\u30ad\u30fc\u4ed8\u304d\u65e5\u672c\u8a9eMagic Keyboard\u306e\u8a2d\u5b9a\u65b9\u6cd5\u3092\u3053\u3053\u306b\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002 \u30b7\u30b9\u30c6\u30e0\u8a00\u8a9e\u3092\u82f1\u8a9e\u3068\u3057\u307e\u3059\u3002
\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3064\u3002
sudo dpkg-reconfigure keyboard-configuration\n
Apple Aluminium (JIS)\u3092\u9078\u629e\u3059\u308b\u3002
Apple Aluminium (JIS)
Japanese\u3092\u9078\u629e\u3059\u308b\u3002
Japanese
Japanese - Japanese (Macintosh)\u3092\u9078\u629e\u3059\u308b\u3002
Japanese - Japanese (Macintosh)
No toggling\u3092\u9078\u629e\u3059\u308b\u3002
No toggling
No temporary switch\u3092\u9078\u629e\u3059\u308b\u3002
No temporary switch
The default for the keyboard layout\u3092\u9078\u629e\u3059\u308b\u3002
The default for the keyboard layout
No compose key\u3092\u9078\u629e\u3059\u308b\u3002
No compose key
No\u3092\u9078\u629e\u3059\u308b\u3002
No
\u3053\u306e\u307e\u307e\u3060\u3068\u300c\u304b\u306a\u300d\u3068\u300c\u82f1\u6570\u300d\u306e\u6319\u52d5\u304c\u9006\u306b\u306a\u3063\u3066\u3044\u308b\u305f\u3081\u3001Mozc\u306e\u8a2d\u5b9a\u3067\u7121\u7406\u3084\u308a\u9006\u306b\u3059\u308b\u3002
\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001\u30ad\u30fc\u30de\u30c3\u30d7\u3092\u5909\u66f4\u3059\u308b\u3002Deactivate IME\u306b\u3057\u3066\u3044\u308b\u306e\u306f\u534a\u89d2\u82f1\u6570\u3067\u306e\u5165\u529b\u6642\u306b\u5909\u63db\u3092\u7121\u52b9\u306b\u3059\u308b\u305f\u3081\u3002
Deactivate IME
\u8a2d\u5b9a\u304c\u9006\u306a\u306e\u306f\u304b\u306a\u3068\u82f1\u6570\u304c\u30ad\u30fc\u30dc\u30fc\u30c9\u4e0a\u306e\u4f4d\u7f6e\u3068\u9006\u306a\u305f\u3081\u3002
.Xmodmap\u306b\u4ee5\u4e0b\u306e\u884c\u3092\u66f8\u3044\u3066xmodmap .Xmodmap\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001Shift\u3068_\u3067\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u3092\u6253\u3066\u308b\u3088\u3046\u306b\u306a\u308b\u3002 \u3082\u3061\u308d\u3093\u3001_\u3092\u62bc\u305b\u3070_\u304c\u51fa\u308b\u3002
.Xmodmap
xmodmap .Xmodmap
Shift
_
keycode 97 = underscore backslash underscore backslash\n
Ubuntu 22.04\u306e\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u8a2d\u5b9a\u3068\u540c\u3058\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u3002
\u304b\u306a\u3001\u82f1\u6570\u3001Caps Lock\u304c\u6b63\u3057\u304f\u8a8d\u8b58\u3055\u308c\u306a\u304b\u3063\u305f\u305f\u3081\u3001xmodmap\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3059\u308b\u3002
xmodmap
keycode 97 = underscore backslash underscore backslash\nkeycode 130 = Hiragana Hiragana Hiragana Hiragana\nkeycode 131 = Eisu_toggle Eisu_toggle Eisu_toggle Eisu_toggle\nkeycode 66 = Caps_Lock Caps_Lock Caps_Lock Caps_Lock\n
IBus\u7528\u306eMozc\u3068Mozc\u306eGUI\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002
IBus
Mozc
sudo apt install ibus-mozc mozc-utils-gui\n
\u305d\u306e\u5f8c\u3001\u8a2d\u5b9a\u306e\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u300cAdd Input Source...\u300d\u304b\u3089\u300cJapanese (Mozc)\u300d\u3092\u8ffd\u52a0\u3059\u308b\u3002 \u305d\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30ad\u30fc\u30de\u30c3\u30d7\u3092\u5909\u66f4\u3059\u308b\u3002
\u3053\u306e\u8a18\u4e8b\u306fAlembic\u306ev1.8.3\u3092\u53c2\u7167\u3057\u3066\u3044\u307e\u3059\u3002 \u610f\u5473\u304c\u308f\u304b\u3089\u306a\u304f\u3066\u3082\u6700\u5f8c\u307e\u3067\u76ee\u3092\u901a\u3057\u3066\u304b\u3089\u3001\u3082\u3046\u4e00\u5ea6\u8aad\u3080\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002 \u79c1\u304c\u7406\u89e3\u3057\u3066\u3044\u308bPolyMesh(\u30dd\u30ea\u30b4\u30f3\u30e1\u30c3\u30b7\u30e5)\u3068Xform(\u30e1\u30c3\u30b7\u30e5\u306e\u5909\u5f62)\u306b\u95a2\u9023\u3059\u308b\u9805\u76ee\u306e\u307f\u53d6\u308a\u4e0a\u3052\u307e\u3059\u3002
PolyMesh
Xform
\u307e\u305f\u3001alembic for realtime rendering\u3084Alembic\u521d\u671f\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8alembic - AlembicPoint9UsersGuide.wiki\u3092\u8aad\u3080\u3068\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002
Alembic\u306f\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3084\u7269\u7406\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u306a\u3069\u3092\u884c\u30463DCG\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u9593\u3067\u3084\u308a\u3068\u308a\u51fa\u6765\u308b\u3001 \u6642\u9593\u3054\u3068\u306e\u7269\u4f53\u306e\u5e7e\u4f55\u60c5\u5831\u3092\u4fdd\u5b58\u3057\u305f\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u3067\u3042\u308b\u3002
Alembic\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6a5f\u80fd\u6bce\u306b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u540d\u524d\u7a7a\u9593\u304c\u5206\u3051\u3089\u308c\u3066\u3044\u308b\u3002 \u4ee5\u4e0b\u306e\u8868\u306b\u5fc5\u8981\u306a\u3082\u306e\u3060\u3051\u3092\u629c\u7c8b\u3057\u305f\u3002
Ogawa\u306fHDF5\u3088\u308a\u30b7\u30f3\u30b0\u30eb\u30b9\u30ec\u30c3\u30c9\u3060\u3068\u5e73\u5747\u30675\u500d\u3001\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u3060\u3068\u540c\u3058\u64cd\u4f5c\u3092\u884c\u3063\u305f\u5834\u5408\u3068\u6bd4\u8f03\u3057\u306625\u500d\u901f\u304f\u8aad\u307f\u8fbc\u3080\u3002 \u307e\u305f\u3001\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u304c\u5e73\u5747\u30675-15%\u5c0f\u3055\u304f\u306a\u308a\u3001\u5c0f\u3055\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u591a\u3044\u307b\u3069\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3082\u5c0f\u3055\u304f\u306a\u308b\u3002 \u7279\u306b\u7406\u7531\u304c\u306a\u3051\u308c\u3070\u3001Ogawa\u3092\u4f7f\u3046\u3053\u3068\u3092\u304a\u52e7\u3081\u3059\u308b\u3002
\u4ee5\u4e0b\u306e\u8868\u306b\u5217\u6319\u3059\u308b\u3002
\u307e\u305f\u3001Alembic\u30d5\u30a1\u30a4\u30eb\u306f\u8ffd\u8a18\u304c\u51fa\u6765\u306a\u3044\u305f\u3081\u3001Points\u306a\u3069\u6642\u7cfb\u5217\u3067\u4fdd\u5b58\u3067\u304d\u306a\u3044\u5834\u5408\u306f\u6642\u7cfb\u5217\u9806\u306b\u30d5\u30a1\u30a4\u30eb\u306b\u540d\u524d\u3092\u4ed8\u3051\u3066\u3001\u3053\u306e\u6a5f\u80fd\u3067\u8aad\u307f\u8fbc\u3080\u3068\u826f\u3044\u3002
Points
AbcCoreLayer\u306fMetaData\u3092\u9069\u5207\u306b\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306b\u3001Util.h\u5185\u306bSetPrune\u3068SetReplace\u3068\u3044\u3046\u4fbf\u5229\u306a\u95a2\u6570\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3089\u3057\u3044\u3002
MetaData
Util.h
SetPrune
SetReplace
Alembic\u3067\u306f\u3001\u5165\u529b\u6642\u306b\u4f7f\u3046\u30af\u30e9\u30b9\u306b\u306fI\u304c\u3001\u51fa\u529b\u6642\u306b\u4f7f\u3046\u3082\u306e\u306b\u306fO\u304c\u540d\u524d\u306e\u5148\u982d\u306b\u4ed8\u304f\u3002 \u3053\u3053\u3067\u306f\u533a\u5225\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u305f\u3081\u3001\u7701\u7565\u3059\u308b\u3002
I
O
Archive
\u30c7\u30a3\u30b9\u30af\u4e0a\u306e\u5b9f\u969b\u306e\u30d5\u30a1\u30a4\u30eb\u3002 \u3059\u3079\u3066\u306e\u30b7\u30fc\u30f3\u30c7\u30fc\u30bf\u3092\u6301\u3064\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30b3\u30f3\u30c6\u30ca\u3002 1\u3064\u306eObject\u3092\u6301\u3064\u3002
Object
Alembic\u306e\u968e\u5c64\u306e\u4e3b\u306a\u5358\u4f4d\u3002 Object\u306fArchive\u306eObject\u3092\u30eb\u30fc\u30c8\u3068\u3057\u305f\u591a\u5206\u6728\u306b\u306a\u3063\u3066\u304a\u308a\u3001\u89aa\u3068\u5b50\u4f9b\u305f\u3061\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002 1\u3064\u306eCompoundProperty\u3092\u6301\u3064\u3002 ObjectHeader\u3068\u547c\u3070\u308c\u308b\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u6301\u3061\u3001SchemaObject\u3092\u5224\u5b9a\u3059\u308b\u305f\u3081\u306b\u4f7f\u308f\u308c\u308b\u3002
CompoundProperty
ObjectHeader
SchemaObject
Schema
\u30dd\u30ea\u30b4\u30f3\u30e1\u30c3\u30b7\u30e5\u3088\u3046\u306a\u3001\u3042\u308b\u8907\u96d1\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306b\u4f5c\u3089\u308c\u305fCompoundProperty\u3002
Schema\u3092CompundProperty\u3068\u3057\u3066\u6301\u3064Object\u306e\u3053\u3068\u3002
CompundProperty
Simple\u3068Compound\u306e2\u7a2e\u985e\u306e\u578b\u304c\u3042\u308b\u3002 \u5024\u3092\u53d6\u5f97\u3059\u308b\u306b\u306fSampleSelector\u3068\u3044\u3046\u3001\u3042\u308b\u6642\u70b9\u306e\u6642\u523b\u3092\u8868\u3059\u30af\u30e9\u30b9\u3092\u4e0e\u3048\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002
SampleSelector
Scalar\u3068Array\u306e2\u7a2e\u985e\u3042\u308b\u3002
ScalarProperty
\u578b\u3068\u8981\u7d20\u306e\u6570\u304c\u56fa\u5b9a\u3055\u308c\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u6c7a\u307e\u308b\u8907\u6570\u306eSample\u3092\u6301\u3064\u3002 \u4f8b\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u304c\u3042\u308b\u3002
ScalarProperty\u306e\u6700\u5927\u306e\u9577\u3055\u306f256\u3067\u3042\u308b\u3002
TypedArrayProperty
\u6642\u523b\u6bce\u306eSample\u3092\u6301\u3064Property\u3002 ArrayProperty\u3082\u3042\u308b\u304c\u3001\u4e3b\u306b\u4f7f\u3046\u306e\u306f\u3053\u3063\u3061\u306e\u65b9\u3002 \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u5024\u306e\u578b(\u6b63\u78ba\u306b\u306fTypedPropertyTraits.h\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u578b)\u304c\u5165\u3063\u3066\u3044\u308b\u3002 \u4f8b\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u304c\u3042\u308b\u3002
Sample
Property
ArrayProperty
DoubleArrayProperty
V3fArrayProperty
Imath::Vec3f
M44fArrayProperty
Imath::M44f
\u305f\u3060\u3057\u3001\u540c\u3058Sample\u3092\u4fdd\u5b58\u3057\u306a\u3044\u3002
(CompoundProperty\u3092\u542b\u3080)\u8907\u6570\u306eProperty\u3092\u6301\u3064Property\u3002
\u3042\u308b\u6642\u523b\u306e\u751f\u306e\u30c7\u30fc\u30bf\u3002 Property\u3068\u540c\u69d8\u306b\u3001Sample\u3082Scalar\u3068Array\u306e2\u7a2e\u985e\u3042\u308b\u3002 \u4f8b\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u304c\u3042\u308b\u3002
DoubleArraySample
V3fArraySample
M44fArraySample
TimeSampling
Property\u304c\u6301\u3064\u6642\u9593\u3092\u7ba1\u7406\u3059\u308b\u30af\u30e9\u30b9\u3002 \u6642\u9593\u306e\u914d\u5217\u3068TimeSamplingType\u3092\u6301\u3064\u3002 TimeSamplingType\u306e\u7a2e\u985e\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002
TimeSamplingType
Property\u5185\u306eSample\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u4f7f\u3046\u30af\u30e9\u30b9\u3002 TimeSampling\u304c\u6301\u3064\u6642\u9593\u306e\u914d\u5217\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u76f4\u63a5\u4e0e\u3048\u308b\u304b\u3001\u6642\u523b\u3092\u4e0e\u3048\u308b\u3053\u3068\u3067\u4f5c\u308b\u3002 \u6642\u523b\u3092\u6e21\u3059\u5834\u5408\u3001\u8ffd\u52a0\u3067TimeIndexType\u30d5\u30e9\u30b0\u3092\u6e21\u3059\u3053\u3068\u3082\u3067\u304d\u308b\u3002 TimeIndexType\u30d5\u30e9\u30b0\u306e\u610f\u5473\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002
TimeIndexType
\u30dd\u30ea\u30b4\u30f3\u30e1\u30c3\u30b7\u30e5\u3092\u7ba1\u7406\u3059\u308b\u30b9\u30ad\u30fc\u30de\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3002 \u6642\u523b\u6bce\u306b\u9802\u70b9\u3001\u9762\u3001\u9802\u70b9\u3084\u9762\u306e\u6cd5\u7dda\u3092\u6301\u3061\u3001UV\u3001\u9802\u70b9\u3054\u3068\u306e\u901f\u5ea6\u3001AABB\u3082\u6301\u3064\u3053\u3068\u304c\u51fa\u6765\u308b\u3002
PolyMesh\u306e\u30b9\u30ad\u30fc\u30de\u3067\u3001PolyMesh\u30af\u30e9\u30b9\u306egetSchema\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u308b\u3002
getSchema
\u3053\u306e\u30af\u30e9\u30b9\u306egetTopologyVariance\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u30dd\u30ea\u30b4\u30f3\u30e1\u30c3\u30b7\u30e5\u304c\u5909\u5316\u3059\u308b\u304b\u5224\u5b9a\u3067\u304d\u308b\u3002 \u4ee5\u4e0b\u306f\u623b\u308a\u5024\u3068\u305d\u306e\u610f\u5473\u306e\u8868\u3067\u3042\u308b\u3002 \u623b\u308a\u5024\u306f\u540d\u524d\u7a7a\u9593Alembic::AbcGeom::MeshTopologyVariance\u3092\u7701\u7565\u3057\u3066\u3044\u308b\u3002
getTopologyVariance
Alembic::AbcGeom::MeshTopologyVariance
XformSchema\u3068\u540c\u3058\u3088\u3046\u306b\u3001getValue\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u3042\u308b\u6642\u523b\u306e\u30dd\u30ea\u30b4\u30f3\u30e1\u30c3\u30b7\u30e5\u3092\u53d6\u5f97\u3067\u304d\u308b\u304c\u3001\u3044\u304f\u3064\u304b\u6ce8\u610f\u70b9\u304c\u3042\u308b\u3002
XformSchema
getValue
Alembic\u3067\u306f\u3001\u4efb\u610f\u306e\u591a\u89d2\u5f62\u3092\u6301\u3064\u3053\u3068\u304c\u51fa\u6765\u308b\u3002 \u3064\u307e\u308a\u3001\u4e09\u89d2\u5f62\u3084\u56db\u89d2\u5f62\u3092\u6301\u3064\u30dd\u30ea\u30b4\u30f3\u30e1\u30c3\u30b7\u30e5\u3092Alembic\u306b\u4fdd\u5b58\u3067\u304d\u308b\u3002 \u3053\u306e\u3053\u3068\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u3001\u9762\u3092\u4ee5\u4e0b\u306e\u30ea\u30b9\u30c8\u3067\u8868\u73fe\u3057\u3066\u3044\u308b\u3002
1\u3064\u76ee\u306e\u30ea\u30b9\u30c8\u306f\u9762\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u30ea\u30b9\u30c8\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u5bfe\u5fdc\u3055\u305b\u305f2\u6b21\u5143\u306e\u30ea\u30b9\u30c8\u3092\u30d5\u30e9\u30c3\u30c8\u306b\u3057\u305f\u3082\u306e\u3067\u3082\u3042\u308b\u3002 \u5177\u4f53\u4f8b\u3068\u3057\u3066\u3001\u4e09\u89d2\u5f62\u3068\u56db\u89d2\u5f62\u3092\u305d\u308c\u305e\u308c1\u3064\u305a\u3064\u6301\u3061\u30011\u8fba\u3092\u5171\u6709\u3059\u308b\u30e1\u30c3\u30b7\u30e5\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002
1\u3064\u76ee\u306e\u30ea\u30b9\u30c8\u3092\u6301\u3064Property\u306fgetFaceIndicesProperty\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u30012\u3064\u76ee\u306e\u30ea\u30b9\u30c8\u3092\u6301\u3064Property\u306fgetFaceIndicesProperty\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u308b\u3002
getFaceIndicesProperty
\u5b9f\u306f\u6cd5\u7dda\u3068UV\u306f\u3053\u308c\u307e\u3067\u8aac\u660e\u3057\u3066\u304d\u305f\u30af\u30e9\u30b9\u306e\u3069\u308c\u3067\u3082\u306a\u3044\u3002 \u6cd5\u7dda\u306fTypedGeomParam\u3068\u3044\u3046Schema\u306b\u4f3c\u305f\u3088\u3046\u306a\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3001PolyMeshSchema\u30af\u30e9\u30b9\u306egetNormalsParam\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u308b\u3002 \u6cd5\u7dda\u306e\u5024\u306e\u610f\u5473\u306fTypedGeomParam\u30af\u30e9\u30b9\u306egetScope\u306e\u623b\u308a\u5024\u306b\u3088\u3063\u3066\u7570\u306a\u308a\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u3002
TypedGeomParam
PolyMeshSchema
getNormalsParam
getScope
kVaryingScope
\u6cd5\u7dda\u306e\u5024\u306e\u53d6\u5f97\u306f\u4ee5\u4e0b\u306e\u4f8b\u3092\u53c2\u7167\u3002
\u5909\u5f62\u3092\u7ba1\u7406\u3059\u308b\u30b9\u30ad\u30fc\u30de\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3002 \u5b50\u306b\u5909\u5f62\u3055\u305b\u308bPolyMesh\u3084\u81ea\u8eab\u3092\u6301\u3064\u3002 Xform\u304c\u89aa\u5b50\u3067\u3042\u308b\u5834\u5408\u3001\u89aa\u304c\u5909\u5f62\u3055\u305b\u305f\u5f8c\u306b\u5b50\u4f9b\u304c\u5909\u5f62\u3055\u305b\u308b(\u30c6\u30b9\u30c8\u3092\u898b\u308b\u9650\u308a\u3001\u3053\u306e\u5909\u5f62\u3057\u304b\u898b\u5f53\u305f\u3089\u306a\u304b\u3063\u305f)\u3002 \u5909\u5f62\u306e\u9806\u5e8f\u306fgetInheritsXforms\u95a2\u6570\u3067\u5224\u5b9a\u3067\u304d\u308b\u3002
getInheritsXforms
Xform\u306e\u30b9\u30ad\u30fc\u30de\u3067\u3001Xform\u30af\u30e9\u30b9\u306egetSchema\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u308b\u3002
XformSchema\u30af\u30e9\u30b9\u306egetValue\u30e1\u30f3\u30d0\u95a2\u6570\u3067XformSample\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002 XformSample\u306fXformOp\u306e\u30ea\u30b9\u30c8\u3092\u6301\u3064\u3002 getNumOps\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u7dcf\u6570\u3092\u53d6\u5f97\u3057\u3001operator[]\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u53d6\u5f97\u3059\u308b\u3002
XformSample
XformOp
getNumOps
operator[]
\u76f4\u306b\u5024\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u304c\u3001\u64cd\u4f5c\u304c\u8ffd\u52a0\u3055\u308c\u305f\u9806\u306b\u53d6\u308a\u51fa\u3055\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u305f\u3081\u3001\u7528\u5fc3\u3057\u3066\u4f7f\u3046\u4e8b\u3002
getNumOpChannels\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u81ea\u8eab\u304c\u6301\u3064XformOp\u306echannel\u306e\u7dcf\u6570\u304c\u308f\u304b\u308b\u3002
getNumOpChannels
channel
XformOp\u306f\u5e73\u884c\u79fb\u52d5\u3001\u56de\u8ee2\u3001\u62e1\u5927\u7e2e\u5c0f\u3001\u7dda\u5f62\u5909\u63db\u3092\u8868\u3059\u3002 \u64cd\u4f5c\u306e\u7a2e\u985e\u306fgetType\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u5224\u5b9a\u3067\u304d\u308b\u3002 \u5217\u6319\u5024\u3068\u610f\u5473\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002
getType
XformOp\u306fchannel\u3068\u3044\u3046double\u306e\u30ea\u30b9\u30c8\u3092\u6301\u3061\u3001\u5404\u64cd\u4f5c\u3092\u8868\u73fe\u3059\u308b\u305f\u3081\u306b\u4f7f\u308f\u308c\u308b\u3002 \u5404\u64cd\u4f5c\u306echannel\u6570\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002
double
\u884c\u5217\u306f\u884c\u512a\u5148\u3067\u683c\u7d0d\u3055\u308c\u308b\u3002
\u5404\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u306f\u3001\u305d\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u516c\u958b\u3057\u3066\u3044\u308b\u5168\u3066\u3092\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3057\u305fAll.h\u3068\u3044\u3046\u540d\u524d\u306e\u30d8\u30c3\u30c0\u30fc\u304c\u3042\u308b\u3002 \u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308c\u3070\u3088\u3044\u3002
All.h
// Alembic Includes\n#include <Alembic/AbcGeom/All.h>\n#include <Alembic/AbcCoreOgawa/All.h>\n
\u6b21\u306bArchive\u3092\u4f5c\u308a\u3001\u305d\u306eArchive\u306e\u5b50\u4f9b\u3068\u3057\u3066\u3001\u9759\u7684\u306a\u30dd\u30ea\u30b4\u30f3\u30e1\u30c3\u30b7\u30e5\u3092\u6301\u3064\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3088\u3046\u3002
// \u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\nauto abc_metadata = Alembic::Abc::MetaData();\n// \u540d\u524d\u3092\"PolyMesh\"\u306b\u3059\u308b\u3002\nabc_metadata.set(Alembic::Abc::kUserDescriptionKey, \"PolyMesh\");\n\nauto archive_writer = Alembic::AbcCoreOgawa::WriteArchive();\nauto writer_ptr = archive_writer(\"polyMesh1.abc\", abc_metadata);\n// polyMesh1.abc\u3078\u66f8\u304d\u8fbc\u3081\u308barchive\u3092\u4f5c\u6210\nauto archive = Alembic::Abc::OArchive(writer_ptr);\n
\u7acb\u65b9\u4f53[-1, 1] x [-1, 1] x [-1, 1]\u306ePolyMesh Object\u3092\u4f5c\u6210\u3059\u308b\u3002\"meshy\"\u306fmeshyObj\u306e\u540d\u524d\u3002
meshyObj
auto abc_top = archive.getTop();\nauto meshyObj = OPolyMesh(abc_top, \"meshy\");\n
UV\u3068\u6cd5\u7dda\u306eSample\u3092\u4f5c\u6210\u3059\u308b\u3002 \u305d\u306e\u524d\u306b\u3001UV\u306e\u540d\u524d\u306fSample\u306b\u5165\u308c\u308b\u524d\u306b\u4ed8\u3051\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002
auto& mesh = meshyObj.getSchema();\nmesh.setUVSourceName(\"test\");\n
UV\u3068\u6cd5\u7dda\u306fGeomParams\u3092\u4f7f\u3046\u3002 GeomParams\u306f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u3042\u3063\u3066\u3082\u306a\u304f\u3066\u3082\u8aad\u307f\u66f8\u304d\u3067\u304d\u308b\u3002 kFacevaryingScope\u306b\u3064\u3044\u3066\u306f\u3001\u53c2\u8003\u6587\u732e\u306e3\u30014\u3092\u53c2\u8003\u3002
GeomParams
kFacevaryingScope
// \u7acb\u65b9\u4f53\u306e\u9802\u70b9\u306eUV\u3002\n// UV\u306e\u5024\u306f\u6307\u5b9a\u3057\u305f\u9762\u3092\u69cb\u6210\u3059\u308b\u9802\u70b9\u306e\u9806\u306b\u3001\u5404\u9762\u306e\u5404\u9802\u70b9\u306e\u5024\u3092\u5217\u6319\u3059\u308b\u3002\nextern const size_t g_numUVs;\nextern const Abc::float32_t g_uvs[];\nauto uvsamp = OV2fGeomParam::Sample(\n V2fArraySample((const V2f *)g_uvs, g_numUVs), // reinterpret_cast\u3092\u4f7f\u3046\u3079\u304d\n kFacevaryingScope\n);\n// \u7acb\u65b9\u4f53\u306e\u9802\u70b9\u306e\u6cd5\u7dda\n// \u6cd5\u7dda\u306e\u5024\u306f\u6307\u5b9a\u3057\u305f\u9762\u3092\u69cb\u6210\u3059\u308b\u9802\u70b9\u306e\u9806\u306b\u3001\u5404\u9762\u306e\u5404\u9802\u70b9\u306e\u5024\u3092\u5217\u6319\u3059\u308b\u3002\n// \u3053\u308c\u306f\u57fa\u672c\u7684\u306b\u306fRenderMan\u306e\"facevarying\"\u306e\u578b\u306b\u5408\u3046\u30b9\u30c8\u30ec\u30fc\u30b8\u3067\u3042\u308b\u3002\nextern const size_t g_numNormals;\nextern const Abc::float32_t g_normals[];\nauto nsamp = ON3fGeomParam::Sample(\n N3fArraySample((const N3f *)g_normals, g_numNormals),\n kFacevaryingScope\n);\n
\u30e1\u30c3\u30b7\u30e5\u306eSample\u3092\u8a2d\u5b9a\u3059\u308b\u3002 \u5f15\u6570\u306f\u5148\u982d\u304b\u3089\u9806\u306b\u3001\u9802\u70b9\u306e\u5ea7\u6a19\u3068\u9802\u70b9\u306e\u6570\u3001\u9762\u3092\u69cb\u6210\u3059\u308b\u9802\u70b9\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u30ea\u30b9\u30c8\u3068\u305d\u306e\u30ea\u30b9\u30c8\u306e\u30b5\u30a4\u30ba\u3001\u9762\u3092\u69cb\u6210\u3059\u308b\u9802\u70b9\u306e\u6570\u306e\u30ea\u30b9\u30c8\u3068\u305d\u306e\u30ea\u30b9\u30c8\u306e\u30b5\u30a4\u30ba\u3067\u3042\u308b\u3002 \u901f\u5ea6\u306fOPolyMeshSchema::Sample\u306esetVelocityies\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u8a2d\u5b9a\u3059\u308b\u3002
OPolyMeshSchema::Sample
setVelocityies
auto mesh_samp = OPolyMeshSchema::Sample(\n V3fArraySample((const V3f *)g_verts, g_numVerts),\n Int32ArraySample(g_indices, g_numIndices),\n Int32ArraySample(g_counts, g_numCounts),\n uvsamp,\n nsamp\n);\nmesh.set(mesh_samp);\n
Alembic\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u30b9\u30b3\u30fc\u30d7\u304b\u3089\u51fa\u308b\u3068\u304d\u306b\u81ea\u52d5\u7684\u306b\u7834\u68c4\u3055\u308c\u308b\u3002 \u306a\u306e\u3067\u3001\u7279\u306b\u4f55\u3082\u3057\u306a\u304f\u3066\u826f\u3044\u3002
\u30d7\u30ed\u30b0\u30e9\u30e0\u5168\u4f53\u306f\u53c2\u8003\u6587\u732e\u306e2\u306b\u3042\u308b\u3002
\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308b\u30d8\u30c3\u30c0\u30fc\u3068\u540d\u524d\u7a7a\u9593\u306f\u524d\u4f8b\u3092\u53c2\u7167\u3002
\u8aad\u307f\u8fbc\u307f\u7528\u30a2\u30fc\u30ab\u30a4\u30d6\u3092\u4f5c\u6210\u3059\u308b\u3002
auto archive_reader = Alembic::AbcCoreOgawa::ReadArchive();\nauto reader_ptr = archive_reader(\"polyMesh1.abc\");\nauto archive = Alembic::Abc::IArchive(reader_ptr);\n
UV, \u6cd5\u7dda\u3092\u53d6\u5f97\u3059\u308b\u3002
auto meshyObj = IPolyMesh(archive.getTop(), \"meshy\");\nIPolyMeshSchema& mesh = meshyObj.getSchema();\nauto N = mesh.getNormalsParam();\nauto uv = mesh.getUVsParam();\n
\u9802\u70b9\u306e\u5ea7\u6a19\u306e\u30ea\u30b9\u30c8\u3001\u9762\u3092\u69cb\u6210\u3059\u308b\u9802\u70b9\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u30ea\u30b9\u30c8\u3001\u9762\u3092\u69cb\u6210\u3059\u308b\u9802\u70b9\u306e\u6570\u306e\u30ea\u30b9\u30c8\u3001AABB\u3001\u3082\u3057\u3042\u308c\u3070\u901f\u5ea6\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\u3002
IPolyMeshSchema::Sample mesh_samp;\nmesh.get(mesh_samp);\n
\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u3001\u6cd5\u7dda\u306e\u30ea\u30b9\u30c8\u306e\u30dd\u30a4\u30f3\u30bf\u30fc(\u6b63\u78ba\u306b\u306fN3fArraySamplePtr)\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002
N3fArraySamplePtr
auto nsp = N.getExpandedValue().getVals();\n
\u5404\u6cd5\u7dda\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u53d6\u5f97\u3067\u304d\u308b\u3002
for ( size_t i = 0 ; i < nsp->size() ; ++i )\n{\n std::cout << i << \"th normal: \" << (*nsp)[i] << std::endl;\n}\n
\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4ed8\u3051\u305f\u3044\u3068\u304d\u306f\u3001getExpandedValue\u306e\u4ee3\u308f\u308a\u306bgetIndexedValue\u3092\u4f7f\u3046\u3002
getExpandedValue
getIndexedValue
auto uvsamp = uv.getIndexedValue();\n
\u5024\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u53d6\u5f97\u3059\u308b\u3002
V2f uv2 = (*(uvsamp.getVals()))[2];\nTESTING_ASSERT( uv2 == V2f( 1.0f, 1.0f ) );\n
\u9802\u70b9\u306e\u30ea\u30b9\u30c8\u306e\u30b5\u30a4\u30ba\u306f\u4ee5\u4e0b\u3067\u53d6\u5f97\u3067\u304d\u308b\u3002
mesh_samp.getPositions()->size();\n
\u6700\u521d\u306e\u9802\u70b9\u306e\u5ea7\u6a19\u306f\u4ee5\u4e0b\u3067\u53d6\u5f97\u3067\u304d\u308b\u3002
(*(mesh_samp.getPositions()))[0];\n
\u53d6\u5f97\u3059\u308b\u3060\u3051\u306a\u3089\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7c21\u6f54\u306b\u66f8\u3051\u308b\u3002
mesh_samp.getPositions()->get()[0];\n
\u5c0f\u30cd\u30bf\u96c6\u3067\u3059\u3002
-expt-extended-lambda
host_vector
device_vector
struct A final {}
template <int D>\nstruct A\n{\n static_assert(D > 1);\n\n double d;\n A<D-1> a;\n};\n\ntemplate <>\nstruct A<1>\n{\n int d;\n};\n
inline
const
default
find_package
components
unit_test_framework
git rm
git reflog --keep (\u30d6\u30e9\u30f3\u30c1\u540d)@{\u756a\u53f7}
--depth 1
git clean
git add -u
PETSc\u306b\u306fPetscCallThrow\u3068\u3044\u3046\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3068std::runtime_error\u3092\u6295\u3052\u308b\u95a2\u6570\u304c\u3042\u308b\u3002 \u3053\u306e\u95a2\u6570\u306fPETSC_CLANGUAGE_CXX\u3068\u3044\u3046\u30de\u30af\u30ed\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u4f7f\u3048\u306a\u3044\u3002 \u4ed6\u306b\u3082C++\u7528\u306e\u95a2\u6570\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u306e\u3067\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3059\u308b\u3002 \u3061\u306a\u307f\u306b\u3001\u30d8\u30c3\u30c0\u30fc\u3092\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308b\u6642\u306fextern \"C\"\u3092\u3064\u3051\u306a\u3044\u3002
PetscCallThrow
std::runtime_error
PETSC_CLANGUAGE_CXX
extern \"C\"
\u516c\u5f0f\u30b5\u30a4\u30c8\u306b\u7528\u9014\u306b\u5fdc\u3058\u3066\u4f7f\u3046\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u793a\u3055\u308c\u3066\u3044\u308b\u304c\u3001\u3069\u3093\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308b\u306e\u304b\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u3002 \u3069\u3093\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308b\u306e\u304b\u8abf\u3079\u308b\u305f\u3081\u306e\u4e00\u756a\u624b\u3063\u53d6\u308a\u65e9\u3044\u65b9\u6cd5\u306f\u3001CI\u306e\u30c6\u30b9\u30c8\u3092\u898b\u308b\u3053\u3068\u3067\u3042\u308b\u3002 \u5730\u9053\u306a\u65b9\u6cd5\u306f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u898b\u308b\u3053\u3068\u3060\u304c\u3001BuildSystem\u304c\u3042\u307e\u308a\u306b\u8907\u96d1\u306a\u306e\u3067\u6642\u9593\u304c\u304b\u304b\u308b\u3060\u308d\u3046\u3002 \u500b\u4eba\u7684\u306b\u306fpackage\u3092\u898b\u308b\u3068\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u6bce\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3069\u3046\u3044\u3046\u98a8\u306b\u4f7f\u308f\u308c\u3066\u3044\u308b\u304b\u308f\u304b\u308b\u306e\u3067\u3001\u3053\u3053\u3092\u898b\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3059\u308b\u3002
BuildSystem
Thrust\u306e\u975e\u540c\u671f\u5b9f\u884c\u306b\u3064\u3044\u3066\u3067\u3059\u304c\u3001\u65e5\u672c\u8a9e\u306e\u6587\u732e\u304c\u300ethrust\u306basync\u30b5\u30dd\u30fc\u30c8\u304c\u5165\u3063\u3066\u3044\u305f\u300f\u304f\u3089\u3044\u3057\u304b\u898b\u5f53\u305f\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u5177\u4f53\u4f8b\u3092\u4ea4\u3048\u306a\u304c\u3089\u74b0\u5883\u69cb\u7bc9\u304b\u3089\u89e3\u8aac\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002
CMake\u3092\u4f7f\u3046\u3084\u308a\u65b9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002 Windows\u3067\u306f\u8a66\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u3054\u4e86\u627f\u4e0b\u3055\u3044\u3002
\u4ee5\u4e0b\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002
Git\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u304c\u3001\u306a\u304f\u3066\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002
Thrust\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002 1.9.4\u4ee5\u4e0a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u9078\u3093\u3067\u4e0b\u3055\u3044\u3002 Git\u3092\u4f7f\u3046\u65b9\u306f\u518d\u5e30\u7684\u306b\u30b5\u30d6\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30af\u30ed\u30fc\u30f3\u3057\u3066\u304f\u3060\u3055\u3044\u3002
\u306a\u305c\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u304b\u3068\u3044\u3046\u3068\u3001CMake\u304cThrust\u3092\u898b\u3064\u3051\u3066\u304f\u308c\u306a\u304b\u3063\u305f\u305f\u3081\u3067\u3059\u3002 \u898b\u3064\u3051\u65b9\u3092\u3054\u5b58\u3058\u306e\u65b9\u306f\u6559\u3048\u3066\u3044\u305f\u3060\u3051\u308b\u3068\u5e78\u3044\u3067\u3059\u3002
\u4f8b\u3068\u3057\u3066\u3001float\u3068int\u306e\u914d\u5217\u3092\u4f5c\u6210\u3057\u3001GPU\u3067\u5404\u8981\u7d20\u306e2\u4e57\u3092\u8a08\u7b97\u3057\u3001\u7d50\u679c\u304c\u6b63\u3057\u3044\u304b\u78ba\u8a8d\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 \u4ee5\u4e0b\u306e\u3088\u3046\u306bCMake\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002
float
int
hoge/-- CMakeLists.txt\n |- double.cu\n |- double.h\n |- main.cpp\n |- thrust/\n
CMakeLists.txt\u306b\u4ee5\u4e0b\u3092\u66f8\u304d\u307e\u3059\u3002
cmake_minimum_required(VERSION 3.27.7)\n\n# CUDA\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3092\u6307\u5b9a\u3059\u308b\u3002\n# \u6700\u521d\u306b\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3002\nif(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)\n set(CMAKE_CUDA_ARCHITECTURES native)\nendif()\n\nproject(my_program VERSION 0.1.0 LANGUAGES CXX CUDA)\n\n# \u3053\u3053\u306e\u8a2d\u5b9a\u306f\u304a\u597d\u307f\u3067\u3002\nset(CMAKE_CXX_EXTENSIONS OFF)\nset(CMAKE_OPTIMIZE_DEPENDENCIES ON)\n\n# CUDA\u3092\u898b\u3064\u3051\u308b\u3002\nfind_package(CUDAToolkit 12 REQUIRED)\n\n# Thrust\u3092\u898b\u3064\u3051\u308b\u3002\nadd_subdirectory(thrust)\nfind_package(Thrust REQUIRED CONFIG)\nthrust_create_target(Thrust)\n\n# CUDA\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f5c\u308b\u3002\nadd_library(double double.cu)\ntarget_compile_options(\n double\n PRIVATE\n # C++14\u4ee5\u4e0a\u304c\u5fc5\u8981\n cxx_std_14\n # \u30e9\u30e0\u30c0\u5f0f\u3092\u30c7\u30d0\u30a4\u30b9\u30b3\u30fc\u30c9\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u3002\n -expt-extended-lambda\n # SIMD\u3092\u7121\u52b9\u306b\u3059\u308b\u3002\n # SIMD\u306e\u7121\u52b9\u5316\u306f\u5fc5\u9808\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001Eigen\u306a\u3069\u7dda\u5f62\u4ee3\u6570\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u969b\u306b\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\n \"$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-fno-tree-vectorize>\"\n \"$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-fno-vectorize>\"\n)\n# \u3053\u3053\u306f\u304a\u597d\u307f\u3067\u3002\ntarget_compile_features(\n double\n PRIVATE\n cuda_std_20\n)\n# \u8ab0\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u306a\u3044\u306f\u305a\u306a\u306e\u3067\u3001\u7c21\u7565\u306b\u3002\ntarget_include_directories(\n double\n PUBLIC \n ${CMAKE_CURRENT_SOURCE_DIR}\n)\n# CUDA\u30e9\u30f3\u30bf\u30a4\u30e0\u3068Thrust\u3092\u30ea\u30f3\u30af\u3059\u308b\u3002\n# \u5f53\u305f\u308a\u524d\u3067\u3059\u304c\u3001Thrust\u306b\u306fCUDA\u306f\u306a\u3044\u306e\u3067\u3002\ntarget_link_libraries(\n double\n PUBLIC\n CUDA::cudart\n Thrust\n)\n\n# my_program\u3092\u4f5c\u308b\u3002\nadd_executable(my_program main.cpp)\ntarget_link_libraries(\n my_program\n PRIVATE\n double\n)\n# \u3053\u3053\u306f\u304a\u597d\u307f\u3067\u3002\ntarget_compile_features(\n my_program\n PRIVATE\n cxx_std_20\n)\n# \u3053\u3053\u306f\u304a\u597d\u307f\u3067\u3002\ntarget_compile_options(\n my_program\n PRIVATE\n \"$<$<CONFIG:Debug>:-g;-O0;-Wall;-Wextra>\"\n \"$<$<CONFIG:Release>:-DNDEBUG;-O3;-march=native;-mtune=native>\"\n)\n# CUDA 5.0\u4ee5\u524d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306f\u3001\u30c7\u30d0\u30a4\u30b9\u30b3\u30fc\u30c9\u3067\u4f7f\u7528\u3059\u308b\u95a2\u6570\u306e\u5b9f\u88c5\u307e\u3067\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308b\u5fc5\u8981\u304c\n# \u3042\u308a\u307e\u3057\u305f\u304c\u3001CUDA 5.0\u4ee5\u964d\u3067\u306f\u3001\u30c7\u30d0\u30a4\u30b9\u30b3\u30fc\u30c9\u3067\u4f7f\u7528\u3059\u308b\u95a2\u6570\u306e\u5ba3\u8a00\u306e\u307f\u3092\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308b\u3060\u3051\u3067\n# \u5341\u5206\u306b\u306a\u308a\u307e\u3057\u305f\u3002\n# \u3053\u306e\u3053\u3068\u3092\u30b3\u30f3\u30d1\u30a4\u30e9\u3068\u30ea\u30f3\u30ab\u30fc\u306b\u4f1d\u3048\u308b\u305f\u3081\u306b\u3001CUDA_SEPARABLE_COMPILATION\u30d7\u30ed\u30d1\u30c6\u30a3\u3092ON\u306b\n# \u3057\u3066\u3044\u307e\u3059\u3002\n# \u305f\u3060\u3057\u3001\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u306b\u306e\u307fON\u306b\u8a2d\u5b9a\u3057\u3066\u4e0b\u3055\u3044\u3002\n# \u8a73\u3057\u304f\u306f\u53c2\u8003\u6587\u732e1\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\nset_property(TARGET my_program PROPERTY CUDA_SEPARABLE_COMPILATION ON)\n
\u3044\u3088\u3044\u3088\u672c\u984c\u3067\u3059\u3002
Thrust\u306b\u306fevent\u3068future\u304c\u3042\u308a\u307e\u3059\u3002 future\u306freduce\u304b\u3089\u8fd4\u3055\u308c\u3001\u305d\u306e\u4ed6\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306fevent\u3092\u8fd4\u3057\u307e\u3059\u3002 \u3069\u3061\u3089\u3082wait()\u30e1\u30f3\u30d0\u95a2\u6570\u3092\u6301\u3061\u3001\u975e\u540c\u671f\u5b9f\u884c\u304c\u7d42\u308f\u308b\u307e\u3067\u5f85\u3061\u307e\u3059\u3002 future\u306f\u3055\u3089\u306bget()\u30e1\u30f3\u30d0\u95a2\u6570\u3092\u6301\u3061\u3001\u5b9f\u884c\u7d50\u679c\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002 \u8a73\u3057\u304f\u77e5\u308a\u305f\u3044\u65b9\u306f\u53c2\u8003\u6587\u732e2\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002 event\u306funique_eager_event\u30af\u30e9\u30b9\u306b, future\u306funique_eager_future\u30af\u30e9\u30b9\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002
event
future
reduce
wait()
get()
unique_eager_event
unique_eager_future
\u30d8\u30c3\u30c0\u30fc\u306f\u305d\u308c\u305e\u308cthrust/event.h, thrust/future.h\u3067\u3059\u3002 \u4eca\u56de\u306f\u8a08\u7b97\u7d50\u679c\u3092host_vector\u306b\u683c\u7d0d\u3059\u308b\u306e\u3067\u3001\u4f7f\u3046\u306e\u306f\u5b9f\u884c\u304c\u5b8c\u4e86\u3057\u305f\u304b\u78ba\u8a8d\u3059\u308b\u3060\u3051\u306eevent\u3067\u3059\u3002
#include <thrust/event.h>\n#include <thrust/host_vector.h>\n\nthrust::device_event Double(thrust::host_vector<float>& doubles, thrust::host_vector<int>& ints);\n
\u3053\u3053\u3067device_event\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u30db\u30b9\u30c8\u3067\u3082\u4f7f\u3048\u307e\u3059\u3002 host_event\u306f\u3042\u308a\u307e\u305b\u3093\u3002 \u5f8c\u306e\u300c\u6b20\u70b9\u300d\u306e\u7bc0\u3067\u3053\u306e\u3053\u3068\u306b\u89e6\u308c\u307e\u3059\u3002 __global__\u306f\u3042\u3063\u3066\u3082\u306a\u304f\u3066\u3082\u3044\u3044\u3067\u3059\u3002
device_event
host_event
__global__
Thrust\u306b\u306fcopy\u3084transform\u3068\u3044\u3063\u305f\u3001STL\u306e\u3088\u3046\u306a\u95a2\u6570\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u3053\u308c\u3089\u3092\u975e\u540c\u671f\u306b\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u306f\u3001async\u540d\u524d\u7a7a\u9593\u306e\u3082\u306e\u3092\u4f7f\u3048\u3070\u3044\u3044\u3067\u3059\u3002 \u4f8b\u3048\u3070\u3001thrust::copy\u306e\u975e\u540c\u671f\u7248\u306fthrust::async::copy\u3067\u3059\u3002
copy
transform
async
thrust::copy
thrust::async::copy
\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3068\u306f\u3001\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u30db\u30b9\u30c8\u3067\u5b9f\u884c\u3059\u308b\u306e\u304b\u3001\u30c7\u30d0\u30a4\u30b9\u3067\u5b9f\u884c\u3059\u308b\u306e\u304b\u3001\u305d\u308c\u3068\u3082\u9010\u6b21\u7684\u306b\u51e6\u7406\u3059\u308b\u306e\u304b\u3092\u6307\u5b9a\u3059\u308b\u30af\u30e9\u30b9\u3067\u3059\u3002 \u30af\u30e9\u30b9\u540d\u306f\u305d\u308c\u305e\u308chost\u3001device\u3001seq\u3067\u3059\u3002 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u660e\u793a\u7684\u306b\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u7121\u99c4\u306a\u30c7\u30fc\u30bf\u306e\u30b3\u30d4\u30fc\u3092\u6e1b\u3089\u305b\u307e\u3059\u3002 \u5b9f\u88c5\u306f\u30bf\u30b0\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\u3067\u3001\u81ea\u5206\u3067\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002 \u8a73\u3057\u304f\u306f\u53c2\u8003\u6587\u732e3\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002
host
device
seq
\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u81ea\u4f53\u306f\u540c\u671f\u7684\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u5bfe\u3057\u3066\u3082\u4f7f\u3048\u307e\u3059\u304c\u3001\u975e\u540c\u671f\u306a\u3089host\u3068device\u306eafter\u30e1\u30f3\u30d0\u95a2\u6570\u306bevent\u3068future\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u5b9f\u884c\u9806\u5e8f\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002 event\u3068future\u306e\u500b\u6570\u306f\u4f55\u500b\u3067\u3082\u3044\u3044\u3067\u3059\u3002 \u307e\u305f\u3001thrust::when_all\u95a2\u6570\u3067\u8907\u6570\u306eevent\u3068future\u3092\u4e00\u3064\u306eevent\u306b\u307e\u3068\u3081\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002
after
thrust::when_all
\u3053\u308c\u3089\u3092\u8e0f\u307e\u3048\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3059\u3002
#include <thrust/async/copy.h>\n#include <thrust/async/transform.h>\n#include <thrust/device_vector.h>\n\n#include \"double.h\"\n\ntemplate <class T>\nthrust::device_event Double(thrust::host_vector<T>& ts) {\n // \u30c7\u30d0\u30a4\u30b9\u5074\u306e\u914d\u5217\u3092\u7528\u610f\n auto device_ts = thrust::device_vector<T>();\n\n // \u30e1\u30e2\u30ea\u306e\u78ba\u4fdd\u3068\u521d\u671f\u5316\n device_ts.resize(ts.size());\n\n // \u30db\u30b9\u30c8\u304b\u3089\u30c7\u30d0\u30a4\u30b9\u3078\u306e\u975e\u540c\u671f\u30b3\u30d4\u30fc\n auto copy_ts_event = thrust::async::copy(\n thrust::host,\n thrust::device,\n ts.begin(),\n ts.end(),\n device_ts.begin()\n );\n\n // \u30c7\u30d0\u30a4\u30b9\u5074\u3067\u306e\u8a08\u7b97\n auto double_ts_event = thrust::async::transform(\n thrust::device.after(copy_ts_event),\n device_ts.begin(),\n device_ts.end(),\n device_ts.begin(),\n [] __device__(T d) { return d * d; }\n );\n\n // \u30c7\u30d0\u30a4\u30b9\u304b\u3089\u30db\u30b9\u30c8\u3078\u306e\u975e\u540c\u671f\u30b3\u30d4\u30fc\n auto copy_back_ts_event = thrust::async::copy(\n thrust::device.after(double_ts_event),\n device_ts.begin(),\n device_ts.end(),\n ts.begin()\n );\n\n return copy_back_ts_event;\n}\n\nthrust::device_event Double(thrust::host_vector<float>& floats, thrust::host_vector<int>& ints) {\n // \u975e\u540c\u671f\u5b9f\u884c\u306e\u5b8c\u4e86\u3092\u307e\u3068\u3081\u308b\n return thrust::when_all(Double(floats), Double(ints));\n}\n
int\u3068float\u306e\u914d\u5217\u306e\u305d\u308c\u305e\u308c\u306b\u5bfe\u3057\u3066\u3001\u30c7\u30d0\u30a4\u30b9\u3078\u306e\u30b3\u30d4\u30fc\u304c\u5b8c\u4e86\u3057\u305f\u3089\u30012\u4e57\u3059\u308b\u8a08\u7b97\u3092\u884c\u3044\u3001\u7d42\u308f\u308c\u3070\u30db\u30b9\u30c8\u3078\u30b3\u30d4\u30fc\u3059\u308b\u51e6\u7406\u3092\u9806\u756a\u306b\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306b\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002 \u6700\u5f8c\u306b\u3001\u4e21\u65b9\u306e\u914d\u5217\u304c\u30db\u30b9\u30c8\u3078\u30b3\u30d4\u30fc\u3055\u308c\u305f\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306eevent\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002
\u3042\u3068\u306f\u3001main\u95a2\u6570\u3067\u5404\u914d\u5217\u3092\u4f5c\u3063\u3066\u3001Double\u95a2\u6570\u306b\u6e21\u3057\u3066\u3001\u7d50\u679c\u304c\u6b63\u3057\u3044\u304b\u78ba\u8a8d\u3059\u308b\u3060\u3051\u3067\u3059\u3002
main
Double
main.cpp
#include \"double.h\"\n\n#include <cassert>\n#include <cmath>\n#include <iostream>\n\nint main() {\n auto floats = thrust::host_vector<float>();\n auto ints = thrust::host_vector<int>();\n\n std::size_t size = 10000;\n\n floats.reserve(size);\n ints.reserve(size);\n\n for (std::size_t i = 0; i < size; ++i) {\n floats.push_back(i);\n ints.push_back(i);\n }\n\n auto event = Double(floats, ints);\n\n event.wait();\n\n for (std::size_t i = 0; i < size; ++i) {\n assert(std::abs(floats[i] - i * i) < 1e-5);\n assert(ints[i] == static_cast<int>(i * i));\n }\n std::cout << \"Success!\\n\";\n\n return 0;\n}\n
\u4e00\u822c\u306b\u975e\u540c\u671f\u5b9f\u884c\u3068\u3044\u3046\u3068\u8eab\u69cb\u3048\u308b\u65b9\u304c\u591a\u3044\u3068\u601d\u308f\u308c\u307e\u3059\u304c\u3001\u4e0a\u306e\u89e3\u8aac\u3092\u898b\u308b\u3068\u610f\u5916\u3068\u7c21\u5358\u306b\u3067\u304d\u308b\u3068\u601d\u308f\u308c\u305f\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002 \u307e\u305f\u3001\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3067\u5b9f\u884c\u9806\u5e8f\u3092\u6307\u5b9a\u3067\u304d\u308b\u306e\u3082\u9b45\u529b\u7684\u3067\u3059\u3002
\u975e\u540c\u671f\u51e6\u7406\u306e\u5229\u70b9\u3068\u3044\u3046\u3088\u308aThrust\u3092\u4f7f\u3046\u5229\u70b9\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u5b9f\u306frocThrust\u3068\u3044\u3046\u3001CUDA\u3092HIP\u3068ROCm\u306b\u7f6e\u304d\u63db\u3048\u305fThrust\u3092AMD\u304c\u958b\u767a\u3057\u3066\u3044\u307e\u3059\u3002 \u73fe\u6642\u70b9\u3067\u306f\u3001Thrust 1.17.2\u307e\u3067\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u975e\u540c\u671f\u5b9f\u884c\u3082\u3067\u304d\u307e\u3059\u3002 \u8a73\u3057\u304f\u306f\u53c2\u8003\u6587\u732e4\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002
\u6b8b\u5ff5\u306a\u304c\u3089\u6b20\u70b9\u304c\u3042\u308a\u307e\u3059\u3002 1\u3064\u76ee\u306e\u6b20\u70b9\u306fCUDA\u304c\u30c7\u30d0\u30a4\u30b9\u306e\u6642\u304b\u3064\u30c7\u30d0\u30a4\u30b9\u5074\u3067\u3057\u304b\u4f7f\u3048\u306a\u3044\u3053\u3068\u3067\u3059\u3002 Thrust\u306foneTBB\u3092\u30c7\u30d0\u30a4\u30b9\u3068\u3057\u3066\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u304c\u3001\u975e\u540c\u671f\u51e6\u7406\u306foneTBB\u3067\u306f\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002 \u30b7\u30ea\u30a2\u30eb\u3084OpenMP\u3082\u540c\u69d8\u3067\u3059\u3002 \u300cevent\u3068future\u300d\u7bc0\u3067\u89e6\u308c\u307e\u3057\u305f\u304c\u3001\u3053\u308c\u304chost_event\u304c\u306a\u3044\u7406\u7531\u3060\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002 \u3057\u304b\u3057\u3001\u3053\u306e\u6b20\u70b9\u306f\u3055\u307b\u3069\u554f\u984c\u306b\u306a\u3089\u306a\u3044\u3067\u3057\u3087\u3046\u3002
2\u3064\u76ee\u306e\u6b20\u70b9\u306fasync::copy\u304c\u8ee2\u9001\u3059\u308b\u30c7\u30fc\u30bf\u306e\u578b\u306b\u5bfe\u3057\u3066trivially relocatable\u3067\u3042\u308b\u3053\u3068\u3092\u8981\u6c42\u3057\u3066\u3044\u308b\u3053\u3068\u3067\u3059\u3002 trivially relocatable\u306a\u578b\u3068\u306f\u3001\u7c21\u5358\u306b\u8a00\u3046\u3068\u30b3\u30d4\u30fc\u3068\u30e0\u30fc\u30d6\u3001\u7834\u68c4\u304cdefault\u3067\u51fa\u6765\u3066\u3001\u4eee\u60f3\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u4eee\u60f3\u7d99\u627f\u3092\u6301\u305f\u305a\u3001\u5168\u3066\u306e\u30e1\u30f3\u30d0\u5909\u6570\u3068\u57fa\u5e95\u30af\u30e9\u30b9\u3082trivially relocatable\u306a\u578b\u3067\u3059\u3002 \u3053\u308c\u306fmemcpy\u3067\u30db\u30b9\u30c8\u3068\u30c7\u30d0\u30a4\u30b9\u9593\u3067\u30c7\u30fc\u30bf\u8ee2\u9001\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u5c0e\u5165\u3055\u308c\u307e\u3057\u305f\u3002 Thrust\u3067\u306f\u3001THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE\u30de\u30af\u30ed\u95a2\u6570\u3092\u4f7f\u3063\u3066\u3001\u4e0e\u3048\u305f\u578b\u304ctrivially relocatable\u3067\u3042\u308b\u3068\u5ba3\u8a00\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u5236\u7d04\u304c\u5f37\u3044\u3082\u306e\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306f\u5411\u4e0a\u3057\u3001\u79c1\u304c\u884c\u3063\u305f\u5b9f\u9a13\u3067\u306f\u305d\u3046\u3067\u306a\u3044\u3082\u306e\u306b\u6bd4\u3079\u3066\u5b9f\u884c\u6642\u9593\u304c\u7d0430%\u6e1b\u3063\u3066\u3044\u307e\u3059\u3002 \u8a73\u3057\u304f\u306f\u53c2\u8003\u6587\u732e5\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002
async::copy
memcpy
THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE
Thrust\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u3054\u89a7\u306b\u306a\u308b\u3068\u308f\u304b\u308b\u306e\u3067\u3059\u304c\u3001\u306a\u3093\u3068\u30a2\u30fc\u30ab\u30a4\u30d6\u306b\u3055\u308c\u3066\u307e\u3059\u3002 \u3069\u3046\u3084\u3089\u534a\u5e74\u524d\u304b\u3089CCCL\u3068\u3044\u3046\u3001CUB\u3068libcudacxx\u3082\u4e00\u7dd2\u306b\u3057\u305f\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u79fb\u3063\u305f\u3088\u3046\u3067\u3059\u3002 \u3053\u306e\u3053\u3068\u306b\u6c17\u3065\u3044\u305f\u306e\u304c\u4e00\u6628\u65e5\u3060\u3063\u305f\u306e\u3067\u3001\u6628\u65e5CCCL\u3067\u3082\u30d3\u30eb\u30c9\u3067\u304d\u308b\u304b\u8a66\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u4e0a\u8ff0\u306e\u3084\u308a\u65b9\u3067\u306f\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002 \u3069\u3046\u306b\u304b\u89e3\u6c7a\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u6642\u9593\u3082\u306a\u304b\u3063\u305f\u306e\u3067\u3068\u308a\u3042\u3048\u305aThrust\u306b\u5bfe\u3057\u3066\u66f8\u304d\u307e\u3057\u305f\u3002 \u3082\u3057\u3054\u5b58\u3058\u306e\u65b9\u304c\u3044\u3089\u3063\u3057\u3083\u3063\u305f\u3089\u3001\u6559\u3048\u3066\u3044\u305f\u3060\u3051\u308b\u3068\u5e78\u3044\u3067\u3059\u3002
\u30c7\u30fc\u30bf\u304ctrivially relocatable\u306a\u578b\u306a\u3089\u3001\u304a\u624b\u8efd\u306b\u975e\u540c\u671f\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002
GitHub\u306b\u7f6e\u3044\u3066\u3044\u307e\u3059\u3002
Thrust\u3092\u4f7f\u3046\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u7c21\u5358\u306b\u7ffb\u8a33\u3059\u308b\u3002
Thrust\u3068\u306fSTL\u306b\u57fa\u3065\u3044\u305f\u3001CUDA\u306e\u305f\u3081\u306eC++\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3042\u308b\u3002 Thrust\u306b\u3088\u3063\u3066\u3001CUDA C\u3068\u5b8c\u5168\u306a\u4e92\u63db\u6027\u304c\u3042\u308b\u9ad8\u6c34\u6e96\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u901a\u3057\u3066\u3001\u6700\u5c0f\u9650\u306e\u52b4\u529b\u3067\u9ad8\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306a\u4e26\u5217\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002
CUDA\u30c4\u30fc\u30eb\u30ad\u30c3\u30c8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u3001Thrust\u306e\u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb\u3082\u6a19\u6e96\u306eCUDA\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\u3055\u308c\u308b\u3002 Thrust\u306f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u306e\u3067\u3001\u3053\u308c\u4ee5\u4e0a\u3059\u308b\u3053\u3068\u306f\u306a\u3044\u3002
Thrust\u306f2\u3064\u306evector\u30b3\u30f3\u30c6\u30ca\u3001host_vector\u3068device_vector\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3002 \u540d\u524d\u304c\u793a\u3059\u3088\u3046\u306b\u3001device_vector\u306fGPU\u306e\u30e1\u30e2\u30ea\u306b\u3042\u308b\u4e00\u65b9\u3067\u3001host_vector\u306f\u30db\u30b9\u30c8\u30e1\u30e2\u30ea\u306b\u4fdd\u5b58\u3055\u308c\u308b\u3002 Thrust\u306evector\u30b3\u30f3\u30c6\u30ca\u306fstd::vector\u306b\u4f3c\u3066\u3044\u308b\u3002 std::vector\u306e\u3088\u3046\u306b\u3001host_vector\u3068device_vector\u306f\u52d5\u7684\u306b\u30b5\u30a4\u30ba\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3001\u30b8\u30a7\u30cd\u30ea\u30c3\u30af\u30b3\u30f3\u30c6\u30ca(\u4efb\u610f\u306e\u30c7\u30fc\u30bf\u578b\u3092\u6301\u3066\u308b)\u3067\u3042\u308b\u3002 \u4ee5\u4e0b\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306fThrust\u306evector\u30b3\u30f3\u30c6\u30ca\u306e\u4f7f\u3044\u65b9\u3092\u793a\u3059\u3002
std::vector
#include <thrust/host_vector.h>\n#include <thrust/device_vector.h>\n\n#include <iostream>\n\nint main(void)\n{\n // H has storage for 4 integers\n thrust::host_vector<int> H(4);\n\n // initialize individual elements\n H[0] = 14;\n H[1] = 20;\n H[2] = 38;\n H[3] = 46;\n\n // H.size() returns the size of vector H\n std::cout << \"H has size \" << H.size() << std::endl;\n\n // print contents of H\n for(int i = 0; i < H.size(); i++)\n std::cout << \"H[\" << i << \"] = \" << H[i] << std::endl;\n\n // resize H\n H.resize(2);\n\n std::cout << \"H now has size \" << H.size() << std::endl;\n\n // Copy host_vector H to device_vector D\n thrust::device_vector<int> D = H;\n\n // elements of D can be modified\n D[0] = 99;\n D[1] = 88;\n\n // print contents of D\n for(int i = 0; i < D.size(); i++)\n std::cout << \"D[\" << i << \"] = \" << D[i] << std::endl;\n\n // H and D are automatically deleted when the function returns\n return 0;\n}\n
\u3053\u306e\u4f8b\u304c\u793a\u3059\u3088\u3046\u306b\u3001=\u6f14\u7b97\u5b50\u306fhost_vector\u304b\u3089device_vector\u3078\u30b3\u30d4\u30fc\u3059\u308b\u305f\u3081\u306b\u4f7f\u308f\u308c\u308b(\u9006\u3082\u540c\u69d8)\u3002 \u3082\u3061\u308d\u3093\u3001host_vector\u540c\u58eb\u3084device_vector\u540c\u58eb\u3067\u30b3\u30d4\u30fc\u3059\u308b\u305f\u3081\u306b\u3082\u4f7f\u308f\u308c\u308b\u3002 \u307e\u305f\u3001device_vector\u306e\u500b\u3005\u306e\u8981\u7d20\u306f\u5927\u304b\u3063\u3053\u3092\u4f7f\u3063\u3066\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u304c\u3001\u5404\u30a2\u30af\u30bb\u30b9\u306fcudaMemcpy\u3092\u547c\u3073\u51fa\u3059\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3001\u51fa\u6765\u308b\u9650\u308a\u4f7f\u308f\u306a\u3044\u65b9\u304c\u826f\u3044\u3002
=
cudaMemcpy
\u7279\u5b9a\u306e\u5024\u3067vector\u306e\u3059\u3079\u3066\u306e\u8981\u7d20\u3092\u521d\u671f\u5316\u3057\u305f\u308a\u3001\u3042\u308bvector\u306e\u3042\u308b\u5024\u306e\u96c6\u5408\u3092\u5225\u306evector\u306b\u30b3\u30d4\u30fc\u3060\u3051\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u4fbf\u5229\u306a\u3053\u3068\u304c\u591a\u3044\u3002 Thrust\u306f\u3053\u308c\u3089\u306e\u64cd\u4f5c\u3092\u884c\u3046\u3044\u304f\u3064\u304b\u306e\u65b9\u6cd5\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3002
#include <thrust/host_vector.h>\n#include <thrust/device_vector.h>\n\n#include <thrust/copy.h>\n#include <thrust/fill.h>\n#include <thrust/sequence.h>\n\n#include <iostream>\n\nint main(void)\n{\n // initialize all ten integers of a device_vector to 1\n thrust::device_vector<int> D(10, 1);\n\n // set the first seven elements of a vector to 9\n thrust::fill(D.begin(), D.begin() + 7, 9);\n\n // initialize a host_vector with the first five elements of D\n thrust::host_vector<int> H(D.begin(), D.begin() + 5);\n\n // set the elements of H to 0, 1, 2, 3, ...\n thrust::sequence(H.begin(), H.end());\n\n // copy all of H back to the beginning of D\n thrust::copy(H.begin(), H.end(), D.begin());\n\n // print D\n for(int i = 0; i < D.size(); i++)\n std::cout << \"D[\" << i << \"] = \" << D[i] << std::endl;\n\n return 0;\n}\n
copy\u95a2\u6570\u306f\u30db\u30b9\u30c8\u304b\u30c7\u30d0\u30a4\u30b9\u306e\u8981\u7d20\u306e\u7bc4\u56f2\u3092\u5225\u306e\u30db\u30b9\u30c8\u304b\u30c7\u30d0\u30a4\u30b9\u306evector\u306b\u30b3\u30d4\u30fc\u3059\u308b\u3002 thrust::fill\u95a2\u6570\u306f\u5358\u306b\u7bc4\u56f2\u5185\u306e\u8981\u7d20\u306b\u7279\u5b9a\u306e\u5024\u3092\u5165\u308c\u308b\u3002 sequence\u95a2\u6570\u306f\u7b49\u9593\u9694\u306e\u5024\u306e\u5217\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3002
thrust::fill
sequence
Thrust\u306e\u540d\u524d\u7a7a\u9593\u306fthrust\u3002
thrust
\u751f\u306e\u30dd\u30a4\u30f3\u30bf\u30fc\u3092Thrust\u306e\u95a2\u6570\u306b\u5f15\u6570\u3068\u3057\u3066\u6e21\u3059\u3053\u3068\u3082\u3067\u304d\u308b\u3002 \u305f\u3060\u3057\u3001\u30c7\u30d0\u30a4\u30b9\u30e1\u30e2\u30ea\u3078\u306e\u30dd\u30a4\u30f3\u30bf\u30fc\u306fthrust::device_ptr\u3067\u5305\u307e\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002 \u4f8b\u3048\u3070\u3001
thrust::device_ptr
size_t N = 10;\n\n// raw pointer to device memory\nint * raw_ptr;\ncudaMalloc((void **) &raw_ptr, N * sizeof(int));\n\n// wrap raw pointer with a device_ptr\nthrust::device_ptr<int> dev_ptr(raw_ptr);\n\n// use device_ptr in thrust algorithms\nthrust::fill(dev_ptr, dev_ptr + N, (int) 0);\n
device_ptr\u304b\u3089\u751f\u306e\u30dd\u30a4\u30f3\u30bf\u3092\u53d6\u308a\u51fa\u3059\u306b\u306f\u3001raw_pointer_cast\u3092\u4f7f\u3046\u3079\u304d\u3060\u3002
device_ptr
raw_pointer_cast
size_t N = 10;\n\n// create a device_ptr\nthrust::device_ptr<int> dev_ptr = thrust::device_malloc<int>(N);\n\n// extract raw pointer from device_ptr\nint * raw_ptr = thrust::raw_pointer_cast(dev_ptr);\n
\u30a4\u30c6\u30ec\u30fc\u30bf\u3068\u30dd\u30a4\u30f3\u30bf\u3092\u533a\u5225\u3059\u308b\u3082\u3046\u4e00\u3064\u306e\u7406\u7531\u306f\u3001\u30a4\u30c6\u30ec\u30fc\u30bf\u306f\u591a\u304f\u306e\u7a2e\u985e\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u3092\u6a2a\u65ad\u3059\u308b\u305f\u3081\u306b\u4f7f\u3048\u308b\u304b\u3089\u3067\u3042\u308b\u3002 \u4f8b\u3048\u3070\u3001STL\u306f\u53cc\u65b9\u5411\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u63d0\u4f9b\u3059\u308b\u30ea\u30f3\u30af\u30ea\u30b9\u30c8\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3002 Thrust\u306f\u305d\u306e\u3088\u3046\u306a\u30b3\u30f3\u30c6\u30ca\u306e\u30c7\u30d0\u30a4\u30b9\u306e\u5b9f\u88c5\u306f\u63d0\u4f9b\u3057\u3066\u3044\u306a\u3044\u304c\u3001\u305d\u308c\u3089\u3068\u4e92\u63db\u6027\u304c\u3042\u308b\u3002
#include <thrust/device_vector.h>\n#include <thrust/copy.h>\n#include <list>\n#include <vector>\n\nint main(void)\n{\n // create an STL list with 4 values\n std::list<int> stl_list;\n\n stl_list.push_back(10);\n stl_list.push_back(20);\n stl_list.push_back(30);\n stl_list.push_back(40);\n\n // initialize a device_vector with the list\n thrust::device_vector<int> D(stl_list.begin(), stl_list.end());\n\n // copy a device_vector into an STL vector\n std::vector<int> stl_vector(D.size());\n thrust::copy(D.begin(), D.end(), stl_vector.begin());\n\n return 0;\n}\n
Thrust\u306fcounting_iterator\u3084zip_iterator\u3068\u3044\u3063\u305f\u3001\u88c5\u98fe\u7684\u306a\u30a4\u30c6\u30ec\u30fc\u30bf\u306e\u96c6\u307e\u308a\u3082\u63d0\u4f9b\u3059\u308b\u3002
counting_iterator
zip_iterator
Thrust\u306f\u305f\u304f\u3055\u3093\u306e\u3042\u308a\u3075\u308c\u305f\u4e26\u5217\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3002 \u3053\u308c\u3089\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e\u591a\u304f\u306fSTL\u306e\u76f4\u63a5\u7684\u306a\u985e\u4f3c\u3092\u6301\u3061\u3001\u540c\u3058STL\u95a2\u6570\u304c\u5b58\u5728\u3059\u308b\u6642\u306f\u540c\u3058\u540d\u524d\u3092\u4f7f\u3046(\u4f8b: thrust::sort\u3068std::sort)\u3002
thrust::sort
std::sort
Thrust\u306e\u5168\u3066\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306f\u30db\u30b9\u30c8\u3068\u30c7\u30d0\u30a4\u30b9\u306e\u4e21\u65b9\u306b\u5bfe\u3059\u308b\u5b9f\u88c5\u3092\u6301\u3064\u3002 \u7279\u306b\u3001Thrust\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304c\u30db\u30b9\u30c8\u30a4\u30c6\u30ec\u30fc\u30bf\u3068\u4e00\u7dd2\u306b\u547c\u3073\u51fa\u3055\u308c\u305f\u6642\u3001\u30db\u30b9\u30c8\u30d1\u30b9\u304c\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\u3055\u308c\u308b\u3002 \u540c\u69d8\u306b\u3001\u30c7\u30d0\u30a4\u30b9\u30a4\u30c6\u30ec\u30fc\u30bf\u304c\u7bc4\u56f2\u3092\u5b9a\u7fa9\u3059\u308b\u305f\u3081\u306b\u4f7f\u308f\u308c\u3066\u3044\u308b\u6642\u3001\u30c7\u30d0\u30a4\u30b9\u306e\u5b9f\u88c5\u304c\u547c\u3070\u308c\u308b\u3002
\u30db\u30b9\u30c8\u3068\u30c7\u30d0\u30a4\u30b9\u9593\u3067\u30c7\u30fc\u30bf\u3092\u30b3\u30d4\u30fc\u3067\u304d\u308bthrust::copy\u3068\u3044\u3046\u4f8b\u5916\u306f\u3042\u308b\u304c\u3001Thrust\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3078\u306e\u5168\u3066\u306e\u30a4\u30c6\u30ec\u30fc\u30bf\u306e\u5f15\u6570\u306f\u540c\u3058\u5834\u6240(\u5168\u3066\u30db\u30b9\u30c8\u4e0a\u304b\u5168\u3066\u30c7\u30d0\u30a4\u30b9\u4e0a)\u306b\u3042\u308b\u3079\u304d\u3060\u3002 \u3053\u306e\u8981\u4ef6\u3092\u7834\u3063\u305f\u6642\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u4f5c\u3089\u308c\u308b\u3002
\u5b8c\u5168\u306a\u30ea\u30b9\u30c8\u306f\u3053\u3053\u3002
\u4ee5\u4e0b\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u3044\u304f\u3064\u304b\u306e\u5909\u5f62\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u793a\u3057\u3066\u3044\u308b\u3002 thrust::negate\u3084thrust::modulus\u306a\u3069\u306e\u3042\u308a\u3075\u308c\u305ffunctor\u306fthrust/functional.h\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u3002
thrust::negate
thrust::modulus
thrust/functional.h
#include <thrust/device_vector.h>\n#include <thrust/transform.h>\n#include <thrust/sequence.h>\n#include <thrust/copy.h>\n#include <thrust/fill.h>\n#include <thrust/replace.h>\n#include <thrust/functional.h>\n#include <iostream>\n\nint main(void)\n{\n // allocate three device_vectors with 10 elements\n thrust::device_vector<int> X(10);\n thrust::device_vector<int> Y(10);\n thrust::device_vector<int> Z(10);\n\n // initialize X to 0,1,2,3, ....\n thrust::sequence(X.begin(), X.end());\n\n // compute Y = -X\n thrust::transform(X.begin(), X.end(), Y.begin(), thrust::negate<int>());\n\n // fill Z with twos\n thrust::fill(Z.begin(), Z.end(), 2);\n\n // compute Y = X mod 2\n thrust::transform(X.begin(), X.end(), Z.begin(), Y.begin(), thrust::modulus<int>());\n\n // replace all the ones in Y with tens\n thrust::replace(Y.begin(), Y.end(), 1, 10);\n\n // print Y\n thrust::copy(Y.begin(), Y.end(), std::ostream_iterator<int>(std::cout, \"\\n\"));\n\n return 0;\n}\n
SAXPY\u306e\u5b9f\u88c5\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u3042\u308b\u304c\u3001\u7701\u7565\u3002
functor\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4f5c\u6210\u3067\u304d\u308b\u3002
struct saxpy_functor\n{\n const float a;\n\n saxpy_functor(float _a) : a(_a) {}\n\n __host__ __device__\n float operator()(const float& x, const float& y) const {\n return a * x + y;\n }\n};\n
\u8907\u96d1\u306a\u8a08\u7b97\u306f\u3001\u7c21\u5358\u306a\u8a08\u7b97\u306b\u5206\u89e3\u3057\u3066\u4f55\u56de\u304b\u306b\u5206\u3051\u3066\u5168\u4f53\u3092\u8a08\u7b97\u3059\u308b\u3088\u308a\u3001\u8907\u96d1\u306a\u8a08\u7b97\u30921\u56de\u3067\u307e\u3068\u3081\u3066\u5168\u4f53\u3092\u8a08\u7b97\u3059\u308b\u307b\u3046\u304c\u65e9\u3044\u3002 \u4f8b\u3048\u3070\u3001\u914d\u5217a, b, x\u306b\u5bfe\u3057\u3066\u3001a * x + b\u3092\u8a08\u7b97\u3059\u308b\u306a\u3089\u3001a * x\u3092\u8a08\u7b97\u3057\u3066b\u3092\u8db3\u3059\u3088\u308aa[i] * x[i] + b[i]\u3092\u8a08\u7b97\u3059\u308b\u307b\u3046\u304c\u65e9\u3044\u3002
a
b
x
a * x + b
a * x
a[i] * x[i] + b[i]
thrust::transform\u306f1\u3064\u304b2\u3064\u306e\u5165\u529b\u5f15\u6570\u3057\u304b\u6301\u305f\u306a\u3044\u304c\u3001\u3053\u306e\u4f8b\u3092\u4f7f\u3046\u30682\u3064\u3088\u308a\u591a\u3044\u5165\u529b\u3067\u30821\u56de\u3067\u51fa\u6765\u308b\u3002
thrust::transform
\u7279\u306b\u6c17\u3092\u4ed8\u3051\u308b\u3053\u3068\u306f\u306a\u3044\u3002 \u8a73\u7d30\u306f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3002