Part 1
요약·해설
DIGITS_NUM·THREADS_NUM·CONFIG_MP_MAX_NUM_CPUS 조정과 qemu_x86_64 실행 결과를 설명합니다.
DIGITS_NUM
THREADS_NUM
CONFIG_MP_MAX_NUM_CPUS
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
ACDAD74F013125E864EA210510E0683A114283BA28D1A14FC40D9EA60966E9F0
.. _smp_pi:
SMP Pi
###########
Overview
********
This sample application calculates Pi independently in many threads, and
demonstrates the benefit of multiple execution units (CPU cores)
when compute-intensive tasks can be run in parallel, with
no cross-dependencies or shared resources.
By changing the value of CONFIG_MP_MAX_NUM_CPUS on SMP systems, you
can see that using more cores takes almost linearly less time
to complete the computational task.
You can also edit the sample source code to change the
number of digits calculated (``DIGITS_NUM``), and the
number of threads to use (``THREADS_NUM``).
Building and Running
********************
This project outputs Pi values calculated by each thread and in the end total time
required for all the calculation to be done. It can be built and executed
on Synopsys ARC HSDK board as follows:
.. zephyr-app-commands::
:zephyr-app: samples/arch/smp/pi
:host-os: unix
:board: qemu_x86_64
:goals: run
:compact:
Sample Output
=============
.. code-block:: console
Calculate first 240 digits of Pi independently by 16 threads.
Pi value calculated by thread #0: 3141592653589793238462643383279502884197...
Pi value calculated by thread #1: 3141592653589793238462643383279502884197...
...
Pi value calculated by thread #14: 314159265358979323846264338327950288419...
Pi value calculated by thread #15: 314159265358979323846264338327950288419...
All 16 threads executed by 4 cores in 28 msec
Part 3
한국어 전문 번역
개요
이 sample application은 여러 thread에서 각각 독립적으로 원주율 Pi를 계산합니다. Cross-dependency나 shared resource가 없어 compute-intensive task를 병렬로 실행할 수 있을 때 여러 execution unit(CPU core)이 주는 이점을 보여줍니다.
SMP system에서 CONFIG_MP_MAX_NUM_CPUS 값을 바꾸면 core를 더 많이 사용할수록 계산 완료 시간이 거의 선형으로 줄어드는 것을 확인할 수 있습니다.
Sample source code에서 계산할 자릿수 DIGITS_NUM과 사용할 thread 수 THREADS_NUM도 변경할 수 있습니다.
Build와 실행
이 project는 각 thread가 계산한 Pi 값과 모든 계산을 마치는 데 걸린 전체 시간을 출력합니다. 다음 명령으로 qemu_x86_64에서 build하고 실행합니다.
west build -b qemu_x86_64 samples/arch/smp/pi
west build -t run
Sample 출력
Calculate first 240 digits of Pi independently by 16 threads.
Pi value calculated by thread #0: 3141592653589793238462643383279502884197...
Pi value calculated by thread #1: 3141592653589793238462643383279502884197...
...
Pi value calculated by thread #14: 314159265358979323846264338327950288419...
Pi value calculated by thread #15: 314159265358979323846264338327950288419...
All 16 threads executed by 4 cores in 28 msec
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.