Files
2026-08-15 03:14:34 +09:00

3.8 KiB

Step 17: oneTBB ParallelFor Adapter

담당 역할과 필수 스킬

  • 담당 역할: implementation-agent
  • 필수 스킬: fesa-cpp-msvc-tdd
  • 모든 C++ build/test와 최종 VERIFY는 MSVC x64 Debug 기준으로 수행한다.

읽어야 할 파일

  • /AGENTS.md
  • /docs/ARCHITECTURE.md
  • /docs/ADR.md
  • /docs/linear-static-3d-euler-beam/implementation-plan.md
  • /include/fesa/core/status.hpp
  • /include/fesa/elements/euler_beam_3d.hpp
  • /src/fesa/elements/euler_beam_3d.cpp
  • /tests/unit/elements/euler_beam_3d_test.cpp
  • /cmake/FesaDependencies.cmake
  • /src/fesa/CMakeLists.txt
  • /tests/CMakeLists.txt

소유 파일

  • Create: /include/fesa/assembly/parallel_for.hpp
  • Create: /src/fesa/assembly/parallel_for.cpp
  • Create: /tests/unit/assembly/parallel_for_test.cpp
  • Modify: /src/fesa/CMakeLists.txt
  • Modify: /tests/CMakeLists.txt

작업

solver core에서 oneTBB header/type을 숨기는 element-local loop adapter를 구현하라.

class ParallelFor {
public:
    virtual ~ParallelFor() = default;
    virtual void execute(std::size_t count,
                         const std::function<void(std::size_t)>& body) const = 0;
};
class SerialParallelFor final : public ParallelFor { /* same contract */ };
class TbbParallelFor final : public ParallelFor { /* oneTBB implementation in .cpp */ };

각 index는 정확히 한 번 처리하고 count==0은 no-op이다. Element-local 결과는 호출자가 index-addressed storage에 기록해 scheduling과 무관한 ordering을 갖게 한다. Adapter는 전역 sparse matrix write나 reduction을 수행하지 않는다. Oversubscription 정책은 implementation comment와 test/implementation report에 남기고, 이 step에서 임의 global thread setting을 바꾸지 않는다.

Tests는 zero/one/many counts, exact-once, serial/TBB semantic equivalence, stable index-addressed output, exception propagation policy를 검증하고 ParallelFor regex로 등록한다.

Acceptance Criteria

cmake --build .harness/build --config Debug --target fesa_tests
ctest --test-dir .harness/build -C Debug -R ParallelFor --output-on-failure

RED 후 GREEN/VERIFY:

cmake -S . -B .harness/build -A x64 `
  -DFESA_GTEST_SOURCE_DIR=C:/git/googletest `
  "-DMKL_DIR=C:/Program Files (x86)/Intel/oneAPI/mkl/2026.1/lib/cmake/mkl" `
  "-DTBB_DIR=C:/Program Files (x86)/Intel/oneAPI/tbb/2023.1/lib/cmake/tbb" `
  "-DHDF5_DIR=C:/Program Files/HDF_Group/HDF5/2.1.1/cmake"
cmake --build .harness/build --config Debug
ctest --test-dir .harness/build -C Debug -R ParallelFor --output-on-failure
ctest --test-dir .harness/build -C Debug --show-only=json-v1
ctest --test-dir .harness/build -C Debug --output-on-failure
$leaks = rg -n "oneapi/tbb|tbb/" include/fesa
if ($LASTEXITCODE -eq 0) { throw "oneTBB API leaked into public headers:`n$leaks" }
if ($LASTEXITCODE -ne 1) { throw 'Public-header dependency scan failed' }

마지막 scan은 public header에서 no-match여야 한다.

검증 절차

  1. adapter conformance tests를 먼저 작성하고 RED를 확인한다.
  2. Serial과 oneTBB 최소 구현으로 GREEN을 만든다.
  3. public boundary scan과 전체 VERIFY를 실행한다.
  4. /docs/linear-static-3d-euler-beam/implementation-report.md의 Step 17 section에 실제 RED/GREEN/VERIFY command, exit code, 핵심 output과 변경 파일을 기록한다.
  5. Step 17을 completed로 갱신하고 deterministic-use contract를 summary에 기록한다.

금지사항

  • 전역 sparse storage에 병렬 write하지 마라. 이유: ordering/race는 Step 18이 통제한다.
  • TBB type/header를 public API에 노출하지 마라. 이유: adapter boundary 계약이다.
  • process-wide thread count를 임의 변경하지 마라. 이유: MKL/TBB policy가 불명확해진다.
  • 직접 commit하지 마라. 이유: Harness executor가 담당한다.