Skip to Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
16.10 運算核心間共享資料
|
659
16.10 運算核心間共享資料
問題點
你的平行運算實作需要在各運算核心之間經由共享變數互相溝通。
解決方案
Mathematica 提供
SetSharedVariable
指令可在各運算核心之間同步變數定義;同樣地,
SetSharedFunction
指令則可同步符號的 downvalue。以下範例中,
list
變數是各運算
核心共享的,且每一核心都可以加入其
$KernelID
值。
討論說明
假設你正在解組合最佳化的問題,如旅行推銷員問題(traveling salesperson problem,
TSP),可能會希望每個核心都可知道目前最佳解,以避免重複計算。以下是 TSP 問題
的一種解法,使用的是模擬退火演算法。[Page-663]
16.11  於多核心運行時避免競態條件
(Race Condition)
問題點
在 Mathematica 第 7 版之前,使用者不必擔心競態條件等問題,因為所有的處理程序都
在單一執行緒下進行;在進入平行處理的領域後,由於各核心均會存取共享檔案及變
數,而導致某些微妙錯誤可能出現,除非經過特別處理,否則共享資源的同步性容易發
生問題。
ch16.indd 659 2014/4/2 下午 04:11:10
660
|
第十六章
解
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Mathematica Cookbook

Mathematica Cookbook

Sal Mangano
人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar

Publisher Resources

ISBN: 9789863470106