hyper threading ใน Mathematica

ปกติถ้าเราคำนวณแบบขนานใน Mathematica มันจะมีการส่งข้อมูลสำหรับการคำนวณระหว่าง cores ของ cpu กัน โดยจำนวนของ cores ที่พูดถึงนี้คือ physical cores ซึ่งสามารถดูได้จาก ตัวแปร $ProcessorCount และเวลาที่คำนวณแบบขนานด้วยคำสั่งเช่น ParallelEvaluate มันก็จะการโหลด kernels เท่ากับจำนวน $ProcessorCount นี้แต่ถ้าอยากโหลดมากกว่านี้ก็สามารถทำได้โดยใช้คำสั่ง LaunchKernels ครับ แต่ Mathematica เองก็ใช้ประโยชน์ multiple threads ภายใน kernel ในหลายคำสั่งโดยเฉพาะพวก image processing หรืออย่าง Compile ซึ่งเราสามารถที่จะบอกจำนวนที่ thread ที่จะใช้ได้โดย option อย่าง ParalleThreadNumber

SystemOptions["ParallelOptions" -> "ParallelThreadNumber"]

และอย่างจำนวน threads ที่ MKL ใช้

SystemOptions["ParallelOptions" -> "MKLThreadNumber"]

แต่ก็ต้องคอยระวังว่า จำนวนthreadสำหรับ MKL ไม่ควรมากกว่าจำนวน physical cores ครับ

Leave a Reply

%d bloggers like this: