CUDAMemoryLoad[list]
list をCUDALink メモリマネージャに登録する.
CUDAMemoryLoad[img]
img をCUDALink メモリマネージャに登録する.
CUDAMemoryLoad
CUDAMemoryLoad[list]
list をCUDALink メモリマネージャに登録する.
CUDAMemoryLoad[img]
img をCUDALink メモリマネージャに登録する.
詳細とオプション
- CUDALink パッケージがNeeds["CUDALink`"]でロードされていなければならない.
- CUDAMemoryLoad使える型:
-
Integer Real Complex "Byte" "Bit16" "Integer" "Byte[2]" "Bit16[2]" "Integer32[2]" "Byte[3]" "Bit16[3]" "Integer32[3]" "Byte[4]" "Bit16[4]" "Integer32[4]" "UnsignedByte" "UnsignedBit16" "UnsignedInteger" "UnsignedByte[2]" "UnsignedBit16[2]" "UnsignedInteger[2]" "UnsignedByte[3]" "UnsignedBit16[3]" "UnsignedInteger[3]" "UnsignedByte[4]" "UnsignedBit16[4]" "UnsignedInteger[4]" "Double" "Float" "Integer64" "Double[2]" "Float[2]" "Integer64[2]" "Double[3]" "Float[3]" "Integer64[3]" "Double[4]" "Float[4]" "Integer64[4]" - 以下のオプションが与えられる:
-
"Device" $CUDADevice CUDA計算に使われるデバイス "TargetPrecision" Automatic 計算に使用する精度
例題
すべて開く すべて閉じる例 (1)
Needs["CUDALink`"]mem = CUDAMemoryLoad[{1, 2, 3}]CUDAMemoryInformationを使うとメモリについての情報が取り出せる:
CUDAMemoryInformation[mem]加えられたメモリはCUDAMemoryUnloadで解放しなければならない:
CUDAMemoryUnload[mem]スコープ (4)
RealあるいはComplexとしてメモリを加えると,デバイスが倍精度をサポートしているかどうかに基づいた型が返される:
CUDAMemoryLoad[{1.0, 2.0, 3.0}, Real]CUDAInformation[$CUDADevice, "Compute Capabilities"]"TargetPrecision"を設定すると,動作の変更を強制することができる:
CUDAMemoryLoad[{1.0, 2.0, 3.0}, Real, "TargetPrecision" -> "Single"]加えられたメモリはCUDAMemoryUnloadで解放しなければならない:
CUDAMemoryUnload[%]画像を"UnsignedByte"型として加えることができる:
mem = CUDAMemoryLoad[[image]]メモリを取り出すと,もとの画像と同じ特性の画像が返される.メモリはCUDAMemoryGetを使って取り出せる:
CUDAMemoryGet[mem]CUDAMemoryInformation[mem]加えられたメモリはCUDAMemoryUnloadで解放しなければならない:
CUDAMemoryUnload[mem]CUDAMemoryLoad[[image], "Float"]CUDAMemoryGet[%]グラフィックスオブジェクトを加えると,オブジェクトはラスタライズされる:
mem = CUDAMemoryLoad[\!\(\*Graphics3DBox[«5»]\)]CUDAMemoryGet[mem]//Head加えられたメモリはCUDAMemoryUnloadで解放しなければならない:
CUDAMemoryUnload[mem]オプション (1)
"TargetPrecision" (1)
RealあるいはComplexとしてメモリを加えると,デバイスが倍精度をサポートしているかどうかに基づいた型が返される:
CUDAMemoryLoad[{1.0, 2.0, 3.0}, Real]これは"TargetPrecision"オプションを"Single"か"Double"に設定すると変更することができる.この例の場合,マシンには倍精度ハードウェアがあるが"TargetPrecision"が単精度なので,"Float"が使われる:
CUDAMemoryLoad[{1.0, 2.0, 3.0}, Real, "TargetPrecision" -> "Single"]常に単精度型なら,型を"Float"または"ComplexFloat"に設定するとさらに分かりやすい:
CUDAMemoryLoad[{1.0, 2.0, 3.0}, "Float"]アプリケーション (2)
srcf = FileNameJoin[{$CUDALinkPath, "SupportFiles", "addTwo.cu"}]addTwo = CUDAFunctionLoad[{srcf}, "addTwo", {{_Integer}, _Integer}, 32]res = addTwo[CUDAMemoryLoad[Range[100]], 100]CUDAMemoryGet[First@res]CUDAMemoryUnload[First@res]CUDAFunctionを実行すると,内部的にメモリがロード,アンロード(入力がCUDAMemoryでない場合は)される. 入力画像の色を反転する:
src = "__global__ void imageColorNegate(mint * img, mint width, mint height, mint channels) {
mint ii;
mint xIndex = threadIdx.x + blockIdx.x*blockDim.x;
mint yIndex = threadIdx.y + blockIdx.y*blockDim.y;
mint index = channels*(xIndex + yIndex*width);
if (xIndex < width && yIndex < height) {
for (ii = 0; ii < channels; ii++)
img[index+ii] = 255 - img[index+ii];
}
}";CUDAFunctionLoadを使って関数をロードする:
colorNegate = CUDAFunctionLoad[src, "imageColorNegate", {{_Integer}, _Integer, _Integer, _Integer}, {16, 16}]{height, width} = ImageDimensions[[image]]
channels = ImageChannels[[image]]CUDAFunctionを実行する:
colorNegate[[image], width, height, channels]テクニカルノート
-
▪
- CUDALink ユーザガイド ▪
- メモリ ▪
- CUDAプログラミング
関連するガイド
-
▪
- CUDALink
テキスト
Wolfram Research (2010), CUDAMemoryLoad, Wolfram言語関数, https://reference.wolfram.com/language/CUDALink/ref/CUDAMemoryLoad.html.
CMS
Wolfram Language. 2010. "CUDAMemoryLoad." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/CUDALink/ref/CUDAMemoryLoad.html.
APA
Wolfram Language. (2010). CUDAMemoryLoad. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/CUDALink/ref/CUDAMemoryLoad.html
BibTeX
@misc{reference.wolfram_2026_cudamemoryload, author="Wolfram Research", title="{CUDAMemoryLoad}", year="2010", howpublished="\url{https://reference.wolfram.com/language/CUDALink/ref/CUDAMemoryLoad.html}", note=[Accessed: 18-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_cudamemoryload, organization={Wolfram Research}, title={CUDAMemoryLoad}, year={2010}, url={https://reference.wolfram.com/language/CUDALink/ref/CUDAMemoryLoad.html}, note=[Accessed: 18-August-2026]}