दो थ्रेड, एक कोर: simultaneous multithreading कैसे काम करती है
पृष्ठभूमि और उद्देश्य
- SMT को अपनाने की पृष्ठभूमि: प्रोसेसर संसाधनों के उपयोग को बढ़ाने के लिए इसे अपनाया गया। प्रोसेसर में सैकड़ों registers, कई load/store units और arithmetic units होते हैं। इन्हें बेहतर ढंग से उपयोग करने के लिए instruction-level parallelism (ILP) तकनीक का उपयोग किया जाता है।
- Instruction pipelining: instruction execution को कई चरणों में बाँटकर हर cycle में नए instructions को प्रोसेस किया जाता है। pipeline जितनी गहरी होगी, उतने अधिक instructions को parallel में प्रोसेस किया जा सकता है।
- Superscalar architecture: हर cycle में कई instructions issue किए जा सकते हैं। उदाहरण के लिए, आधुनिक Intel Core i7 प्रोसेसर हर cycle में 4 instructions issue कर सकते हैं।
- क्षैतिज और ऊर्ध्वाधर वेस्ट: जब पर्याप्त independent instructions नहीं मिलते, तब संसाधनों की बर्बादी होती है। क्षैतिज वेस्ट तब होता है जब प्रोसेसर पर्याप्त independent instructions नहीं ढूँढ पाता, और ऊर्ध्वाधर वेस्ट तब होता है जब सभी instructions वर्तमान में चल रहे instruction पर निर्भर होते हैं।
Intel प्रोसेसर में SMT का implementation
- Architectural state replication: दो थ्रेड्स को एक साथ चलाने के लिए प्रोसेसर की architectural state को replicate किया जाता है। इससे एक physical processor operating system को दो logical processors के रूप में दिखाई देता है।
- Resource sharing और replication: कुछ resources replicate किए जाते हैं और कुछ share किए जाते हैं। replication करना है या नहीं, यह power consumption और chip पर उपलब्ध वास्तविक space जैसे कई factors पर निर्भर करता है।
प्रोसेसर microarchitecture
- Frontend, backend, और retirement unit: प्रोसेसर microarchitecture को तीन भागों में बाँटा जाता है। frontend instructions को fetch और decode करता है, backend execution resources allocate करता है और instructions को execute करता है। retirement unit executed instructions के परिणामों को architectural state में commit करता है।
SMT implementation का विवरण
- Frontend: इसमें instruction pointer, trace cache, ITLB cache, uop queue जैसे कई components होते हैं। दो logical processors को support करने के लिए हर component या तो replicate किया जाता है या share किया जाता है।
- Backend: इसमें resource allocator, register renaming, instruction ready queue, instruction scheduler आदि शामिल होते हैं। resource allocator हर cycle में logical processors के बीच switch करता है।
- Retirement unit: जब instructions architectural state में commit होने के लिए तैयार होते हैं, तो यह उन्हें track करता है और सही क्रम में commit करता है।
मेमोरी subsystem
- TLB: virtual address को physical address में बदलने वाली एक छोटी cache। यह दो logical processors के बीच dynamic रूप से share की जाती है।
- L1, L2, L3 cache: हर CPU core की अपनी L1 cache होती है। L2 cache microarchitecture के अनुसार अलग हो सकती है, जबकि L3 cache cores के बीच share की जाती है।
SMT का performance पर प्रभाव
- Single-thread execution: जब SMT-enabled core पर single thread चलाया जाता है, तो resources share होने के कारण performance कम हो सकती है।
- दो थ्रेड्स का execution: cache access patterns के अनुसार performance बदल सकती है। cooperative threads performance बढ़ा सकते हैं, लेकिन competitive threads performance घटा सकते हैं।
- Security vulnerabilities: हाल के वर्षों में SMT से जुड़ी security समस्याएँ पाई गई हैं। resource sharing और speculative execution के कारण sensitive data leak होने की संभावना हो सकती है।
निष्कर्ष
- SMT का उपयोग करना है या नहीं, यह तय करना: SMT को CPU resource utilization बढ़ाने और instruction throughput बढ़ाने के लिए डिज़ाइन किया गया था, लेकिन performance और security के लिहाज़ से इसमें trade-off हैं। workload के अनुसार SMT का उपयोग करना है या नहीं, यह तय करना महत्वपूर्ण है।
GN⁺ का सार
- SMT की समझ: SMT को CPU resource utilization बढ़ाने और instruction throughput बढ़ाने के लिए डिज़ाइन किया गया है।
- Performance और security: SMT performance improvement में मदद कर सकता है, लेकिन resource contention और security vulnerabilities के कारण performance degradation और security issues भी हो सकते हैं।
- उपयोग का निर्णय: workload के अनुसार SMT का उपयोग करना है या नहीं, यह सावधानी से तय करना चाहिए। यदि high performance की आवश्यकता हो, तो SMT को disable करना बेहतर हो सकता है।
- संबंधित प्रोजेक्ट: AMD के SMT implementation और ARM प्रोसेसर के SMT performance analysis प्रोजेक्ट भी देखने लायक हैं।
अभी कोई टिप्पणी नहीं है.