是诸如 ParallelTable 和 ParallelMap 的函数的 DistributedContexts 选项的默认值.
$DistributedContexts
是诸如 ParallelTable 和 ParallelMap 的函数的 DistributedContexts 选项的默认值.
更多信息
- 每次并行计算之前,在并行内核中计算的符号定义将自动分配给所有内核,只要这些符号属于 DistributedContexts 选项中给定的上下文.
- 初始值是 $DistributedContexts:=$Context,它在当前上下文中分配所有符号定义,但是不分配来自程序包的符号定义.
范例
打开所有单元 关闭所有单元基本范例 (1)
范围 (5)
remote[x_] := {$KernelID, x ^ 3}ParallelTable[remote[i], {i, 4}]$DistributedContexts = None;local[x_] := {$KernelID, x ^ 2}ParallelTable[local[i], {i, 4}]$DistributedContexts = Automatic;a`k := $KernelID
b`k := -$KernelIDParallelTable[{a`k, b`k}, {4}]$DistributedContexts = "a`";a`m := $KernelID
b`m := -$KernelIDParallelTable[{a`m, b`m}, {4}]$DistributedContexts := $Context属性和关系 (1)
找出所有当前正在使用 $DistributedContexts 的并行函数:
Select[Names["System`Parallel*"], MemberQ[Options[Symbol[#]], DistributedContexts :> $DistributedContexts]&]可能存在的问题 (1)
$DistributedContexts 的值不用在 Parallelize 中:
$DistributedContexts = None;local1[x_] := {$KernelID, x ^ 2}Parallelize[Table[local1[i], {i, 4}]]设置 Parallelize 的 DistributedContexts 选项值:
SetOptions[Parallelize, DistributedContexts -> None]local2[x_] := {$KernelID, x ^ 3}Parallelize[Table[local2[i], {i, 4}]]$DistributedContexts := $ContextSetOptions[Parallelize, DistributedContexts :> $Context]相关的工作流程
- 执行并行计算
文本
Wolfram Research (2010),$DistributedContexts,Wolfram 语言函数,https://reference.wolfram.com/language/ref/$DistributedContexts.html.
CMS
Wolfram 语言. 2010. "$DistributedContexts." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/$DistributedContexts.html.
APA
Wolfram 语言. (2010). $DistributedContexts. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/$DistributedContexts.html 年
BibTeX
@misc{reference.wolfram_2026_$distributedcontexts, author="Wolfram Research", title="{$DistributedContexts}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/$DistributedContexts.html}", note=[Accessed: 13-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_$distributedcontexts, organization={Wolfram Research}, title={$DistributedContexts}, year={2010}, url={https://reference.wolfram.com/language/ref/$DistributedContexts.html}, note=[Accessed: 13-August-2026]}