text
stringlengths
16
3.88k
source
stringlengths
60
201
ruptions. Some caveats: – What information is disclosed upon corruption? – For composability, A and Z can talk at each corruption. On protocol composition So far, we modeled “stand-alone security”: • Only a single execution of a single protocol • No other parties, no other network activity What about security “in conjunction with other protocol executions”? • Other executions of the same protocol? • Other executions of arbitrary other protocols? • “Intended” (coordinated) executions? • “unintended” (uncoordinated) executions? Examples • Composition of instances of the same protocol: – With same inputs/different inputs – Same parties/different parties/different roles – Sequential, parallel, concurrent (either coordinated or uncoordinated). • “Subroutine composition” (modular composition): protocol Q calls protocol P as subroutine. – Non-concurrent, Concurrent • General composition: Running in the same system with arbitrary other protocols (arbitrary network activity), without coordination. Is security maintained under these operations? Examples • Composition of instances of the same protocol: – With same inputs/different inputs – Same parties/different parties/different roles – Sequential, parallel, concurrent (either coordinated or uncoordinated). • “Subroutine composition” (modular composition): protocol Q calls protocol P as subroutine. – Non-concurrent, Concurrent • General composition: Running in the same system with arbitrary other protocols (arbitrary network activity), without coordination. Is security maintained under these operations? Modular composition: The basic idea Q Q Q P Q P Q Q (cid:206) Q P Q P f Towards the composition theorem The hybrid model with ideal access to func. f (the f-hybrid model): – Start with the real-life model of protocol execution. – In addition, the parties have access to a trusted party F for f: • At pre-defined rounds, the protocol instructs all parties to sends values to F. • F evaluates f on the given inputs and hands outputs to parties • Once the outputs are obtained the parties proceed as usual. –
https://ocw.mit.edu/courses/6-897-selected-topics-in-cryptography-spring-2004/0dfd54053823c507a9a117d910d31ff5_lecture1_2.pdf
. • F evaluates f on the given inputs and hands outputs to parties • Once the outputs are obtained the parties proceed as usual. – Notation: EXECf P,H,Z is the ensemble describing the output of Z after interacting with protocol P and adversary H in the f-hybrid model. Note: • During the “ideal call rounds” no other computation takes place. • Can generalize to a model where in each “ideal call round” a different function is being evaluated. But doesn’t really add power (can use a single universal functionality). The composition operation: Modular composition (Originates with [Micali-Rogaway91]) Start with: • Protocol Q in the f-hybrid model • Protocol P that securely realizes f Construct the composed protocol QP: • Each call to f is replaced with an invocation of P. • The output of P is treated as the value of f. Notes: • In QP, there is at most one protocol active (ie, sending messages) at any point in time: When P is running, Q is suspended. It is important that in P all parties terminate the protocol at the same round. Otherwise the composition theorem does not work… If P is a protocol in the real-life model then so is QP. If P is a protocol in the f’-hybrid model for some function f’, then so is QP. • • The non-concurrent modular composition theorem: Protocol QP “emulates” protocol Q. That is: For any B-limited adversary A there is a B-limited adversary H such that for any Z we have EXECf Q,H,Z ~ EXECQp,A,Z . Corollary: If protocol Q t-securely realizes function f’’ (in the f-hybrid model) then protocol QP t-securely realizes f’’ (in the plain real-life model),. Proof outline: Let’s restrict ourselves to one subroutine call. We have a B-limited adversary A that interacts with protocol QP in the real-life model. We want to construct an adversary H that interacts with protocol Q in the f-hybrid model such that no Z can tell the difference between the two interactions. We proceed In three steps: 1.
https://ocw.mit.edu/courses/6-897-selected-topics-in-cryptography-spring-2004/0dfd54053823c507a9a117d910d31ff5_lecture1_2.pdf
protocol Q in the f-hybrid model such that no Z can tell the difference between the two interactions. We proceed In three steps: 1. Out of A, we construct an adversary AP that interacts only with protocol P. 2. From the security of P, there is an adversary SP in the ideal process for f such that IDEALf Sp,Z ~ EXECP,A,Z . 3. Out of A and S we construct adversary H, and show that EXECf P,H,Z ~ EXECQp,A,Z . Adversary AP : – Expect the input (coming from Z) to contain an internal state of A at the beginning of the round where protocol QP calls P. (If input is in the wrong format then halt.) – Run A from this state, while interacting with parties running P. – At the end of the run, output the current state of A. From the security of P we have that there is an Sp,Z ~ EXECP,A,Z . adversary SP such that IDEALf Note: Here it is important that the input of AP is general and not only the inputs of the bad parties to the function. Adversary H : – Until the round where the parties in Q call f, run A. (Indeed, up to this point the two protocols are identical.) – At the point where Q calls f, run SP: • Play Z for SP, and give it the current state of A as input. • When SP generates f-inputs, forward these inputs to f. • Forward the outputs obtained from f to SP . – Once SP generates its output, continue running A from the state that appears in the output of SP. – Halt when A halts, and output whatever A outputs. Analysis of H : Assume there is an environment Z that on input z distinguishes with some probability between a run of H with Q in the f-hybrid model and a run of A with QP in the plain real-life model. Construct an environment ZP that, on input z, distinguishes with the same probability between a run of SP in the ideal process for f, and a run of AP with P (in contradiction to the security of P).
https://ocw.mit.edu/courses/6-897-selected-topics-in-cryptography-spring-2004/0dfd54053823c507a9a117d910d31ff5_lecture1_2.pdf
same probability between a run of SP in the ideal process for f, and a run of AP with P (in contradiction to the security of P). Environment ZP (on input z): – Run Z on input z, and orchestrate for Z an interaction with parties running QP and with adversary A. – At the round when P is called, start interacting with the external system: • Give to the external good parties the inputs that the simulated good parties would give to P. • Give the current state of A to the external adversary – When the external outputs are generated, continue the simulated interaction between A and the parties running Qp: the good parties use their outputs from the external system as the outputs of P, and A runs from the state in the output of the external adversary. – When the internal outputs are generated, hand them to Z and outputs whatever Z outputs. Analysis of ZP : Can verify: – – If the “external system” that ZP interacts with is an ideal process for f with adversary SP then the simulated Z sees exactly an interaction with H and Q in the f-hybrid model. If the “external system” that ZP interacts with is an execution of P with adversary AP then the simulated Z sees exactly an interaction with A and QP in the plain real-life model. Thus, ZP distinguishes with the same probability that Z distinguishes. Implication of the theorem Can design and analyze protocols in a modular way: – Partition a given task T to simpler sub-tasks T1…Tk – Construct protocols for realizing T1…Tk. – Construct a protocol for T assuming ideal access to T1…Tk. – Use the composition theorem to obtain a protocol for T from scratch. (Analogous to subroutine composition for correctness of programs, but with an added security guarantee.)
https://ocw.mit.edu/courses/6-897-selected-topics-in-cryptography-spring-2004/0dfd54053823c507a9a117d910d31ff5_lecture1_2.pdf
MIT OpenCourseWare http://ocw.mit.edu 6.189 Multicore Programming Primer, January (IAP) 2007 Please use the following citation format: Saman Amarasinghe, 6.189 Multicore Programming Primer, January (IAP) 2007. (Massachusetts Institute of Technology: MIT OpenCourseWare). http://ocw.mit.edu (accessed MM DD, YYYY). License: Creative Commons Attribution-Noncommercial-Share Alike. Note: Please use the actual date you accessed this material in your citation. For more information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms 6.189 IAP 2007 Lecture 3 Introduction to Parallel Architectures Prof. Saman Amarasinghe, MIT. 1 6.189 IAP 2007 MIT Implicit vs. Explicit Parallelism Implicit Explicit Hardware Compiler Superscalar Processors Explicitly Parallel Architectures Prof. Saman Amarasinghe, MIT. 2 6.189 IAP 2007 MIT Outline ● Implicit Parallelism: Superscalar Processors ● Explicit Parallelism ● Shared Instruction Processors ● Shared Sequencer Processors ● Shared Network Processors ● Shared Memory Processors ● Multicore Processors Prof. Saman Amarasinghe, MIT. 3 6.189 IAP 2007 MIT Implicit Parallelism: Superscalar Processors ● Issue varying numbers of instructions per clock „ statically scheduled – using compiler techniques – in-order execution „ dynamically scheduled – Extracting ILP by examining 100’s of instructions – Scheduling them in parallel as operands become available – Rename registers to eliminate anti dependences – out-of-order execution – Speculative execution Prof. Saman Amarasinghe, MIT. 4 6.189 IAP 2007 MIT Pipelining Execution IF: Instruction fetch EX : Execution ID : Instruction decode WB : Write back Cycles Instruction # Instruction i 1 IF Instruction i+1 Instruction i+2 Instruction i+3 Instruction i+4 2 ID IF 3 4 5
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
Instruction i+2 Instruction i+3 Instruction i+4 2 ID IF 3 4 5 6 7 8 EX WB ID IF EX WB ID IF EX WB ID IF EX WB ID EX WB Prof. Saman Amarasinghe, MIT. 5 6.189 IAP 2007 MIT Super-Scalar Execution 2 ID ID IF IF Instruction type 1 IF IF Integer Floating point Integer Floating point Integer Floating point Integer Floating point Cycles 3 4 5 6 7 EX WB EX WB ID ID IF IF EX WB EX WB ID ID IF IF EX WB EX WB ID ID EX WB EX WB Prof. Saman Amarasinghe, MIT. 2-issue super-scalar machine 6 6.189 IAP 2007 MIT Data Dependence and Hazards ● InstrJ is data dependent (aka true dependence) on InstrI: I: add r1,r2,r3 J: sub r4,r1,r3 ● ● If two instructions are data dependent, they cannot execute simultaneously, be completely overlapped or execute in out-of­ order If data dependence caused a hazard in pipeline, called a Read After Write (RAW) hazard Prof. Saman Amarasinghe, MIT. 7 6.189 IAP 2007 MIT ILP and Data Dependencies, Hazards ● HW/SW must preserve program order: ● order instructions would execute in if executed sequentially as determined by original source program „ Dependences are a property of programs Importance of the data dependencies „ 1) indicates the possibility of a hazard „ 2) determines order in which results must be calculated „ 3) sets an upper bound on how much parallelism can possibly be exploited ● Goal: exploit parallelism by preserving program order only where it affects the outcome of the program Prof. Saman Amarasinghe, MIT. 8 6.189 IAP 2007 MIT Name Dependence #1:
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
program Prof. Saman Amarasinghe, MIT. 8 6.189 IAP 2007 MIT Name Dependence #1: Anti-dependence ● Name dependence: when 2 instructions use same register or memory location, called a name, but no flow of data between the instructions associated with that name; 2 versions of name dependence InstrJ writes operand before InstrI reads it ● I: sub r4,r1,r3 J: add r1,r2,r3 K: mul r6,r1,r7 Called an “anti-dependence” by compiler writers. This results from reuse of the name “r1” If anti-dependence caused a hazard in the pipeline, called a Write After Read (WAR) hazard ● Prof. Saman Amarasinghe, MIT. 9 6.189 IAP 2007 MIT Name Dependence #2: Output dependence ● InstrJ writes operand before InstrI writes it. I: sub r1,r4,r3 J: add r1,r2,r3 K: mul r6,r1,r7 ● Called an “output dependence” by compiler writers. This also results from the reuse of name “r1” If anti-dependence caused a hazard in the pipeline, called a Write After Write (WAW) hazard Instructions involved in a name dependence can execute simultaneously if name used in instructions is changed so instructions do not conflict „ Register renaming resolves name dependence for registers „ Renaming can be done either by compiler or by HW Prof. Saman Amarasinghe, MIT. 10 6.189 IAP 2007 MIT ● ● Control Dependencies ● Every instruction is control dependent on some set of branches, and, in general, these control dependencies must be preserved to preserve program order if p1 { S1; }; if p2 { S2; } ● S1 is control dependent on p1, and S2 is control dependent on p2 but not on p1. ● Control dependence need not be preserved „ willing to execute instructions that should not have been executed, thereby violating the control dependences, if can do so without affecting correctness of the program ● Speculative Execution Prof. Saman Amarasinghe, MIT. 11 6.
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
can do so without affecting correctness of the program ● Speculative Execution Prof. Saman Amarasinghe, MIT. 11 6.189 IAP 2007 MIT Speculation ● Greater ILP: Overcome control dependence by hardware speculating on outcome of branches and executing program as if guesses were correct „ Speculation ⇒ fetch, issue, and execute instructions as if branch predictions were always correct „ Dynamic scheduling ⇒ only fetches and issues instructions ● Essentially a data flow execution model: Operations execute as soon as their operands are available Prof. Saman Amarasinghe, MIT. 12 6.189 IAP 2007 MIT Speculation in Rampant in Modern Superscalars ● Different predictors „ Branch Prediction „ Value Prediction „ Prefetching (memory access pattern prediction) ● Inefficient „ Predictions can go wrong „ Has to flush out wrongly predicted data „ While not impacting performance, it consumes power Prof. Saman Amarasinghe, MIT. 13 6.189 IAP 2007 MIT Today’s CPU Architecture: Heat becoming an unmanageable problem ) 2 m c / W ( y t i s n e d r e w o P 10,000 1,000 100 10 4004 8008 8080 1 '70 Sun's Surface Rocket Nozzle Nuclear Reactor 8086 8085 286 386 Hot Plate 486 '80 '90 '00 '10 Image by MIT OpenCourseWare. Intel Developer Forum, Spring 2004 - Pat Gelsinger (Pentium at 90 W) Cube relationship between the cycle time and pow Prof. Saman Amarasinghe, MIT. 14 6.189 IAP 2007 MIT Pentium-IV ● Pipelined ● „ minimum of 11 stages for any instruction Instruction-Level Parallelism „ Can execute up to 3 x86 instructions per cycle Image removed due to copyright restrictions. ● Data Parallel Instructions „ MMX (64-bit) and SSE (128-bit) extensions provide short vector support ● Thread-Level Parallelism at
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
Data Parallel Instructions „ MMX (64-bit) and SSE (128-bit) extensions provide short vector support ● Thread-Level Parallelism at System Level „ Bus architecture supports shared memory multiprocessing Prof. Saman Amarasinghe, MIT. 15 6.189 IAP 2007 MIT Outline ● Implicit Parallelism: Superscalar Processors ● Explicit Parallelism ● Shared Instruction Processors ● Shared Sequencer Processors ● Shared Network Processors ● Shared Memory Processors ● Multicore Processors Prof. Saman Amarasinghe, MIT. 16 6.189 IAP 2007 MIT Explicit Parallel Processors ● Parallelism is exposed to software „ Compiler or Programmer ● Many different forms „ Loosely coupled Multiprocessors to tightly coupled VLIW Prof. Saman Amarasinghe, MIT. 17 6.189 IAP 2007 MIT Little’s Law Throughput per Cycle One Operation Latency in Cycles Parallelism = Throughput * Latency ● To maintain throughput T/cycle when each operation has latency L cycles, need T*L independent operations ● For fixed parallelism: „ „ decreased latency allows increased throughput decreased throughput allows increased latency tolerance 6.189 IAP 2007 MIT 18 Prof. Saman Amarasinghe, MIT. e m T i e m T i Types of Parallelism e m T i Pipelining Data-Level Parallelism (DLP) e m T i Thread-Level Parallelism (TLP) Instruction-Level Parallelism (ILP) Prof. Saman Amarasinghe, MIT. 19 6.189 IAP 2007 MIT Translating Parallelism Types Pipelining Data Parallel Thread Parallel Instruction Parallel Prof. Saman Amarasinghe, MIT. 20 6.189 IAP 2007 MIT Issues in Parallel Machine Design ● Communication „ how do parallel operations communicate data results? ● Synchronization „ how are parallel operations coordinated? ● Resource Management „ how are a large number of parallel
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
data results? ● Synchronization „ how are parallel operations coordinated? ● Resource Management „ how are a large number of parallel tasks scheduled onto finite hardware? ● Scalability „ how large a machine can be built? Prof. Saman Amarasinghe, MIT. 21 6.189 IAP 2007 MIT Flynn’s Classification (1966) Broad classification of parallel computing systems based on number of instruction and data streams ● SISD: Single Instruction, Single Data „ conventional uniprocessor ● SIMD: Single Instruction, Multiple Data „ one instruction stream, multiple data paths „ distributed memory SIMD (MPP, DAP, CM-1&2, Maspar) shared memory SIMD (STARAN, vector computers) „ ● MIMD: Multiple Instruction, Multiple Data „ message passing machines (Transputers, nCube, CM-5) „ non-cache-coherent shared memory machines (BBN Butterfly, T3D) „ cache-coherent shared memory machines (Sequent, Sun Starfire, SGI Origin) ● MISD: Multiple Instruction, Single Data „ no commercial examples Prof. Saman Amarasinghe, MIT. 22 6.189 IAP 2007 MIT My Classification ● By the level of sharing „ Shared Instruction „ Shared Sequencer „ Shared Memory „ Shared Network Prof. Saman Amarasinghe, MIT. 23 6.189 IAP 2007 MIT Outline ● Implicit Parallelism: Superscalar Processors ● Explicit Parallelism ● Shared Instruction Processors ● Shared Sequencer Processors ● Shared Network Processors ● Shared Memory Processors ● Multicore Processors Prof. Saman Amarasinghe, MIT. 24 6.189 IAP 2007 MIT Shared Instruction: SIMD Machines ● Illiac IV (1972) „ 64 64-bit PEs, 16KB/PE, 2D network ● Goodyear STARAN (1972) „ 256 bit-serial associative PEs, 32B/PE, multistage network ● ICL DAP (Distributed
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
„ 256 bit-serial associative PEs, 32B/PE, multistage network ● ICL DAP (Distributed Array Processor) (1980) „ 4K bit-serial PEs, 512B/PE, 2D network ● Goodyear MPP (Massively Parallel Processor) (1982) „ 16K bit-serial PEs, 128B/PE, 2D network ● Thinking Machines Connection Machine CM-1 (1985) „ 64K bit-serial PEs, 512B/PE, 2D + hypercube router „ CM-2: 2048B/PE, plus 2,048 32-bit floating-point units ● Maspar MP-1 (1989) „ 16K 4-bit processors, 16-64KB/PE, 2D + Xnet router „ MP-2: 16K 32-bit processors, 64KB/PE Prof. Saman Amarasinghe, MIT. 25 6.189 IAP 2007 MIT Shared Instruction: SIMD Architecture ● Central controller broadcasts instructions to multiple processing elements (PEs) Array Controller Control Data Inter-PE Connection Network PE PE PE PE PE PE PE PE M e m M e m M e m M e m M e m M e m M e m M e m • Only requires one controller for whole array • Only requires storage for one copy of program • All computations fully synchronized Prof. Saman Amarasinghe, MIT. 26 6.189 IAP 2007 MIT Cray-1 (1976) ● First successful supercomputers Images removed due to copyright restrictions. Prof. Saman Amarasinghe, MIT. 27 6.189 IAP 2007 MIT Cray-1 (1976) 64 Element Vector Registers Single Port Memory 16 banks of 64-bit words + 8-bit SECDED ( (Ah) + j k m ) (A0) 64 T Regs 80MW/sec data load/store 320MW/sec instruction
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
Ah) + j k m ) (A0) 64 T Regs 80MW/sec data load/store 320MW/sec instruction buffer refill ( (Ah) + j k m ) (A0) 64 T Regs Si Tjk Ai Bjk V0 V1 V2 V3 V4 V5 V6 V7 S0 S1 S2 S3 S4 S5 S6 S7 A0 A1 A2 A3 A4 A5 A6 A7 Vi Vj Vk Sj Sk Si Aj Ak Ai V. Mask V. Length FP Add FP Mul FP Recip Int Add Int Logic Int Shift Pop Cnt Addr Add Addr Mul 64-bitx16 4 Instruction Buffers NIP LIP CIP memory bank cycle 50 ns processor cycle 12.5 ns (80MHz) 6.189 IAP 2007 MIT 28 Prof. Saman Amarasinghe, MIT. Vector Instruction Execution Cycles 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 IF ID EX WB EX IF ID EX WB EX EX IF ID EX WB Successive instructions EX EX EX IF ID EX WB EX EX EX EX EX EX EX EX EX EX EX EX Prof. Saman Amarasinghe, MIT. 29 6.189 IAP 2007 MIT Vector Instruction Execution VADD C,A,B Execution using one pipelined functional unit Execution using four pipelined functional units A[6] B[6] A[5] B[5] A[4] B[4] A[3] B[3] A[24] B[24] A[25] B[25] A[26] B[26] A[27] B[27] A[20] B[
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
B[25] A[26] B[26] A[27] B[27] A[20] B[20] A[21] B[21] A[22] B[22] A[23] B[23] A[16] B[16] A[17] B[17] A[18] B[18] A[19] B[19] A[12] B[12] A[13] B[13] A[14] B[14] A[15] B[15] C[2] C[1] C[0] C[8] C[4] C[9] C[5] C[10] C[6] C[11] C[7] C[0] C[1] C[2] C[3] Prof. Saman Amarasinghe, MIT. 30 6.189 IAP 2007 MIT Vector Unit Structure Functional Unit Vector Registers Lane Prof. Saman Amarasinghe, MIT. 31 6.189 IAP 2007 MIT Memory Subsystem Outline ● Implicit Parallelism: Superscalar Processors ● Explicit Parallelism ● Shared Instruction Processors ● Shared Sequencer Processors ● Shared Network Processors ● Shared Memory Processors ● Multicore Processors Prof. Saman Amarasinghe, MIT. 32 6.189 IAP 2007 MIT Shared Sequencer VLIW: Very Long Instruction Word Int Op 1 Int Op 2 Mem Op 1 Mem Op 2 FP Op 1 FP Op 2 Two Integer Units, Single Cycle Latency Two Load/Store Units, Three Cycle Latency Two Floating-Point Units, Four Cycle Latency ● Compiler schedules parallel execution ● Multiple parallel operations packed into one long instruction word ● Compiler must avoid data hazards (no interlocks) Prof. Saman Amarasinghe, MIT. 33 6.189 IAP 2007 MIT VLIW Instruction Execution 1 IF 2 ID IF Success
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
. 33 6.189 IAP 2007 MIT VLIW Instruction Execution 1 IF 2 ID IF Successive instructions Cycles 3 4 5 6 EX WB EX EX ID EX WB EX EX ID IF EX WB EX EX Prof. Saman Amarasinghe, MIT. VLIW execution with degree = 3 34 6.189 IAP 2007 MIT ILP Datapath Hardware Scaling Register File Multiple Functional Units Memory Interconnect ● Replicating functional units and cache/memory banks is straightforward and scales linearly ● Register file ports and bypass logic for N functional units scale quadratically (N*N) ● Memory interconnection among N functional units and memory banks also scales quadratically (For large N, could try O(N logN) interconnect schemes) ● ● Technology scaling: Wires are getting even slower relative to gate delays Multiple Cache/Memory Banks ● Complex interconnect adds latency as well as area => Need greater parallelism to hide latencies Prof. Saman Amarasinghe, MIT. 35 6.189 IAP 2007 MIT Clustered VLIW Cluster Interconnect Local Regfile Local Regfile Cluster Memory Interconnect Multiple Cache/Memory Banks ● Divide machine into clusters of local register files and local functional units ● Lower bandwidth/higher latency interconnect between clusters ● Software responsible for mapping computations to minimize communication overhead Prof. Saman Amarasinghe, MIT. 36 6.189 IAP 2007 MIT Outline ● Implicit Parallelism: Superscalar Processors ● Explicit Parallelism ● Shared Instruction Processors ● Shared Sequencer Processors ● Shared Network Processors ● Shared Memory Processors ● Multicore Processors Prof. Saman Amarasinghe, MIT. 37 6.189 IAP 2007 MIT Shared Network: Message Passing MPPs (Massively Parallel Processors) ● Initial Research Projects „ Caltech Cosmic Cube (early 1980s) using custom M
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
s (Massively Parallel Processors) ● Initial Research Projects „ Caltech Cosmic Cube (early 1980s) using custom Mosaic processors ● Commercial Microprocessors including MPP Support „ Transputer (1985) „ nCube-1(1986) /nCube-2 (1990) ● Standard Microprocessors + Network Interfaces „ Intel Paragon (i860) „ TMC CM-5 (SPARC) „ Meiko CS-2 (SPARC) IBM SP-2 (RS/6000) „ ● MPP Vector Supers „ Fujitsu VPP series Designs scale to 100s or 1000s of nodes Interconnect Network NI NI NI NI NI NI NI NI μP μP μP μP μP μP μP μP Mem Mem Mem Mem Mem Mem Mem Mem Prof. Saman Amarasinghe, MIT. 38 6.189 IAP 2007 MIT Message Passing MPP Problems ● All data layout must be handled by software „ cannot retrieve remote data except with message request/reply ● Message passing has high software overhead „ early machines had to invoke OS on each message (100μs­ 1ms/message) „ even user level access to network interface has dozens of cycles overhead (NI might be on I/O bus) „ sending messages can be cheap (just like stores) „ receiving messages is expensive, need to poll or interrupt Prof. Saman Amarasinghe, MIT. 39 6.189 IAP 2007 MIT Outline ● Implicit Parallelism: Superscalar Processors ● Explicit Parallelism ● Shared Instruction Processors ● Shared Sequencer Processors ● Shared Network Processors ● Shared Memory Processors ● Multicore Processors Prof. Saman Amarasinghe, MIT. 40 6.189 IAP 2007 MIT Shared Memory: Shared Memory Multiprocessors ● Will work with any data placement (but might be slow) „ can choose to optimize only critical portions of code ● Load and store instructions used to communicate data between
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
data placement (but might be slow) „ can choose to optimize only critical portions of code ● Load and store instructions used to communicate data between processes „ no OS involvement „ low software overhead ● Usually some special synchronization primitives „ fetch&op „ load linked/store conditional In large scale systems, the logically shared memory is implemented as physically distributed memory modules ● ● Two main categories „ non cache coherent „ hardware cache coherent Prof. Saman Amarasinghe, MIT. 41 6.189 IAP 2007 MIT Shared Memory: Shared Memory Multiprocessors ● No hardware cache coherence „ IBM RP3 „ BBN Butterfly „ Cray T3D/T3E „ Parallel vector supercomputers (Cray T90, NEC SX-5) ● Hardware cache coherence „ many small-scale SMPs (e.g. Quad Pentium Xeon systems) „ large scale bus/crossbar-based SMPs (Sun Starfire) „ large scale directory-based SMPs (SGI Origin) Prof. Saman Amarasinghe, MIT. 42 6.189 IAP 2007 MIT Cray T3E • Up to 2048 600MHz Alpha 21164 processors connected in 3D torus ● Each node has 256MB-2GB local DRAM memory ● Load and stores access global memory over network ● Only local memory cached by on-chip caches ● Alpha microprocessor surrounded by custom “shell” circuitry to make it into Y X Z Image by MIT OpenCourseWare. effective MPP node. Shell provides: „ multiple stream buffers instead of board-level (L3) cache „ „ „ „ „ external copy of on-chip cache tags to check against remote writes to local memory, generates on-chip invalidates on match 512 external E registers (asynchronous vector load/store engine) address management to allow all of external physical memory to be addressed atomic memory operations (fetch&op) support for hardware barriers/eureka to synchronize parallel tasks Prof. Saman Amarasinghe, MIT. 43 6.189 IAP 2007 MIT HW Cache Cohernecy
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
tasks Prof. Saman Amarasinghe, MIT. 43 6.189 IAP 2007 MIT HW Cache Cohernecy ● Bus-based Snooping Solution „ Send all requests for data to all processors „ Processors snoop to see if they have a copy and respond accordingly „ Requires broadcast, since caching information is at processors „ Works well with bus (natural broadcast medium) „ Dominates for small scale machines (most of the market) ● Directory-Based Schemes „ Keep track of what is being shared in 1 centralized place (logically) „ Distributed memory => distributed directory for scalability (avoids bottlenecks) „ Send point-to-point requests to processors via network „ Scales better than Snooping „ Actually existed BEFORE Snooping-based schemes Prof. Saman Amarasinghe, MIT. 44 6.189 IAP 2007 MIT Bus-Based Cache-Coherent SMPs μP μP μP μP $ $ $ $ Bus Central Memory ● Small scale (<= 4 processors) bus-based SMPs by far the most common parallel processing platform today ● Bus provides broadcast and serialization point for simple snooping cache coherence protocol ● Modern microprocessors integrate support for this protocol Prof. Saman Amarasinghe, MIT. 45 6.189 IAP 2007 MIT Sun Starfire (UE10000) • Up to 64-way SMP using bus-based snooping protocol μP μP μP μP μP μP μP μP $ $ $ $ $ $ $ $ Board Interconnect Board Interconnect 4 processors + memory module per system board Uses 4 interleaved address busses to scale snooping protocol 16x16 Data Crossbar Memory Module Memory Module Separate data transfer over high bandwidth crossbar Prof. Saman Amarasinghe, MIT. 46 6.189 IAP 2007 MIT SGI Origin 2000 • Large scale distributed directory SMP • Scales from 2 processor workstation to 512 processor supercomputer Node contains: • Two MIPS R10000 processors plus caches •
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
• Scales from 2 processor workstation to 512 processor supercomputer Node contains: • Two MIPS R10000 processors plus caches • Memory module including directory • Connection to global network • Connection to I/O Scalable hypercube switching network supports up to 64 two-processor nodes (128 processors total) (Some installations up to 512 processors) Node R10000 R10000 Cache Cache Directory/ Main Memory HUB XIO Router to CrayLink Interconnect Module Module Router Router Module Router Cray link Interconnect Router Module Router Router Router Module Module Module Image by MIT OpenCourseWare. Prof. Saman Amarasinghe, MIT. 47 6.189 IAP 2007 MIT Outline ● Implicit Parallelism: Superscalar Processors ● Explicit Parallelism ● Shared Instruction Processors ● Shared Sequencer Processors ● Shared Network Processors ● Shared Memory Processors ● Multicore Processors Prof. Saman Amarasinghe, MIT. 48 6.189 IAP 2007 MIT Phases in “VLSI” Generation 100,000,000 10,000,000 1,000,000 i s r o t s s n a r T 100,000 10,000 Bit-level parallelism Instruction-level Thread-level (?) multicore XXX X X XX X XX X X R10000 X XX XXX XX X X X XX X XXXX XXXX X XXX X X X X X XX Pentium X X X X X X XX X i80386 X i80286 X X X X X R3000 X R2000 X i8086 i8080 X XX i8008 X X i4004 1,000 1970 1975 1980 1985 1990 1995 2000 2005 Prof. Saman Amarasinghe, MIT. 49 6.189 IAP
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
5 1990 1995 2000 2005 Prof. Saman Amarasinghe, MIT. 49 6.189 IAP 2007 MIT Multicores 512 256 128 # of cores 64 32 16 8 4 2 1 4004 8080 8086 286 386 486 Pentium 8008 Picochip Ambric PC102 AM2045 Cisco CSR-1 Intel Tflops Raw Raza Cavium XLR Octeon Niagara Cell Boardcom 1480 Xbox360 PA-8800 Opteron Power4 Opteron 4P Xeon MP Tanglewood PExtreme Power6 Yonah P2 P3 Itanium P4 Athlon Itanium 2 1970 1975 1980 1985 1990 1995 2000 2005 20?? Prof. Saman Amarasinghe, MIT. 50 6.189 IAP 2007 MIT Multicores ● Shared Memory „ Intel Yonah, AMD Opteron „ IBM Power 5 & 6 „ Sun Niagara ● Shared Network „ MIT Raw „ Cell ● Crippled or Mini cores „ Intel Tflops „ Picochip Prof. Saman Amarasinghe, MIT. 51 6.189 IAP 2007 MIT Shared Memory Multicores: Evolution Path for Current Multicore Processors Image removed due to copyright restrictions. Multicore processor diagram. ● IBM Power5 „ Shared 1.92 Mbyte L2 cache ● AMD Opteron „ Separate 1 Mbyte L2 caches „ CPU0 and CPU1 communicate through the SRQ ● Intel Pentium 4 „ “Glued” two processors together Prof. Saman Amarasinghe, MIT. 52 6.189 IAP 2007 MIT CMP: Multiprocessors On One Chip ● By placing multiple processors, their memories and the IN all on one chip, the latencies of chip-to-chip communication are drastically
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
Chip ● By placing multiple processors, their memories and the IN all on one chip, the latencies of chip-to-chip communication are drastically reduced „ ARM multi-chip core Private IRQ Configurable # of hardware intr Per-CPU aliased peripherals Configurable between 1 & 4 symmetric CPUs Private peripheral bus Interrupt Distributor CPU Interface CPU Interface CPU Interface CPU Interface CPU L1$s CPU L1$s CPU L1$s CPU L1$s Snoop Control Unit CCB I & D 64-b bus Prof. Saman Amarasinghe, MIT. Primary AXI R/W 64-b bus 53 Optional AXI R/W 64-b bus 6.189 IAP 2007 MIT Shared Network Multicores: The MIT Raw Processor Images removed due to copyright restrictions. • 16 Flops/ops per cycle • 208 Operand Routes / cycle • 2048 KB L1 SRAM Prof. Saman Amarasinghe, MIT. 54 6.189 IAP 2007 MIT Raw’s three on-chip mesh networks (225 Gb/s @ 225 Mhz) MIPS-Style Pipeline 8 32-bit buses Registered at input Æ longest wire = length of tile Prof. Saman Amarasinghe, MIT. 55 6.189 IAP 2007 MIT Shared Network Multicore: The Cell Processor ● IBM/Toshiba/Sony joint project - 4-5 years, 400 designers „ „ 234 million transistors, 4+ Ghz 256 Gflops (billions of floating pointer operations per second) ● One 64-bit PowerPC processor „ „ 4+ Ghz, dual issue, two threads 512 kB of second-level cache ● Eight Synergistic Processor Elements „ Or “Streaming Processor Elements” „ Co-processors with dedicated 256kB of memory (not cache) ● IO „ Dual Rambus XDR memory controllers (on chip) – 25.6 GB/sec of memory bandwidth 76.8 GB/s chip-to-chip
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
ambus XDR memory controllers (on chip) – 25.6 GB/sec of memory bandwidth 76.8 GB/s chip-to-chip bandwidth (to off-chip GPU) „ PP P P U U M I C M I C Image removed due to copyright restrictions. IBM-Toshiba-Sony joint processor. SS SS SS SS PP PP PP PP UU UU UU UU RRB B MIB MIB RI R I AC S S S S A S C C P P P P C P U U U U U S P U S P U S P U Prof. Saman Amarasinghe, MIT. 56 6.189 IAP 2007 MIT Mini-core Multicores: PicoChip Processor I/O I/O ● Array of 322 processing elements ● 16-bit RISC ● 3-way LIW ● 4 processor variants: „ 240 standard (MAC) „ 64 memory „ 4 control (+ instr. mem.) „ 14 function accellerators I/O I/O External Memory Array Processing Element Switch Matrix Inter-picoArray Interface Prof. Saman Amarasinghe, MIT. 57 6.189 IAP 2007 MIT Conclusions ● Era of programmers not caring about what is under the hood is over ● A lot of variations/choices in hardware ● Many will have performance implications ● Understanding the hardware will make it easier to make programs get high performance ● A note of caution: If program is too closely tied to the processor Æ cannot port or migrate „ back to the era of assembly programming Prof. Saman Amarasinghe, MIT. 58 6.189 IAP 2007 MIT
https://ocw.mit.edu/courses/6-189-multicore-programming-primer-january-iap-2007/0e56d30fb5cce40a429b63435d2a039a_lec3architctre.pdf
18.409 An Algorithmist’s Toolkit September 24, 2009 Lecturer: Jonathan Kelner Scribe: Shaunak Kishore Lecture 5 1 Administrivia Two additional resources on approximating the permanent • Jerrum and Sinclair’s original paper on the algorithm • An excerpt from Motwani and Raghavan’s Randomized Algorithms 2 Review of Monte Carlo Methods We have some (usually exponentially large) set V of size Z, and we wish to know how many elements are contained in some subset S (which represents elements with some property we are interested in counting). A Monte Carlo method for approximating the size of S is to pick k elements uniformly at random from V and see how many are also contained in S. If q elements are contained in S, then return as our approximate solution Zq/k. In expectation, this is the correct answer, but how tightly the estimate is concentrated around the correct value depends on the size of p = |S| . |V | Definition 1 An ((cid:15), δ) approximation scheme is an algorithm for finding an approximation within a multiplicative factor of 1 ± (cid:15) with probability 1 − δ. Using the Chernoff bound, if we sample independently from a 0-1 random variable, we need to conduct (cid:18) log δ pε2 N ≥ Θ (cid:19) trials to achieve an ((cid:15), δ) approximation, where p = |S| | polynomial-time approximation scheme. |V as before. This bound motiv ates the definition of a Definition 2 A fully-polynomial randomized approximation scheme, or FPRAS, is an ((cid:15), δ) ap- proximation scheme with a runtime that is polynomial in n, 1/(cid:15), and log 1/δ. There are two main problems we might encounter when trying to design an FPRAS for a difficult problem. First, the S may be an exponentially small subset of V . In this case, it would take exponentially many samples from V to get O( log 1/δ ) successes. Second, it could be difficult to sample uniformly from a large and complicated set V . We will see ways to solve both these
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
successes. Second, it could be difficult to sample uniformly from a large and complicated set V . We will see ways to solve both these problems in two examples today. (cid:15)2 3 DNF Counting and an Exponentially Small Target Suppose we have n boolean variables x1, x2, . . . xn. A literal is an xi or its negation. Definition 3 A formula F is in disjunctive normal form if it is a disjunction (OR) of conjunctive (AND) clauses: F = C1 ∨ C2 ∨ . . . ∨ Cm, where each Ci is a clause containing the ANDs of some of the literals. For example, the formula F = (x1 ∧ x3) ∨ (x2) ∨ (x2 ∧ x1 ∧ x3 ∧ x4) is in disjunctive normal form. 5-1 If there are n boolean literals, then there are 2n possible assignments. Of these 2n assignments, we want to know how many of them satisfy a given DNF formula F . Unfortunately, computing the exact number of solutions to a given DNF formula is #P -Hard1 . Therefore we simply wish to give an ε-approximation for the number of solutions a given DNF formula that succeeds with probability 1 − δ and runs in time polynomial in n, m, log δ, and 1/ε. Na¨ıvely, one could simply try to use the Monte Carlo method outlined above to approximate the number of solutions. However the number of satisfying assignments might be exponentially small, requiring expo­ nentially many samples to get a tight bound. For example the DNF formula F = (x1 ∧ x2 ∧ · · · ∧ xn) has only 1 solution out of 2n assignments. 3.1 Reducing the Sample Space Instead of picking assignments uniformly at random and testing each clause, we will instead sample from the set of assignments that satisfy at least one clause (but not uniformly). This algorithm illustrates the general strategy of sampling only the important space. Consider a
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
least one clause (but not uniformly). This algorithm illustrates the general strategy of sampling only the important space. Consider a table with assignments on one side and the clauses C1, C2, . . . , Cm on the other, where each entry is 0 or 1 depending on whether the assignment satisfies the clause. Then, for each assignment, we color the entry for first clause which it satisfies yellow (if such a clause exists). We color the remaining entries satisfied clauses blue, and we set these entries to 0. See Figure 1. Figure 1: A table of assignments versus clauses and how to color it. We will sample uniformly from the space of blue and yellow colored entries, and then test whether we’ve sampled a yellow entry. We then multiply the ratio we get by the total number of blue and yellow entries, which we can easily compute. Let clause Ci have ki literals. Then clearly the column corresponding to Ci has 2n−ki satisfying assign­ ments (which we can easily compute). We choose which clause to sample from with probability proportional to 2n−ki . Then we pick a random satisfying assignment for this clause and test whether it is the first satisfied clause in its row (a yellow entry), or if there is a satisfied clause that precedes it (a blue entry). The total size of the space we’re sampling from is just � i 2n−ki . 1To see this, understand that the negation of a DNF formula is just a CNF formula by application of De Morgan’s laws. Therefore counting solutions to a DNF formula is equivalent to counting (non-)solutions of a CNF formula, which is the canonical example of a #P -Hard problem.
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
equivalent to counting (non-)solutions of a CNF formula, which is the canonical example of a #P -Hard problem. 5-2 Our probability of picking a yellow entry is at least 1/m, where m is the number of clauses, so we can take enough samples in polynomial time. Therefore, this algorithm is an FPRAS for counting the solutions to the DNF formula. 4 Approximating the Permanent of a 0-1 Matrix Definition 4 (Determinant) For a given n × n matrix M , the determinant is given by det(M ) = � π∈Sn n � sgn(π) Mi,π(i). i=1 The formula for the permanent of a matrix is largely the same, with the sgn(π) omitted. Definition 5 (Permanent) For a given n × n matrix M , the permanent is given by per(M ) = n � � Mi,π(i). π∈Sn i=1 However, while the determinant of a matrix is easily computable — O(n3) by LU decomposition — calculating the permanent of a matrix is #P -Complete. As we will show, computing the permanent of a 0-1 matrix reduces to the problem of finding the number of perfect matchings in a bipartite graph. 4.1 The Permanent of a 0-1 Matrix and Perfect Matchings Given an n × n 0-1 matrix M , we construct a subgraph G of Kn,n, as follows. Let the vertices on the left be v1, v2, . . . vn and let the vertices on the right be w1, w2, . . . wn. There is an edge between vi and wj if and only if Mij is 1. Sup
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
There is an edge between vi and wj if and only if Mij is 1. Suppose σ is a permutation of {1, 2, . . . n}. Then the product i Miσ(i) is 1 if the pairing (vi, wσ(i)) is a perfect matching, and 0 otherwise. Therefore, the permanent of M equals the number of perfect matchings in G. As an example, we look at a particular 3 × 3 matrix and the corresponding subgraph of K3,3. � ⎛ 1 ⎝ 1 0 1 1 1 ⎞ 0 0 ⎠ 1 ⎛ ⎜ ⎝ ⎛ ⎜ ⎝ 1 1 0 1 1 0 ⎞ ⎟ ⎠ ⎞ ⎟ ⎠ 0 0 1 0 0 1 1 1 1 1 1 1 Calculating the permanent of a 0-1 matrix is still #P -Complete. As we will see, there is an FPRAS for approximating it. 5-3 4.2 An FPRAS for Approximating the Permanent of a Dense Graph 4.2.1 Some History • 1989: Jerrum and Sinclair showed how to approximate the permanent of a dense graph (all vertices have degree at least n/2). At the time, it was not known if this result could be extended to the general case. • 2001: Jerrum, Sinclair and Vigoda showed how to approximate the permanent of an arbitrary graph (and therefore for any matrix with nonnegative entries). We will show today the result of 1989 for approximating the permanent of a dense graph. 4.2.2 General Strategy We can’t do the na¨ıve Monte Carlo here, since the probability of
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
Strategy We can’t do the na¨ıve Monte Carlo here, since the probability of picking a perfect matching from the set of all permutations can be exponentially small. Therefore we will instead consider the set of all (possibly partial) matchings, not just perfect ones. Let Mk be the set of all partial matchings of size k. Now suppose that we had a black box that samples uniformly at random from Mk ∪ Mk−1 for any k. Then by the Monte Carlo method, by testing membership in Mk, we can determine the ratio rk = |Mk| . |Mk−1| If we assume that for all k, 1/α ≤ rk ≤ α for some polynomially-sized α, then we can estimate each rk to within relative error ε = 1/n2 using polynomially many samples. Therefore our estimate of the number of perfect matchings is just |Mn| = |M1| ri. n � If all of our approximations were within a (1 ± 1 n 2 )n ≈ (1 ± 1 ). 2 ) factor, then our total error is at most (1 ± 1 n n i=2 4.2.3 Bounding the rk We first begin with a crucial lemma. Lemma 6 Let G be a bipartite graph of minimum degree ≥ n/2. Then every partial matching in Mk−1 has an augmenting path of length ≤ 3. Proof Let m ∈ Mk−1 be a partial matching. Let u be an unmatched node of m. Now suppose that there are no augmenting paths of length 1 starting from u in this matching m (i.e. there is no unmatched node v such that there is an edge connecting u and v). Then by our
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
node v such that there is an edge connecting u and v). Then by our degree conditions, u must be connected to �. Likewise if we pick an unmatched node v, if it has no augmenting at least n/2 of the matched nodes vi paths of length 1, then it must be connected to at least n/2 of the matched nodes u� j . But by the pigeonhole principle, there must exist i and j such that (u� j , v) is an augmenting path of length 3. �) ∈ m. The path (u, vi j , vi �, u� Theorem 7 Let G be a bipartite graph of minimum degree ≥ n/2. Then 1/n2 ≤ rk ≤ n2 for all k. Proof We first prove that rk ≤ n2 . Consider the function f : Mk → Mk−1, which maps m ∈ Mk to its (arbitrarily-chosen) canonical representative in Mk−1 (i.e. uniquely choose a submatching of m). For any m� ∈ Mk−1, it must be the case that |f −1(m�)| ≤ (n − k + 1)2 ≤ n2 . Thus |Mk| ≤ n2|Mk−1|. Now we show that 1/n2 ≤ rk. Fix some m ∈ Mk. By Lemma 6, every partial matching in Mk−1 has an augmenting path of length ≤ 3. There are at most k partial matchings in Mk−1 that can by augmented by a path of length 1 to equal m. In addition, there are at most k(k − 1)
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
length 1 to equal m. In addition, there are at most k(k − 1) matchings in Mk−1 that can be augmented by a path of length 3 to equal m. Thus |Mk−1| ≤ (k + k(k − 1))|Mk| = k2|Mk| ≤ n2|Mk|. 5-4 4.2.4 How to Sample (Approximately) Uniformly We still have to show how to sample uniformly from Ck = Mk ∪ Mk−1. We will only show how to sample approximately uniformly from this set. As it turns out, this result is good enough for our purposes. The main idea here is to construct a graph whose vertex set is Ck, and then do a random walk on this graph which converges to the uniform distribution. We have to show two things: that the random walk converges in polynomial time, and that the stationary distribution on the graph Ck is uniform. To show that the random walk mixes quickly, we bound the conductance Φ(Ck) by the method of canonical paths. Lemma 8 Let G = (V, E) be a graph for which we wish to bound Φ(G). For every v, w ∈ V , we specify a canonical path pv,w from v to w. Suppose that for some constant b and for all e ∈ E, we have � v,w∈V I[e ∈ pv,w] ≤ b|V | that is, at most b|V | of the canonical paths run through any given edge e. Then Φ(G) ≥ is the maximum degree of any vertex. 1 4bdmax , where dmax Proof
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
(G) ≥ is the maximum degree of any vertex. 1 4bdmax , where dmax Proof As before, the conductance of G is defined as Φ(G) = min S⊂V min �� e(S) v∈S d(v), � � . v∈S d(v) Let S ⊂ V . We will show that Φ(S) ≥ . Without loss of generality, assume that |S| ≤ |V |/2. Then the number of canonical paths across the cut is at least |S||S| ≥ |S||V |/2. For each edge along the cut there can be no more than b|V | paths through each edge, the number of edges e(S) is at least |S| . 2b 1 4bdmax In addition we can bound min v∈S d(v), v∈S d(v) by |S|dmax. These bounds give us �� � � as claimed. Φ(S) ≥ |S|/2b |S|dmax ≥ 1 . 2bdmax Since the spectral gap is at least Φ(G)2, as long as b and dmax are bounded by polynomials, a random walk on G will converge in polynomial time. 4.2.5 The Graph Ck We will only do Cn. It should be clear later how to extend this construction for all k. Recall that our vertices correspond to matchings in Mn ∪ Mn−1. We show how to connect our vertices with 4 different types of directed edges: • Reduce (Mn −→ Mn−1): If m ∈ Mn, then for all e ∈ m define a transition to m� = m − e ∈ Mn−1 • Augment (Mn−1 −→ Mn): If m ∈ Mn−1, then for all u and v unmatched with
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
1 −→ Mn): If m ∈ Mn−1, then for all u and v unmatched with (u, v) ∈ E, define a transition to m� = m + (u, v) ∈ Mn. • Rotate (Mn−1 −→ Mn−1): If m ∈ Mn−1, then for all (u, w) ∈ m, (u, v) ∈ E with v unmatched, define a transition to m� = m + (u, v) − (u, w) ∈ Mn−1. • Self-Loop: Add enough self-loops so that you remain where you are with probability 1/2 (this gives us a uniform stationary distribution). Note that this actually provides an undirected graph since each of these steps is reversible. Example 9 In Figure 2 we show C2 for the graph G = K2,2. The two leftmost and two rightmost edges are Augment/Reduce pairs, while the others are Rotate transitions. The self-loops are omitted. 5-5 Figure by MIT OpenCourseWare. Figure 2: C2 for the graph G = K2,2. 4.2.6 Canonical Paths We still need to define the canonical paths pv,w for our graph Cn. For each node s ∈ Mn ∪Mn−1, we associate with it a “partner” s� ∈ Mn, as follows: • If s ∈ Mn, s� = s. • If s ∈ Mn−1 and has an augmenting path of length 1, augment to get s�. • If s ∈ Mn−1 and has a shortest augmenting path of length 3, augment to get s�. Now for nodes s, t ∈ Mn ∪ Mn−1, we show how to provide a canonical path ps,t which consists of three segments (and each segment can be one of two different types). • s −→ s
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
consists of three segments (and each segment can be one of two different types). • s −→ s� (Type A) • s� −→ t� (Type B) • t� −→ t (Type A) Type A paths are paths that connect a vertex s ∈ Mn ∪ Mn−1 to its partner s� ∈ Mn. Clearly, if s ∈ Mn then the type A path is empty. Now if s ∈ Mn−1 and has an augmenting path of length 1, then our canonical path is simply the edge that performs the Augment operation. If s ∈ Mn−1 and has a shortest augmenting path of length 3, then our canonical path is of length 2: first a Rotate, then an Augment (see Figure 3 for an example). For a Type B path, both s� and t� are in Mn. We let d = s� ⊕ t�, the symmetric difference of the two matchings (those edges which are not common to both matchings). It is clear that since s� and t� are perfect matchings, d consists of a collection of disjoint, even-length, alternating (from s� or from t�) cycles of length at least 4. Our canonical path from s� to t� will in a sense “unwind” each cycle of d individually. Now, in order for the path to be canonical, we need to provide some ordering on the cycles so that we process them in the same order each time. However, this can be done easily enough. In addition, we need to provide some ordering on the vertices in each cycle so that we unwind each cycle in the same order each time. Again, this can be done easily enough. All that remains is to describe how the cycles are unwound, which can be done much more e�
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
, this can be done easily enough. All that remains is to describe how the cycles are unwound, which can be done much more effectively with a picture than by text. See Figures 4 and 5. We must now bound the number of canonical paths that pass through each edge. First we consider the type A paths. 5-6 Figure by MIT OpenCourseWare. Figure 3: Type A path of length 2. Lemma 10 Let s ∈ Mn. Then at most O(n2) other nodes s� ∈ Mn ∪ Mn−1 have s as their partner. Proof There are three possible types of nodes s� that have s as their partner. The first is if s� = s (hence the type A path is empty). The second can be obtained by a Reduce transition (the nodes s� with augmenting path of length 1). The third can be obtained by a Reduce and Rotate pair of transitions. There is only partner for the first, O(n) for the second, and O(n2) for the third. Therefore there are at most O(n2) nodes s� that can count s� as their partner. Now we wish to count the number of canonical paths for type B. Lemma 11 Let T be a transition (i.e. an edge of Cn). Then the number of pairs s, t ∈ Mn that contain T on their type B canonical path is bounded by |Cn|. Proof We will provide an injection σT (s, t) that maps to matchings in Cn = Mn ∪ Mn−1. As before, let d = s ⊕ t be the symmetric difference of the two matchings s and t (recall that these can be broken down into disjoint alternating cycles C1, . . . , Cr). Now we proceed along the
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
can be broken down into disjoint alternating cycles C1, . . . , Cr). Now we proceed along the unwinding of these cycles until we reach the transition T . At this point we stop and say that the particular matching we are at, where all cycles up to this point agree with s and all cycles after this point agree with t, is the matching that σT (s, t) maps to. It is clear that this is fine when T is a Reduce or Augment transition, since these only occur at the beginning or end of an unwinding. The only problem is when T is a Rotate transition, because then there exists a vertex u (the pivot of the rotation) that is matched to a vertex v with (u, v) ∈ s and is also matched to a vertex w with (u, w) ∈ t. This is because up to T we agree with s, and after T we agree with t. But what we can do at this point is notice that one of these two edges (which we denote by es,t) always has the start vertex of the current cycle as one of its end-points. Therefore by removing it we end up with a matching again. This is further illustrated in Figure 6. Theorem 12 The conductance of our graph has the following bound Φ(Cn) = Θ � � 1 n6 5-7 Figure by MIT OpenCourseWare. Figure 4: Unwinding a single cycle (type B path). . As shown in Lemma 10, there are at most O(n2) canonical Proof By Lemma 8, we have Φ(G) ≥ paths to s ∈ Mn from Mn−1, and at most O(n2) canonical paths from t
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
s ∈ Mn from Mn−1, and at most O(n2) canonical paths from t ∈ Mn to Mn−1. In addition we showed in Lemma 11 that the number of type B paths through a particular transition T is bounded by |Mn ∪ Mn−1| = V (where V is the vertex set of Cn). Therefore as a whole, the number of canonical paths through a particular transition T is bounded by n 1 2bdmax | × n × | V | 2 | Since dmax = O(n2), the conductance is bounded from below by Θ n 6 and our random walk mixes in 2, which implies b = n . 4 � 1 � polynomial time. 5-8 Figure by MIT OpenCourseWare. Figure 5: Unwinding a collection of cycles (type B path). Figure by MIT OpenCourseWare. Figure 6: The encoding σT (s, t). 5-9 MIT OpenCourseWare http://ocw.mit.edu 18.409 Topics in Theoretical Computer Science: An Algorithmist's Toolkit Fall 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
https://ocw.mit.edu/courses/18-409-topics-in-theoretical-computer-science-an-algorithmists-toolkit-fall-2009/0e8570f928771e3992f59e13c91d19bc_MIT18_409F09_scribe5.pdf
MIT OpenCourseWare http://ocw.mit.edu 18.726 Algebraic Geometry Spring 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.726: Algebraic Geometry (K.S. Kedlaya, MIT, Spring 2009) Cohen-Macaulay schemes and Serre duality In this lecture, we extend Serre duality to Cohen-Macaulay schemes over a field. As in the previous lecture, let k be a field (not necessarily algebraically closed), let j : X → P = PN k be a closed immersion with X of dimension n, and let OX (1) be the corresponding twisting sheaf. 1 Cohen-Macaulay schemes and duality Let ω◦ denote a dualizing sheaf on X; remember that this choice includes a trace map H n(X, ω◦ ) → k. We then obtain natural functorial maps X X θi : Exti X (F , ω◦ → H n−i(X, F )∨ X ) because both sides are cohomological functors on the opposite category of coherent sheaves on X, and the one on the left is effaceable because it vanishes on direct sums of twisting sheaves. By the definition of a dualizing sheaf, θ0 is always an isomorphism. Theorem. The following conditions are equivalent. (a) The scheme X is equidimensional (each irreducible component has dimension n) and Cohen-Macaulay. (b) The maps θi are isomorphisms for all i ≥ 0
https://ocw.mit.edu/courses/18-726-algebraic-geometry-spring-2009/0ea66a0bdcf4f8127c826882531f1642_MIT18_726s09_lec25_serre_dual.pdf
aulay. (b) The maps θi are isomorphisms for all i ≥ 0 and all coherent sheaves F on X. This is of course meaningless if I don’t tell you what a Cohen-Macaulay scheme is. For the moment, suffice to say that a scheme is Cohen-Macaulay if and only if each of its local rings is a Cohen-Macaulay ring. That already has content, because then the theorem says that (b) is equivalent to a local condition on X, which is far from obvious. I’ll also point out that a regular local ring is always Cohen-Macaulay. This implies the following. Corollary. If X is smooth over k, then θi is an isomorphism for all i ≥ 0 and all coherent sheaves F on X. 2 Proof of the duality theorem, part 1 Even without knowing what a Cohen-Macaulay scheme is, we can at least start working to prove that condition (b) is equivalent to a local condition on X. Let us start by relating (b) to two global vanishing assertions. Lemma. The following conditions are equivalent to (b). 1 (c) For any locally free coherent sheaf F on X, for q sufficiently large, we have H i(X, F (−q)) = 0 for all i < n. (c′) For q sufficiently large, we have H i(X, OX (−q)) = 0 for all i < n
https://ocw.mit.edu/courses/18-726-algebraic-geometry-spring-2009/0ea66a0bdcf4f8127c826882531f1642_MIT18_726s09_lec25_serre_dual.pdf
�ciently large, we have H i(X, OX (−q)) = 0 for all i < n. Note that condition (c) is a sort of opposite to Serre’s vanishing theorem, which gives the vanishing of H i(X, F (q)) for i > 0 and q sufficiently large. Proof. Given (b), for any locally free coherent sheaf F on X, we have H i(X, F (−q)) = Extn−i(F (−q), ω◦ )∨ X X = Extn−i(OX , F ∨ ⊗ ω◦ (q))∨ X = H n−i(X, F ∨ and this vanishes for n − i > 0 and q large by Serre’s vanishing theorem. Thus (b) implies (c). X (q))∨ ⊗ ω◦ It is clear that (c) implies (c′). Given (c′), it follows that H n−i(X, ·)∨ is effaceable for all i > 0 since we can cover F with a direct sum of twisting sheaves. Hence θi is the natural map between two universal cohomological functors, hence is an isomorphism. Thus (c′) implies (b). X We next reformulate this in local terms, using Serre duality on P . Lemma. The following condition is equivalent to (b). (d) For all i < n, Ext P (j∗OX , ωP ) = 0. N −i Remember that no matter what X is, we have Ext P proved this in the course of constructing the dualizing sheaf ω◦ X . N −i (j∗
https://ocw.mit.edu/courses/18-726-algebraic-geometry-spring-2009/0ea66a0bdcf4f8127c826882531f1642_MIT18_726s09_lec25_serre_dual.pdf
the course of constructing the dualizing sheaf ω◦ X . N −i (j∗OX , ωP ) = 0 for i > n: we Proof. By Serre duality on P (and choosing an isomorphism H n(P, ωP ) = k), we may identify ∼ H i(X, OX (−q)) = H i(P, j∗OX (−q)) = ∼ ∼ ExtN −i P (j∗OX , ωP (q))∨ . So (c) is equivalent to the condition that for q sufficiently large, ExtN P for all i < n. Recall from earlier that for q large, −i(j∗OX , ωP (q)) = Γ(P, Ext P ExtN P N −i Since Ext P large if and only if Ext N P (j∗OX , ωP ) is coherent, Γ(P, Ext P (j∗OX , ωP (q))) = Γ(P, Ext P −i(j∗OX , ωP ) = 0. N −i N −i N −i −i(j∗OX , ωP (q)) = 0 (j∗OX , ωP )(q)). (j∗OX , ωP )(q)) vanishes for q sufficiently Condition (d) can be rewritten as follows. Lemma. The following condition is equivalent to (b). (e) For each point x ∈ X, if A = OP,x and I is the ideal of A defining X at x, then for all i < n, ExtN −i A (A/I, A) = 0. Proof. This translates directly from (d) once we remember that ωP is locally free of rank
https://ocw.mit.edu/courses/18-726-algebraic-geometry-spring-2009/0ea66a0bdcf4f8127c826882531f1642_MIT18_726s09_lec25_serre_dual.pdf
. This translates directly from (d) once we remember that ωP is locally free of rank 1 on P . This is almost the local condition we are seeking, except that it still refers to the position of X within P . 2 3 The Cohen-Macaulay condition To get rid of the dependence of our duality condition on the relative geometry of X within P , we need some more sophisticated commutative algebra. Proposition. Let A be a regular local ring and let M be a finitely generated A-module. Then for any nonnegative integer n, the following are equivalent. (a) We have Exti(M, A) = 0 for all i > n. (b) For any A-module N, we have Exti(M, N) = 0 for all i > n. (c) There exists a projective resolution 0 → Ln → · · · → L1 → L0 → M → 0 of M at length at most n. Proof. See Hartshorne Proposition III.6.10A (and associated Matsumura reference) and ex­ ercise III.6.6. The smallest integer for which this holds is called the projective dimension of M (if it exists), denoted pdA(M). For instance, M is projective if and only if pdA(M) = 0. For M a module over a ring A, a regular sequence is a sequence x1, . . . , xn of elements of A such that for i = 1, . . . , n, xi is not a zerodivisor on M/(x1, . .
https://ocw.mit.edu/courses/18-726-algebraic-geometry-spring-2009/0ea66a0bdcf4f8127c826882531f1642_MIT18_726s09_lec25_serre_dual.pdf
1, . . . , n, xi is not a zerodivisor on M/(x1, . . . , xi−1)M. For A a local ring, the depth of M is the maximal length of a regular sequence with all xi in the maximal ideal of A. Proposition. For A a regular local ring and M an A-module, pdA(M) + depthA(M) = dim(A). Proof. See Hartshorne Proposition III.6.12A (and associated Matsumura reference). We can finally give a local equivalent to condition (b) from the duality theorem. Recall that our last equivalent (e) said that for each x ∈ X, for A = OP,x and I the ideal of A defining X at x, ExtN −i(A/I, A) = 0 for all i < n. This is equivalent to pdA(A/I) ≤ N − n, and hence to depthA(A/I) ≥ n. The trick is that if M is an A/I-module, then depthA(M) = depthA/I (M). Thus we have the following. A Lemma. The following condition is equivalent to (b). (f ) For each point x ∈ X, if B = OX,x, then depthB(B) ≥ n. On the other hand, we always have depthB(B) ≤ dim(B) ≤ n, so it is equivalent to require depthB(B) = dim(B) = n. This condition depthB (B) = dim(B) is in fact the definition of a Cohen-Macaulay lo­ cal ring B. Any regular local ring is Cohen-Macaulay, since we
https://ocw.mit.edu/courses/18-726-algebraic-geometry-spring-2009/0ea66a0bdcf4f8127c826882531f1642_MIT18_726s09_lec25_serre_dual.pdf
lo­ cal ring B. Any regular local ring is Cohen-Macaulay, since we can use generators of the cotangent space as a regular sequence. But the Cohen-Macaulay condition is much more permissive; for instance, any local complete intersection is Cohen-Macaulay. 3
https://ocw.mit.edu/courses/18-726-algebraic-geometry-spring-2009/0ea66a0bdcf4f8127c826882531f1642_MIT18_726s09_lec25_serre_dual.pdf
MEDIA AND BOUNDARY CONDITIONS Media: conductivity σ, permittivity ε, permeability μ Media are the only tools we have to create or sense EM fields Conductivity (σ): ⎯J (current density, A/m2) = nq v = σ E n = #q’s/m3, q = charge (Coulombs), =v average velocity (m/s) Semiconductors: P{escape} ∝ e-W/kT + - ∞ σ Superconductor Metal Metals: - J ∝ v = at + - + = + - + qE = m f t m ⎯E Semiconductor + - t , 0 q m ∴ σ ∝ 300K Temperature T t ; t = f(T ) emp (t = time before collisions reset v ≅ 0) L2-1 DIELECTRICS Vacuum: E = ε o D nˆda • (cid:119) ∫∫ S free charge density = = (cid:120) ∫∫∫ V ρ f D ρ f dv ⎯E - + +- +- ε +- +- +- +- +- +- medium )+ ρ ρ ( p f dv Dielectric Materials: D E = ε = ε + E P o (cid:119) ∫∫ S ε o E nda = ˆ • (cid:120) ∫∫∫ V • − (cid:120) ∫∫∫ P nda = ˆ S (cid:119) ∫∫ ρp is polarization (surface) charge density dv ρ p V electron cloud nucleus +q Atom - d ⎯E polarized atoms Metal plates + + + + + - - - - -
https://ocw.mit.edu/courses/6-013-electromagnetics-and-applications-spring-2009/0ec2c39ffccb37e83b43f6f59868f8d7_MIT6_013S09_lec02.pdf
- d ⎯E polarized atoms Metal plates + + + + + - - - - - E P ρv = 0 ρp + + + + + - - - - - =P “Polarization Vector” L2-2 MAGNETIC MATERIALS Basic Equations: B n • ˆda = 0 (cid:119)∫∫S B = μoH in vacuum B = μH = μo (H + M) M = “Magnetization Vector” μ = permeability e + + e B e B e + atoms magnetic domain ⎯H = 0 magnetic domains domain wall ⎯M L2-3 SATURATION AND HYSTERISIS ⎯H = 0 magnetic domains ⎯H > 0 ⎯M 1 B H W [J/m ] Magnetic energy density 2 • = m 3 ⎯B slope ≅ μo Residual flux density Br ⎯B 0 slope ≅ μ ⎯H -Hc magnetic coercive force 0 saturation ⎯H Area = hysterisis loss [J/m3] L2-4 MEDIA PARAMETERS Conductivity σ [Siemens/m] Dielectric constant (ε/ε ) o Relative permeabilities μ/μ o ~10-15 10-12 Paraffin Glass Dry earth Distilled water 2x10-4 Sea water Iron Copper Silver 1.0 Copper Bismuth 3-5 107 1.8-2.0 Silver 5.8x107 Sandy soil 6.1x107 Vacuum Wood (fir) 10-4-10-5 Teflon, petroleum 2.1 Vaseline Paper Polystyrene 0.99983 0.99998 0.999991 0.999991 1.000000 1.0000004 1.
https://ocw.mit.edu/courses/6-013-electromagnetics-and-applications-spring-2009/0ec2c39ffccb37e83b43f6f59868f8d7_MIT6_013S09_lec02.pdf
.99983 0.99998 0.999991 0.999991 1.000000 1.0000004 1.00002 250 600 2000 5000 100,000 Supermalloy 1,000,000 2.2 Water 2-3 Vacuum 2.6 Air 2.6 Aluminum 3.8 Fused quartz Cobalt 4.15 Nickel Ice Pyrex glass 5.1 Aluminum oxide 8.8 Ethyl alcohol 24.5 Mu metal 81 Water Titanium dioxide 100 Mild steel Iron L2-5 INTEGRAL MAXWELL’S EQUATIONS Graphical Equations: D nˆda • (cid:119) ∫∫ S = (cid:120) ∫∫∫ V ρ dv B nˆda • = 0 (cid:119) ∫∫ S s E d • (cid:118) ∫ c = − ∂ ∫∫ A t ∂ B • nˆda Gauss Gauss Faraday • H ds = (cid:118) ∫ c ∫∫ A J • nˆda ∂+ ∫∫ A t ∂ D • nˆda Ampere D E, B H Constitutive relations = μ = ε ρ 0 D B E B H J D L2-6 FIELDS PERPENDICULAR TO BOUNDARIES Using Gauss’s Law: ( (cid:119) ∫∫ S ( ) D D A → 2 ⊥ ˆD nda • 1 ⊥ − ∫∫(cid:119) S ˆ D • n da = ∫∫∫ v ρ dv A = ρ s ˆn A (L
https://ocw.mit.edu/courses/6-013-electromagnetics-and-applications-spring-2009/0ec2c39ffccb37e83b43f6f59868f8d7_MIT6_013S09_lec02.pdf
da = ∫∫∫ v ρ dv A = ρ s ˆn A (Lim A → 0, δ2 <<A) ) : 1D δ 2D surface charge density ρs surface S Therefore: D 1 ⊥ − D 2 ⊥ = ρ s yields: ) nˆ D D − 2 1 ( • = ρ s ∫∫(cid:119) A ˆB nda B 1 ⊥ ( = • − B 2 ⊥ ) A 0 yields: = ( • ˆn B B 0 − = 1 2 ) L2-7 FIELDS PARALLEL TO BOUNDARIES Using Faraday’s Law: c (cid:118) ∫ d ( dt A∫∫(cid:119) E → ∫(cid:118) i E ds ) 2 // = − 1// E E • ds − L C = - ∂ ∫∫ A t ∂ ˆ B • nda i B da → 0 (Lim δ→0) Therefore: ⎯E1// =⎯E2// ( ˆn E E 0 − × = ) 1 2 Using Ampere’s Law: ˆn E1// 1E 2E aˆda,n L δ ds A -E2// (J + D/ t) • da ∂ ∂ = ∫∫ A H • ds ∫(cid:118) c c∫(cid:118) i H ds ( H → 1// − H ) 2 // Therefore: ( × ˆn H H J − s 1 = ) 2 L = A
https://ocw.mit.edu/courses/6-013-electromagnetics-and-applications-spring-2009/0ec2c39ffccb37e83b43f6f59868f8d7_MIT6_013S09_lec02.pdf
Therefore: ( × ˆn H H J − s 1 = ) 2 L = A∫∫(cid:119) ( J nˆ • s → a i J da ) ∂ A∫∫(cid:119) i D da t ∂ → 0 − L L2-8 PERFECT CONDUCTORS Electric Fields: {if σ→∞ and⎯E ≠ 0} ⇒ { (J D/ t) da + ∂ ∂ } ⇒ { }⇒ {Wm = μH2/2 [J/m3] → ∞, and wm → ∞} E= σ → ∞ H → ∞ since = J i i H ds (cid:63)c ∫ ∫∫ A Therefore: Magnetic Fields: {If E 0 and = Therefore: ⎯E = 0 inside perfect conductors ˆ i(cid:119) ∫∫ ∫ E n da ε s v ρ = 0 (since dv = ρ i i E ds} B nˆda = − (cid:118) ∫ c ∂ ∂ ∫∫ A t ⎯H = 0 inside perfect conductors (if σ = ∞, and H(t=0) = 0) ⇒ ) { B t 0} ∂ ∂ = Superconductors (Cooper pairs don’t impact lattice): ≅ because σ = ∞ B 0 inside Cooper pairs of electrons disassociate and superconductivity fails when the external B(T) is above a critical threshold L2-9 SUMMARY: BOUNDARY CONDITIONS General Boundary Conditions: ) ˆn D D − 2 1 ) 2 ˆn B B 0 − ( • ( • = 1 = �
https://ocw.mit.edu/courses/6-013-electromagnetics-and-applications-spring-2009/0ec2c39ffccb37e83b43f6f59868f8d7_MIT6_013S09_lec02.pdf
1 ) 2 ˆn B B 0 − ( • ( • = 1 = ρ s 1 1E ,D 1 1H ,B ρs ρs ⎯Js ( × ( × ˆn E E 0 − = 1 ˆn H H J − s = 1 2 ) ) 2 H ,B 2 2 E ,D 2 2 Inside Perfect Conductors: 2 D = B = E = 0 2 2 • = ˆn D • 1 = ρ s ˆn B 0 1 ˆn E 0 1 ˆn H J 1 s = × × = ⇒⎯B is parallel to perfect conductors ⇒⎯E is perpendicular to perfect conductors L2-10 MIT OpenCourseWare http://ocw.mit.edu 6.013 Electromagnetics and Applications Spring 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
https://ocw.mit.edu/courses/6-013-electromagnetics-and-applications-spring-2009/0ec2c39ffccb37e83b43f6f59868f8d7_MIT6_013S09_lec02.pdf
6.012 - Microelectronic Devices and Circuits – Fall 2009 Inverter Analysis and Design The inverter stage is a basic building block for digital logic circuits and memory cells. A generic inverter stage is illustrated below on the left. It consists of two devices, a pull-up device, which is typically either a bipolar junction transistor or an enhancement mode field effect transistor, and a pull-down device, which might be another transistor, or a resistor, current source, diode, etc. The stage load which is shown in the figure represents the input resistance of the following stage, which is typically a stage (or n stages) just like the original stage. (a) A generic inverter stage (b) The static currents to calculate vOUT(vIN) An important piece of information about an inverter stage is its static transfer characteristic, vOUT(vIN). To calculate this characteristic we sum the currents into the output node of the inverter, as is illustrated above on the right. With all of these currents written as functions of vIN and vOUT, this sum yields the desired relationship: iPU(vIN, vOUT) = iPD(vIN, vOUT) + iSL(vOUT) As an example, consider the MOSFET inverter circuit shown at the top of the next page with an n-channel MOSFET pull-down and a resistor pull-up. The MOSFET is characterized by its K-value and by its threshold voltage, VT (we will assume for simplicity that α is 1). To analyze this circuit we not first that with a MOSFET pull- down, the static input current is zero and if the stage output is connected to the input of a similar stage, the static stage load current will also
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
- down, the static input current is zero and if the stage output is connected to the input of a similar stage, the static stage load current will also be zero, and the equation above is simply iPU = iPD. With a resistor pull-up, the pull-up current, iPU, is (VDD - vOUT)/R and the pull-down current, iPD, is the MOSFET drain current. This current depends on the gate-to-source voltage, vGS, which is the same as vIN, and the drain-to-source voltage, vDS, which is the same as vOUT. With vIN less than VT, the pull-down current is zero and vOUT is VDD. As vIN increases past VT, vOUT will initially be larger than 1 iSL(vOUT) [ = n iIN(vOUT)]iIN(vIN)+-vIN+-vOUTPullUpPullDownStage Load+ VDDiPU(vIN, vOUT)iPD(vIN, vOUT)+-vIN+-vOUTPullUpPullDownStage Load+ VDD (vIN - VT), and the device will be in saturation so that iPD will be K(vIN - VT)2/2. vOUT is found by setting iPD equal to iPU: iPU = iPD A MOSFET inverter with an n-channel MOSFET pull-down and resistor pull-up. Substituting yields which we solve for vOUT (VDD - vOUT)/R = K(vIN - VT)2/2 vOUT = VDD - RK(vIN - VT)2/2 Clearly vOUT decreases as vIN increases. When vOUT reaches vIN - VT, the pull-down goes from saturation to the linear region and iPD changes to K(vIN - VT - vOUT/2)vOUT, and the desired relationship is found by solving the quadratic (VDD - vOUT)/R = K(vIN - VT - vOUT/2)vOUT The resulting transfer characteristic is plotted in the course text in Figure 15.8. Curves for other pull-up devices are also shown in this section of the text.
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
plotted in the course text in Figure 15.8. Curves for other pull-up devices are also shown in this section of the text. We can identify six features of a given inverter design which we can use to evaluate it and compare it to other designs. They are: 1. The logic levels, VHI, and VLO 2. The noise margins 3. The switching times, τHI→LO, and τLO→HI 4. The power dissipation 5. The fan-out and fan-in sensitivities 6. The manufacturability 2 +-vIN+-vOUT+ VDDRVT, KiIN = 0iSL = 0iPU = (V - vOUT)/RiPD = 0 if (vIN - VT) < 0 < vOUT = K(vIN - VT)^2/2 if 0 < (vIN - VT) < vOUT = K(vIN - VT - vOUT/2)vOUT if 0 < vOUT < (vIN - VT) The logic levels are found by insisting that VHI and VLO are such that VHI applied to the input of an inverter results in an output of VLO, and that VLO applied to the input of an inverter results in an output of VHI. Mathematically, if the transfer characteristic is vOUT = f(vIN), we must find the solutions to the equation vOUT = f(f(vOUT)). For useful inverter stages there will be three solutions to this equation, but only the largest and smallest values are valid; the middle solution is unstable and will not be realized in practice. VHI and VLO are often most easily found with the aid of the graphical technique shown in Figure 15.5 of the course text. To determine the switching times we must first recognize that the reason an inverter output does not instantaneously change in response to an change of its input is because there is charge
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
the reason an inverter output does not instantaneously change in response to an change of its input is because there is charge stored on the output node (on the gate of the load stage, for example, if we are discussing inverters with MOSFET pull-downs as in our earlier example). This is illustrated below: The generic inverter stage with the non-linear charge store shown explicitly. When the input is switched from VHI to VLO, the pull down device typically turns off (so iPD = 0), and the output switches from VLO to VHI. When this happens the output node must be charged up, and this charge is supplied by the pull-up device. This was illustrated on the left in the next figure. The charging current, iCH, which is dqN/dt, is the difference between iPU and iSL (assuming as is usually the case that iPD = 0): iCH ≈ iPU - iSL = dqN/dt The larger this current, the faster the charge store changes, and the faster the output switches. (Note that the corresponding statements can be made about the discharging cycle shown on the right in the figure.) In general the charge stored on the output node, qN, will be a non-linear function of vOUT, and it will not be possible to calculate vOUT(t) and determine the switching time analytically. There are two cases in which we can calculate the switching time, 3 +-vIN+-PullUpPullDownStage Load+ VqN(vOUT) vOUT however, and to the extent that we can approximate a given situation as one or the other of these to cases, we can estimate the switching time analytically. The first special case is when the charging (
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
these to cases, we can estimate the switching time analytically. The first special case is when the charging (or discharging) current is constant. We can calculate the change in the amount of stored charge when vOUT changes from VLO to VHI, and knowing this the charging time is simply this charge divided by the (a) Finding τLO→HI (charging cylce) vIN: VHI→VLO; vOUT: VLO →VHI iCH = iPU - iPD - iSL (b) Finding τHI→LO (discharge cycle) vIN: VLO →VHI; vOUT: VHI→VLO; iDCH = iPD - iPU + iSL charging current, which we have approximated as being constant, ICH (we can say the same about the discharge cycle): τLO→HI ≈ ΔqN/ICH, and τHI→LO ≈ - ΔqN/IDCH [Note: frequently designers do not require that the node be completely charged, but say the node has switched when 90% of the store has been built up (in which case, of course, ΔqN is replaced by 0.9 ΔqN]. The second special case is if the charge store can be modeled as a linear capacitor, CL (i.e., qN ≈ CLvOUT). Then we can write dvOUT/dt = iCH(vOUT)/CL to get a differential equation for vOUT(t). We should be able to solve this equation numerically, if we can not do so analytically. If the charge store can be modeled as a linear capacitor and the charging and dischargind currents can be modeled as constant, then τLO→HI ≈ CL(VHI - VLO)/ICH, and τHI→LO ≈ CL(VHI - VLO)/IDCH 4 iSL(vOUT) [ = n iIN(vOUT)]+-+-vOUTPullUpStage Load+ VDD
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
VLO)/IDCH 4 iSL(vOUT) [ = n iIN(vOUT)]+-+-vOUTPullUpStage Load+ VDDiPU(vIN, vOUT)iPD = 0iIN(vIN)qN(vOUT)iCHPull down offVLO ! VHIvIN = VLOiSL(vOUT) [ = n iIN(vOUT)] +-+-vOUTPullUpPullDownStage Load+ VDDiPU(vIN, vOUT)iPD(vIN, vOUT)iIN(vIN)qN(vOUT)iDCHVHI ! VLOvIN = VHI We have already included the transient when the input is switched from VLO to VHI in our discussion, but just to make sure this is clear, in this part of the cycle, the pull down device turns on and the output switches from VHI to VLO. The most important difference is that the charge store now discharges and does so through the pull-down device. The pull-down device must conduct this discharge current and the current flowing through the pull-up device (less that into the stage load). In this case, a large pull-up device current is not desirable because it makes this switching time long, whereas a large pull-up current makes the other switching time short. In practice one usually wants to minimize the sum of these two switching times which means that we in general want to design the circuit to have equal magnitude charging and discharging currents, if possible. An example to the switching transient situation in the MOSFET inverter with a resistive pull-up that we illustrated earlier is shown in the figures below. The gate capacitance of the loading stage(s) has been modeled as a linear capacitor. The charging of the store clearly occurs with an RC time constant exponential; the discharging transient is more complex (and typically is much the shorter of the two). (a) Finding τLO→HI (charging cylce) vIN: VHI→VLO; vOUT:
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
of the two). (a) Finding τLO→HI (charging cylce) vIN: VHI→VLO; vOUT: VLO →VHI iCH = iPU (b) Finding τHI→LO (discharge cycle) vIN: VLO →VHI; vOUT: VHI→VLO; iDCH = iPD - iPU The power dissipation consists of two components. One is the static power; the other is the dynamic, or switching, power. Then the ouput is high, the static power dissipated is VDDIPU(output high); when the output is low, the static power dissipated is VDDIPU(output low). To get one number to work with we commonly say an average inverter will have its output high half the time, on average, and low the other half. Thus the average static power dissipation is (VDDIPU(output high) + VDDIPU(output low))/2. 5 +-+-vOUT+ VRVT, KiDCH = iPD - iPUiPU = (V - vOUT)/RvIN = VHI iPDCLVHI !VLO+-vIN = VLO+-vOUT+ VRiCH = iPUiPU = (V - vOUT)/ROFFCLVLO !VHI The dynamic power dissipation is due the fact that each low-high-low cycle the output node is charged to roughly VDD, and then discharged to roughly zero volts. If we can approximate the node charge store with a linear capacitor, CL, the energy 2/2, and the amount of energy stored on the dissipated in charging it to VDD is CLVDD 2/2. This later amount of energy is dissipated when the node is node is also CLVDD discharged so in one cycle the total energy dissipated is CLVDD If the gate is operating at a frequency of f, the
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
the total energy dissipated is CLVDD If the gate is operating at a frequency of f, the average dynamic power dissipation is f times this or f CLVDD 2. 2. You can refer to the course text for discussions of noise margins, fan in and fan out, and manufacturability. 6 MIT OpenCourseWare http://ocw.mit.edu 6.012 Microelectronic Devices and Circuits Fall 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
https://ocw.mit.edu/courses/6-012-microelectronic-devices-and-circuits-fall-2009/0eddab43e246fc2d62368fe37516020c_MIT6_012F09_lec14_inverter.pdf
T. Speller January 11, 2007 Scenarios as a creative practice Scenarios are another creative practice increasingly being used by companies and gaining favor from the success of Shell Oil with their future scenarios process (see references below). We intend our system architectures to not just satisfy current requirements but also be easily evolvable over time. One way of working towards evolvability is by designing a product family. The family can be developed and produced all at one time, or to mitigate risk may be started with one product entry followed by variants of the product over time. This controlled release of new family members manages risk, can spread out resource requirements and reduces the need for a high upfront capital investment. Therefore, another ‘ideal’ design attribute is the system architecture’s ability to evolve. How do we plan for the evolution of a product? One strategy is to make the current first release version of the SA so flexible that it can be evolved quickly and at minimal cost. However, typically in order to have notions of how to design in the flexibility we must know the future. Scenarios, which derives its name from scriptwriting in plays, is one means of thinking through possible futures. Your creative team can think of many different possible futures affecting your enterprise and its products. How do you know that you have explored all possible futures? You don’t know, but large fluctuations in the “environment,” or disturbances, must be considered, not just the different normal, possible paths out into the future. This is a ‘what if’ analysis. One must consider the seemingly improbable disturbances that can, and as we have seen in 9/11 and the recent tsunami, do occur. The scenarios can be done by experts, managers, futurists, your SA team, yourself and … . Think about how your product may be misused or used for purposes not originally intended. In this case you should consider testing it for robustness in this outside usage or ‘protecting’ the product from being misused. Once these scenarios are developed and discussed, their impact must be discounted to the present in your SA design as much as you judge is appropriate. In this viewpoint one might consider the selected present SA to be the result of all plausibly considered futures. By modularity and platforming along with other SA strategies, you can achieve flexibility and its close relative, extensibility
https://ocw.mit.edu/courses/esd-34-system-architecture-january-iap-2007/0ee4b57ff758f54fbf8bd701834d412d_scenarios.pdf
plausibly considered futures. By modularity and platforming along with other SA strategies, you can achieve flexibility and its close relative, extensibility, with minimal or modest added cost to your present SA design. A good book by which to start being convinced of the usefulness of scenarios is http://www.amazon.com/exec/obidos/tg/detail/-/1578518202/qid=1105579205/sr=1- 32/ref=sr_1_32/002-5285815-5183236?v=glance&s=books The Living Company by Arie de Geus. Also, here are two websites to review on scenarios http://www.shell.com/home/content/aboutshell-en/our_strategy/shell_global_scenarios __________ _____________________________________________________ /dir_global_scenarios_07112006.html. (Accessed 21 August 2007). _________________________________________________ and http://www.sric-bi.com/consulting/ScenarioPlan.shtml
https://ocw.mit.edu/courses/esd-34-system-architecture-january-iap-2007/0ee4b57ff758f54fbf8bd701834d412d_scenarios.pdf
MIT OpenCourseWare http://ocw.mit.edu 6.854J / 18.415J Advanced Algorithms Fall 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. � � 18.415/6.854 Advanced Algorithms November 19, 2008 Approximaion Algorithms: MAXCUT Lecturer: Michel X. Goemans 1 MAX-CUT problem MAX-CUT Problem: Given a graph G = (V, E) and weights on the edges w : E cut (S : S¯), S ⊆ V that maximizes w(S : S¯) = � MIN-CUT Problem: find a cut (S : S¯) that minimizes w(S : S¯). S) w(e). e∈(S: ¯ → R+, find a There is a polynomial algorithm for the MIN-CUT problem: use the min s − t cut algorithm on each pair of vertices (or, better, for a fixed s), and take the smallest of them. However, the MAX-CUT problem is NP-hard, and we’ll try several ways of designing approximation algorithms for it. 2 Idea #1: Local Search Algorithm: Start from any cut (S : S¯). Define the neighborhood N (S : S¯) of the cut to be the MOVE neighborhood: all the cuts that result from moving one vertex from one side of the cut to the other side. Consider a locally maximum cut for this neighborhood. Lemma 1 If (S : S¯) is a local maximum for the MOVE neighborhood, then w(S : S¯) ≥ 2 w(E) ≥ 1 OP T . 2
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
the MOVE neighborhood, then w(S : S¯) ≥ 2 w(E) ≥ 1 OP T . 2 1 Proof of lemma 1: Look at a vertex i ∈ V . Let Ci be the set of all edges (i, j) ∈ E that are part of the cut (S : S¯) (that is if i ∈ S then j ∈ S ¯ and vice versa). Let Ai be the set of all edges (i, j) ∈ E that are not part of the cut (S : S¯). Since moving any single vertex i to the other side of the cut does not improve the weight of the cut, we know that: Summing over all vertices i, we get: w(Ci) ≥ w(Ai). � w(Ci) ≥ � w(Ai), i∈V i∈V or 2w(S : S¯) ≥ 2w(E\(S : S¯)). Rearranging, we get: or Remarks: 4w(S : S¯) ≥ 2w(E) w(S : ¯ S) ≥ 1 2 w(E) ≥ 1 2 OP T. � (a) The bound of 1/2 cannot be improved for this MOVE neighborhood: Consider a k-vertex cycle, where k is a multiple of 4, as the graph G (with unit weights). The best cut will include Lec18-1 all edges. However, if we start from a cut in which the edges of the cycle alternate in and out of the cut, we have a locally optimum solution with only k/2 edges in the cut. (b) The local search algorithm based on the MOVE neighborhood for MAX-CUT takes expo­ nentially many steps in the worst-case. This is true even for graphs that are 4-regular (each vertex has exactly
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
-case. This is true even for graphs that are 4-regular (each vertex has exactly 4 neighbors) (Haken and Luby [1]). For 3-regular graphs the algorithm is polynomial (Poljak [4]). → (c) To capture the complexity of local search, Johnson, Papadimitriou and Yannakakis [3] have defined the class PLS (Polynomial Local Search). Members of this class are optimization 2S . We say problems of the form max{f (x) : x ∈ S} together with a neighborhood N : S that v ∈ S is a local optimum if c(v) = max{c(x) : x ∈ N (v)}. To be in PLS, we need to have polynomial-time algorithms for (i) finding a feasible solution, (ii) deciding if a solution is feasible and if so computing its cost, and (iii) deciding if a better solution in the neighborhood N (v) of a solution v exists and if so finding one. They introduce a notion of reduction, and this leads to PLS-complete problems for which any problem in PLS can be reduced to it. Their notion of reduction implies that if, for one PLS-complete problem, one has a polynomial-time algorithm for finding a local optimum then the same true for all PLS problems. In particular, MAX-CUT with the MOVE neighborhood is PLS-complete [5]. Furthermore, it follows from Johnson et al. [3] that the obvious local search algorithm is not an efficient way of finding a local optimum for a PLS-complete problem; indeed, for any PLS-complete problem,
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
ing a local optimum for a PLS-complete problem; indeed, for any PLS-complete problem, there exist instances for which the local search algorithm of repeatedly finding an improved solution takes exponential time. The result of Haken and Luby above is thus just a special case. Still, this does not preclude other ways of finding a local optimum. 3 Idea #2: Random Cut Algorithm: There are 2|V | possible cuts. Sample a cut randomly using a uniform distribution over all possible cuts in the graph: ∀v ∈ V, P r(v ∈ S) = 1 , independently for all vertices v ∈ V . 2 Lemma 2 This randomized algorithm gives a cut with expected weight that is ≥ 1 OP T . 2 Proof of lemma 2: E[w(S : ¯ S)] = E[ w(e)I(e ∈ (S : ¯ S))] = � e∈E � e∈E = w(e) · 1 2 = 1 2 w(E). � w(e) · P r(e ∈ (S : ¯ S)) e∈E � Using the method of conditional expectations, we can transform this randomized algorithm into a deterministic algorithm. The basic idea is to use the following identity for a random variable f and event A: E[f ] = E[f A]P r(A) + E[f A¯]P r(A¯) = E[f |A]P r(A) + E[f |A¯](1 − P r(A)) | | {E[f |A], E[f |A¯] }. ≤ max In our setting, we consider the vertices in a specific order, say v1, v2, already decided/conditioned on the position (i.e. whether or not they are in S) of v1, Now, condition on whether
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
(i.e. whether or not they are in S) of v1, Now, condition on whether vi ∈ S. Letting f = w(S : S¯), we get: , and suppose we have , vi−1. · · · · · · E[f |{v1, · · · , vi−1} ∩ S = Ci−1] ≤ max(E[f |{v1, · · · , vi−1} ∩ S = Ci−1, vi ∈ S], E[f |{v1, · · · , vi−1} ∩ S = Ci−1, vi ∈/ S]). Lec18-2 Both terms in the max can be easily computed and we can decide to put vi on the side of the cut which gives the maximum, i.e. we set Ci to be either Ci−1 or Ci−1 ∪ {vi} in such a way that: E[f |{v1, · · · , vi−1} ∩ S = Ci−1 ≤ E[f |{v1, · · · , vi} ∩ S = Ci]. When we have processed all inequalities, we get a cut (Cn : C¯ n) such that and this provides a deterministic 0.5-approximation algorithm. 1 w(E) ≤ E[f ] ≤ w(Cn : C¯ n), 2 Examining this derandomized version more closely, we notice that we will place vi on the side , vi−1}. of the cut that maximizes the total weight between vi and the previous vertices {v1, v2, This is therefore a simple greedy algorithm. · · · Remarks: (a) The performance guarantee of the randomized algorithm is no better than 0.5; just consider the complete graph on n vertices with unit weights. Also, the performance guarantee of
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
consider the complete graph on n vertices with unit weights. Also, the performance guarantee of the greedy algorithm is no better than 0.5 int he worst-case. 4 Idea #3: LP relaxation Algorithm: Start from an integer-LP formulation of the problem: max s.t. � w(e)xe e∈E xe ∈ {0, 1} ∀e ∈ E � � xe + (1 − xe) ≤ |C| − 1 ∀cycle C ⊆ E ∀F ⊆ C, |F | odd ⇔ e∈F e∈C\F � � xe − e∈F e∈C\F xe ≤ |F | − 1 ∀cycle C ⊆ E ∀F ⊆ C, |F | odd Since we have a variable xe for each edge (if xe = 1 than e ∈ (S : S)), we need the second type of constraints to guarantee that S is a legal cut. The validity of these constraints comes from the fact that any cycle and any cut must intersect in an even number of edges. even number of edges that are in the cut. ¯ Next, we relax this integer program into a LP: � max w(e)xe s.t. e∈E 0 ≤ xe ≤ 1 ∀e ∈ E � � xe − xe ≤ |F | − 1 ∀cycle C ⊆ E ∀F ⊆ C, |F | odd. e∈F e∈C\F This isa relaxation of the maximum cut problem, and thus provides an upper bound on the value of the optimum cut. We could try to solve this linear program and devise a scheme to “round” the possibly fractional solution to a cut. Remarks: Lec18-3 (a) This LP can be solved
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
to “round” the possibly fractional solution to a cut. Remarks: Lec18-3 (a) This LP can be solved in a polynomial time. One possibility is to use the ellipsoid algorithm as the separation problem over these inequalities can be solved in polynomial time (this is not trivial). Another possibility is to view the feasible region of the above linear program as the projection of a polyhedral set Q ⊆ Rn 2 with O(n3) number of constraints; again, this is not obvious. (b) If the graph G is planar, then all extreme points of this linear program are integral and correspond to cuts. We can therefore find the maximum cut in a planar graph in polynomial time (there is also a simpler algorithm working on the planar dual of the graph). (c) There exist instances for which OP T ∼ 1 (or ∃G = (V, E), w(e) = 1, OP T ≤ n( 1 + �), LP ≥ n(1 − �)), which means that any rounding algorithm we could come up with will not guarantee a factor better than 1 .2 LP 2 2 5 Idea #4: SDP relaxation The idea is to use semidefinite programming to get a more useful relaxation of the maximum cut problem. This is due to Goemans and Williamson [2]. Instead of defining variables on the edges as we did in the previous section, let’s use variables on the vertices to denote which side of the cut a given vertex is. This leads to the following quadratic integer formulation of the maximum cut problem: max s.t. � w(i, j) 1 − yiyj 2 (i,j)∈E yi ∈ {1, −1}n ∀i ∈ V. Here we have defined a variable yi for each vertex i
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
∀i ∈ V. Here we have defined a variable yi for each vertex i ∈ V such that yi = 1 if i ∈ S and yi = −1 otherwise. We know that an edge (i, j) is in the cut (S : S¯) iff yiyj = −1, and this explains the quadratic term in the objective function. We can rewrite the objective function in a slightly more convenient way using the Laplacian of the graph. The Laplacian matrix L is defined as follows: ⎧ ⎪0 ⎨ lij = −w(i, j) ⎪� ⎩ =i w(i, k) k:k (i, j) / ∈ E i = j, (i, j) ∈ E i = j. that is, the off-diagonal elements are the minus the weights, and the diagonal elements correspond to the sum of the weights incident to the corresponding vertex. Using the Laplacian matrix, we can rewrite equivalently the objective function in the following way: y T Ly = n � n � yiyj lij = n � � y 2 i w(i, k) − � yiyj w(i, j) i=1 j=1 i=1 k�=i (i,j)∈E = 2w(E) − � yiyj w(i, j) = 4 ⎝ � (i,j)∈E (i,j)∈E ⎛ w(i, j) 1 − yiyj 2 ⎞ ⎠ , and thus � (i,j)∈E w(i, j) 1 − yiyj 2 = 1 4 y T Ly. Lec18-
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
�E w(i, j) 1 − yiyj 2 = 1 4 y T Ly. Lec18-4 � � Thus the maximum cut value is thus equal to max{ y T LY : y ∈ {0, 1}n}. 1 4 If the optimization was over all y ∈ Rn with ||y||2 = n then we would get that 2 1 max{ 4 y T LY : y ∈ Rn , ||y||2 = n} = n 4 λmax(L), where λmax(L) is the maximum eigenvalue of the matrix L. This shows that OP T ≤ n λmax(L); this is an eigenvalue bound introduced by Delorme and Poljak. 4 Using semidefinite programming, we will get a slightly better bound. Using the Frobenius inner product, we can again reformulate the objective function as: or as 1 4 1 y T Ly = L (yy T ), 4 • 1 4 • L Y if we define Y = yyT . Observe that Y � 0, Y has all 1’s on its diagonal, and its rank is equal to 1. It is easy to see that the coverse is also true: if Y � 0, rank(Y ) = 1 and Yii = 1 for all i then Y = yyT where y ∈ {−1, 1}n . Thus we can reformulate the problem as: max s.t. • L Y 1 4 rank(Y ) = 1, ∀i ∈ V : Yii = 1, Y � 0. This is almost a semidefinite program except that the rank condition is not allowed. By removing the condition that rank(Y ) = 1, we relax
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
is not allowed. By removing the condition that rank(Y ) = 1, we relax the problem to a semidefinite program, and we get the following SDP: SDP = max s.t. • L Y 1 4 ∀i ∈ V : Yii = 1, Y � 0. Obviously, by removing the condition that rank(Y ) = 1 we only increase the space on which we maximize, and therefore the value (simply denoted by SDP ) to this semidefinite program is an upper bound on the solution to the maximum cut problem. We can use the algorithms we described earlier in the class to solve this semidefinite program to an arbitrary precision. Either the ellipsoid algorithm, or the interior-point algorithms for conic programming. Remember that semidefinite programs were better behaved if they satisfied a regular­ ity condition (e.g., they would satisfy strong duality). Our semidefinite programming relaxation of MAXCUT is particularly simple and indeed satisfies both the primal and dual regularity conditions: (a) Primal regularity conditions ∃Y � 0 s.t. Yii = 1 ∀i. This condition is obviously satisfied (consider Y = I). Lec18-5 (b) Dual regularity condition: First consider the dual problem ­ min s.t. � zi 1 4 ⎛ ⎜ ⎜ ⎜ ⎝ i∈V z1 0 . . . 0 ⎞ ⎟ ⎟ ⎟ ⎠ − L � 0, 0 z2 . . . 0
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
�� ⎟ ⎟ ⎠ − L � 0, 0 z2 . . . 0 0 ... 0 ... . . . . . . ... zn ⎞ where zi ∈ R for all i ⎛ ... 0 ... 0 . . . . . . ... zn 0 z2 . . . 0 z1 0 . . . 0 ⎜ ⎜ ⎜ ⎝ ⎟ ⎟ ⎟ ⎠ ∈ V . The regulation condition is that there exist zi’s such that − L � 0. This is for example satisfied if, for all i, zi > λmax(L). Remark: can take is equal to λmax(L), and we derive that: If we add the condition that z1 = z2 = ... = zn to the dual then the smallest value zi OP T ≤ SDP ≤ n 4 λmax(L), and therefore this SDP bound improves upon the eigenvalue bound. We will start the next lecture by proving the following theorem. Theorem 3 ([2]) For all w ≥ 0, we have that OP T ≥ 0.87856. SDP In order to prove this theorem, we will propose an algorithm which derives a cut from the solution to the semidefinite program. To describe this algorithm, we first need some preliminaries. From the Cholesky’s decomposition, we know that: Y � 0 ⇔ ∃V ∈ Rk×n , k = rank(Y ) ≤ n, s.t. Y = V T V ⇔ ∃v1, ..., vn s.t. Yij = v T vj , vi ∈ Rn . i Therefore, we can rewrite the SDP as a ’vector program’: � w(i, j) T vj 1 − vi 2 (i,j)∈
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
the SDP as a ’vector program’: � w(i, j) T vj 1 − vi 2 (i,j)∈E ∀i ∈ V : ∀i ∈ V : �vi� = 1 vi ∈ Rn . max s.t. To be continued... References [1] A. Haken and M. Luby, “Steepest descent can take exponential time for symmetric connection networks”, Complex Systems, 1988. [2] M.X. Goemans and D.P. Williamson, Improved Approximation Algorithms for Maximum Cut and Satisfiability Problems Using Semidefinite Programming, J. ACM, 42, 1115–1145, 1995. [3] D.S. Johnson, C.H. Papadimitriou and M. Yannakakis, “How easy is local search”, Journal of Computer and System Sciences, 37, 79–100, 1988. Lec18-6 [4] S. Poljak, “Integer Linear Programs and Local Search for Max-Cut”, SIAM J. on Computing, 24, 1995, pp. 822-839. [5] A.A. Sch¨affer and M. Yannakakis, “Simple local search problems that are hard to solve”, SIAM Journal on Computing, 20, 56–87, 1991. Lec18-7
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/0eef690adf10b98bffd65d5415516412_lec18.pdf
6.858 Lecture 6 Capabilities and  other Protection Mechanisms   What's the problem the authors of "confused deputy" encountered? • Their system had a Fortran compiler, /sysx/fort (in Unix filename syntax) • They wanted the Fortran compiler to record usage statistics,  but where? o Created  a special statistics  file, /sysx/stat. o Gave /sysx/fort "home files license" (kind-­‐of  like  setuid  w.r.t.  /sysx) • What  goes wrong? o User can invoke the compiler asking it to write output to /sysx/stat. § e.g. /sysx/fort /my/code.f -­‐o  /sysx/stat o Compiler  opens supplied path name, and succeeds, because of its license. o User alone  couldn't have written  to  that /sysx/stat file. • Why isn't the /sysx/fort thing just a bug in the compiler? o Could, in principle, solve  this  by  adding checks  all over the  place. o Problem: need to add checks virtually everywhere files are opened. o Perfectly correct code becomes buggy once it's part of a setuid binary. • So what's the "confused deputy"? o The compiler is running on behalf of two principals: § § the user principal (to  open user's files) the compiler principal (to open compiler's files) o Not clear what principal's privileges should be used at any given time. Can  we solve this confused deputy problem in Unix? • Suppose gcc wants to keep statistics in /etc/gcc.stats • Could  have a special setuid program that only writes to that file o Not so convenient:  can't just open  the  file  like  any  other. • What if we make gcc setuid to some non-­‐root user
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
like  any  other. • What if we make gcc setuid to some non-­‐root user  (owner  of stats  file)? o Hard  to  access  user's  original files. • What  if gcc is setuid-­‐root? (Bad  idea, but let's  figure  out why..) o Lots  of potential for buffer  overflows  leading to  root access. o Need to instrument every place where gcc might open a file. • What check should we perform when gcc is opening a file? o If it's an "internal"  file  (e.g. /etc/gcc.stats), maybe no check. o If it's a user-­‐supplied  file, need to make sure user can access it. o Can  look at the permissions for the file in question. o Need to also check permissions on directories leading up to this file. • Potential problem: race conditions. o What if the file changes between the time we check it and use it? o Common  vulnerability: attacker replaces legit file with symlink o Symlink could point to, say, /etc/gcc.stats, or /etc/passwd, or ... o Known as "time-­‐of-­‐check  to time-­‐of-­‐use"  bugs (TOCTTOU). Several possible ways of thinking of this problem: 1 1. Ambient authority: privileges that are automatically used by process are the problem here. No privileges should ever be used automatically. Name of an object should  be  also  the  privileges  for accessing  it. 2. Complex  permission checks: hard for privileged app to replicate. With simpler checks, privileged apps might be able to correctly check if another  user should have access to some object.
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
to replicate. With simpler checks, privileged apps might be able to correctly check if another  user should have access to some object. What are examples of ambient authority? • Unix UIDs, GIDs. • Firewalls  (IP  address  vs. privileges  for accessing it) • HTTP cookies (e.g. going to a URL like http://gmail.com) How  does naming an object through a capability help? • Pass file descriptor instead of passing a file name. • No way  to  pass  a valid  FD unless  caller  was  authorized  to  open that file. Could  we use file descriptors to solve our problem with a setuid gcc? • Sort-­‐of:  could make the compiler only accept files via FD passing. • Or,  could create a setuid helper that  opens the /etc/gcc.stats file, passes an  open file descriptor back to our compiler process. • Then, can continue using this open file much like any other file. • How to  ensure  only  gcc  can run this  helper? o Make gcc setgid to some special group. o Make the helper only executable to that  special  group. o Make sure that  group  has no other privileges given  to it. What problem are the Capsicum  authors trying to solve with capabilities? • Reducing privileges  of untrustworthy  code in various  applications. • Overall  plan: o Break up an application into smaller components. o Reduce privileges of components that are most vulnerable to attack. o Carefully  design interfaces so one component can't compromise another. • Why is this difficult? o Hard  to reduce privileges of code ("sandbox") in traditional Unix system. o Hard  to
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
difficult? o Hard  to reduce privileges of code ("sandbox") in traditional Unix system. o Hard  to give sandboxed code some limited access (to files, network, etc). What sorts of applications might use sandboxing? • OKWS. • Programs that deal with network input: o Put input handling  code into  sandbox. • Programs that manipulate data in complex ways: o (gzip,  Chromium,  media codecs, browser plugins, ...) o Put complex (& likely buggy) part into sandbox. • How  about arbitrary programs downloaded from the Internet? o Slightly different problem: need to isolate unmodified application code. 2 o One programmer insid option: § Works in some cases: Javascript, Java, Native Client,  ... § Need to standardize on an environment for sandboxed code. writes  their  application  to  run e sandbox. o Another option: impose new security policy on existing code. § Probably need to preserve all APIs that programmer was using. § Need to impose checks on existing APIs, in that case. § Unclear  what the  policy  should  be  for accessing files,  network,  etc. • Applications that want to avoid being tricked into misusing privileges? o Suppose two Unix users, Alice and Bob, are working on some project. o Both are in some group G, and project dir allows access by that group. o Let's say Alice emails someone a file from the project directory. o Risk: Bob could replace the file with a symlink to Alice's private file. o Alice's process will implicitly use Alice's ambient privileges to open. o Can think of this  as  sandboxing an individual file  operation. What sandboxing plans (mechanisms) are out there (advantages, limitations)? • OS typically provides some kind of security mechanism ("primitive"). o E.g., user/group  IDs in Unix, as we saw  in the previous lecture. o For today, we
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
E.g., user/group  IDs in Unix, as we saw  in the previous lecture. o For today, we  will look at OS-­‐level  security primitives/mechanisms. o Often a good match when you care about protecting resources the OS manages. o E.g., files,  processes,  coarse-­‐grained  memory, network interfaces, etc. • Many OS-­‐level  sandboxing mechanisms work at the level of processes. o Works well  for an entire process that  can  be isolated as a unit. o Can require  re-­‐architecting  application  to create processes for isolation. • Other techniques  can provide finer-­‐grained  isolation (e.g., threads  in proc). o Language-­‐level  isolation  (e.g.,  Javascript). o Binary instrumentation (e.g., Native Client). o Why would we need these other sandboxing  techniques? § Easier to control  access to non-­‐OS  / finer-­‐grained  objects. § Or perhaps can sandbox  in  an OS-­‐independent way. o OS-­‐level  isolation  often  used in  conjunction  with finer-­‐grained  isolation. § Finer-­‐grained  isolation is often hard  to get right  (Javascript,  NaCl). § E.g., Native  Client  uses both a fine-­‐grained  sandbox + OS-­‐level   sandbox. o Will look at these in more detail in later lectures. Plan 0: Virtualize everything  (e.g., VMs). • Run untrustworthy code inside of a virtualized environment. • Many examples: x86 qemu, FreeBSD jails, Linux LXC,
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
VMs). • Run untrustworthy code inside of a virtualized environment. • Many examples: x86 qemu, FreeBSD jails, Linux LXC,  .. • Almost a different category of mechanism: strict isolation. • Advantage: sandboxed code inside VM  has almost no interactions with outside. • Advantage: can sandbox unmodified code that's not expecting to be isolated. • Advantage: some VMs  can be started by arbitrary users (e.g., qemu). • Advantage: usually composable with other isolation techniques, extra layer. 3 • Disadvantage: hard to allow some sharing: no shared processes, pipes, files. • Disadvantage: virtualizing everything often makes VMs  relatively heavyweight. o Non-­‐trivial  CPU/memory  overheads for each sandbox. Plan 1: Discretionary  Access Control  (DAC). • Each object has a set of permissions (an access control list). o E.g., Unix files,  Windows objects. o "Discretionary" means applications set permissions on objects (e.g. chmod). • Each program runs with privileges of some principals. o E.g., Unix user/group  IDs,  Windows SIDs. , • When program accesses an object, check the program's privileges to decide. o "Ambient privilege": privileges used implicitly for each access. Name | V Process privileges | V Object -> Permissions -> Allow? How  would you sandbox a program on a DAC system (e.g., Unix)? • Must  allocate a new  principal  (user ID): o Otherwise,  existing principal's privileges will be used implicitly! • Prevent process from reading/writing other files: o Change  permissions on every file system-­‐wide? § Cumbersome,  impractical, requires root. o Even then, new program can create important world-­‐writable file. o Alternative: chroot (again, have to be root). • Allow process to read/write a certain file: o Set permissions on that file appropriately, if possible. o Link/move file into the
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
to be root). • Allow process to read/write a certain file: o Set permissions on that file appropriately, if possible. o Link/move file into the chroot directory for the sandbox? • Prevent process from accessing the network: o No real  answer for this in  Unix. o Maybe configure firewall?   But not  really process-­‐specific. • Allow process to access particular network connection: o See above, no great  plan for this in Unix. • Control what processes  a sandbox can kill / debug / etc: o Can run under the same UID, but that may be too many privileges. o That privileges might other have also UID Problem: only root can create new principals, on most DAC systems. • E.g., Unix, Windows. Problem: some objects might not have a clear configurable access control list. • Unix:  processes, network… Problem: permissions on files might not map to policy you want for sandbox. • Can sort-­‐of  work around  using chroot for files,  but awkward. ... 4 Related problem: performing some operations with a subset of privileges. • Recall example with Alice emailing a file out of shared group directory. "Confused  deputy problem": program is a "deputy" for multiple principals. • • One solution: check if group permissions allow access (manual, error-­‐prone). o Alternative solution: explicitly specify  privileges  for each operation. § Capabilities  can help: capability (e.g., fd) combines object + privileges. Unix § Some by name) features incompat. w/ pure capability design (symlink s . Plan 2: Mandatory  Access Control  (MAC). In DAC,  security policy is set by applications themselves (chmod, etc). • • MAC tries to help users / administrators specify policies for applications. o "Mandatory"  in the sense that applications can't change this policy. o Traditional MAC systems try to enforce military classified levels
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
applications. o "Mandatory"  in the sense that applications can't change this policy. o Traditional MAC systems try to enforce military classified levels. o E.g.,  ensure  top-­‐secret  programs can't reveal classified information. Name | V Operation + caller process | V Object --------> Allow? Policy ------------+ ^ | • Note: many systems have aspects of both DAC + MAC in them. o E.g., Unix user IDs are "DAC",  but one can argue firewalls are "MAC". o Doesn't really matter -­‐-­‐ good to know the extreme points in design space Windows Mandatory Integrity Control  (MIC)  / LOMAC in FreeBSD. • Keeps track  of an "integrity level"  for each process. • Files have a minimum integrity level associated with them. • Process cannot write  to  files  above  its  integrity  level. • • FreeBSD LOMAC also tracks data read by processes. IE in Windows Vista  runs as low integrity,  cannot overwrite  system files. o (Similar to many information-­‐flow-­‐based  systems.) o When  process reads low-­‐integrity  data, it becomes low integrity too. o Transitive, prevents adversary from indirectly tampering with files. • Not immediately useful for sandboxing: only a fixed number of levels. SElinux. Idea: system administrator specifies a system-­‐wide security policy. • • Policy  file  specifies whether  each operation  should  be  allowed  or denied. • To help  decide whether  to  allow/deny,  files labeled with "types". 5 o (Yet another  integer  value,  stored  in inode along
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
Yet another  integer  value,  stored  in inode along  w/  uid, gid ..) , Mac OS X sandbox ("Seatbelt") and Linux seccomp_filter. • Application specifies policy for whether to allow/deny each syscall. o (Written  in LISP for MacOSX's mechanism, or in BPF for Linux's.) • Can  be difficult to determine security impact of syscall based on args. o What does a pathname refer to? Symlinks, hard  links,  race conditions… (Although MacOSX's sandbox provides a bit more information.) • Advantage:  any  user  can  sandbox an  arbitrary  piece  of code, finally! • Limitation: programmer must separately write the policy + application code. • Limitation: some operations can only be filtered at coarse granularity. o E.g., POSIX shm in MacOSX's filter language, according to Capsicum paper. • Limitation: policy language might be awkware to use, stateless, etc. o E.g., what if app should have exactly one connection to some server? • Note: quite is seccomp_filter about talks Capsicum  paper different the from regular/old regular/old seccomp. seccomp, and the ] Is it a good idea to separate policy from application code? • Depends  on overall goal. • Potentially good if user/admin wants to look at or change policy. • Problematic if app developer needs to maintain both code and policy. • For app developers, might help clarify policy. • Less centralized  "MAC"  systems seccomp) (Seatbelt, provide a compromise - Plan 3: Capabilities (Capsicum). for Different • plan access  control:  capabilities. If process has a handle for some object ("capability"),  can access it. . Capability --> Object • No separate  question  of privileges,  access  control lists,
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
--> Object • No separate  question  of privileges,  access  control lists,  policies,  etc. • E.g.: file  descriptors on Unix are  a capability for a file. o Program can't make up a file descriptor it didn't legitimately get. (Why not?) o Once file is open, can access it; checks happened at open time. o Can pass  open files  to  other  processes. o FDs also help solve "time-­‐of-­‐check to  time-­‐of-­‐use"  (TOCTTOU)  bugs. • Capabilities  are usually ephemeral: not part of on-­‐disk inode. o Whatever starts  the program needs to re-­‐create  capabilities each time. Global namespaces. • Why are these guys so fascinated with eliminating global namespaces? • Global namespaces require some access control story (e.g., ambient privs). 6 sandbox's  access to objects in global namespaces • Hard  to  control Kernel  changes. • Just to  double-­‐check:  why  do we  need kernel changes? . o Can  we implement everything in a library (and LD_PRELOAD it)? • Represent more things as file descriptors: processes (pdfork). o Good idea in general. • Capability  mode: once process enters cap mode, cannot leave (+all children). In capability mode, can only use file descriptors -­‐-­‐ no global namespaces. • o Cannot  open files by full path name: no need for chroot as in OKWS. o Can  still open files by relative path name,  given fd for dir (openat). • Cannot  use ".." in path names or in symlinks: why not? o In principle, ".." might be fine
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
at). • Cannot  use ".." in path names or in symlinks: why not? o In principle, ".." might be fine, as long as ".." doesn't go too far. o Hard  to  enforce  correctly. o Hypothetical design: § Prohibit looking  up ".." at the  root capability. § No more ".." than non-­‐".." components in path name, ignoring ".". • Assume a process has capability C1  for /foo. • Race condition, in a single process  with 2 threads: T1: mkdir(C1, "a/b/c") T1: C2 = openat(C1, "a") T1: C3 = openat(C2, "b/c/../..") for /foo/a Let openat() run until it's about to look up the first ".." T2: renameat(C1, "a/b/c", C1, "d") T1: Look up the first "..", which goes to "/foo" Look up the second "..", which goes to "/" ## should return a cap • Do Unix permissions still apply? can't o Yes o But intent is that sandbox shouldn't rely on Unix permissions. because  you files  in have acce just cap dir all a s for dir. • For file  descriptors, add  a wrapper  object that stores  allowed  operations. • Where does the kernel  check  capabilities? -- s o One  function in kernel looks up fd numbers -­‐-­‐ modified it to check caps. o Also modified namei function, which looks up path names. o Good practice: look for narrow interfaces, otherwise easy to miss checks. libcapsicum. • Why do application  developers need this library? • Biggest  functionality: starting  a new  process in  a sandbox. fd lists. • Mostly a convenient  way to pass lots of file descriptors to child process. • Name file descriptors by string instead of hard-­‐coding
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
• Mostly a convenient  way to pass lots of file descriptors to child process. • Name file descriptors by string instead of hard-­‐coding  an fd number. cap_enter()  vs lch_start(). • What  are the advantages of sandboxing  using  exec  instead of cap_enter? • Leftover data in memory: e.g., private keys in OpenSSL/OpenSSH. 7 • Leftover  file  descriptors  that application forgot to  close. • Figure 7 in paper: tcpdump had privileges on stdin, stdout, stderr. • Figure  10 in paper:  dhclient had  a raw socket, syslogd  pipe, lease  file. (Even a sandbox can  create  a sandbox.) Advantages: any process can create a new sandbox. • Advantages: fine-­‐grained control of access to resources (if they map to FDs). • Files, network  sockets,  processes. Disadvantage:  weak story  for keeping track of access  to  persistent files. Disadvantage: prohibits global namespaces, requires writing code differently. Alternative capability designs: pure capability-­‐based OS (KeyKOS,  etc). • Kernel  only  provides a message-­‐passing  service. • Message-­‐passing  channels (very much like file descriptors) are capabilities. • Every  application has to be written  in a capability style. • Capsicum  claims to be more pragmatic: some applications need not be changed. Linux  capabilities: solving a different problem. • Trying to  partition  root's  privileges  into  finer-­‐grained  privileges
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
root's  privileges  into  finer-­‐grained  privileges. • Represented by various capabilities: CAP_KILL,  CAP_SETUID, CAP_SYS_CHROOT… • Process can run with  a specific capability  instead  of all of root's  privs. • Ref: capabilities(7), http://linux.die.net/man/7/capabilities Using Capsicum  in applications. • Plan: ensure sandboxed process doesn't use path names or other global NSes. o For every directory it might need access to, open FD ahead of time. o To open files, use openat() starting from one of these directory FDs. o .. programs that open lots of files all over the place may be cumbersome. • tcpdump. o 2-­‐line version: just  cap_enter() after opening  all FDs. o Used procstat to  look at resulting  capabilities. o 8-­‐line version: also restrict  stdin/stdout/stderr. o Why?   E.g., avoid reading  stderr log,  changing terminal settings… • dhclient. o Already privilege-­‐separated, using Capsicum  to reinforce sandbox (2 lines). • gzip. o Fork/exec  sandboxed  child  process, feed it data using RPC  over pipes. o Non-­‐trivial  changes, mostly to marshal/unmarshal data for RPC:  409 LoC. o Interesting bug: forgot to propagate compression level at first. • Chromium. o Already privilege-­‐separated  on other platforms (but not on FreeBSD). o ~100 LoC to wrap  file descriptors for sandboxed processes. • OKWS. 8 o What are the various answers to the homework question? Does Capsicum  achieve its goals? • How hard
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
8 o What are the various answers to the homework question? Does Capsicum  achieve its goals? • How hard/easy  is it to  use? o Using Capsicum  in an application almost always requires app changes. (Many applications tend to open files by pathname, etc.) § § One exception: Unix  pipeline apps (filters) that  just  operate on   FDs. o Easier for streaming applications that process data via FDs. o Other sandboxing  requires  similar changes (e.g., dhclient, Chromium). o For existing applications, lazy initialization seems to be a problem. § No general-­‐purpose  solution  -­‐-­‐ either  change  code or initialize   early. o Suggested plan: sandbox and see what breaks. § Might  be subtle: gzip  compression level bug. • What  are the security guarantees it  provides? o Guarantees  provided to  app  developers:  sandbox can  operate  only  on open FDs. Implications depend on how app developer partitions application, FDs. o o User/admin doesn't get any direct guarantees from Capsicum. o Guarantees assume no bugs in FreeBSD kernel (lots of code), and that the Capsicum  developers caught all ways to access a resource not via FDs. • What are the performance overheads? (CPU,  memory) o Minor overheads for accessing  a file descriptor. o Setting up a sandbox using fork/exec takes O(1msec), non-­‐trivial. o Privilege separation can require RPC / message-­‐passing,  perhaps noticeable. • Adoption? o o A handful of applications have  been modified to use Capsicum:  dhclient, In FreeBSD's kernel
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
o o A handful of applications have  been modified to use Capsicum:  dhclient, In FreeBSD's kernel  now, enabled by default  (as of FreeBSD 10). tcpdump, and a few more since the paper was written (Ref: http://www.cl.cam.ac.uk/research/security/capsicum/freebsd.html) o Casper  daemon to help applications perform non-­‐capability  operations. E.g., DNS lookups, look up entries in /etc/passwd, etc. http://people.freebsd.org/~pjd/pubs/Capsicum_and_Casper.pdf   § § o There's a port of Capsicum  to Linux (but not in upstream kernel repo). What applications wouldn't be a good fit for Capsicum?   • Apps that need to control access to non-­‐kernel-­‐managed  objects. o E.g.: X server state,  DBus,  HTTP  origins in a web browser,  etc. o E.g.: a database server that needs to ensure DB file is in correct format. o Capsicum  treats pipe to a user-­‐level  server (e.g.,  X server) as one cap. • Apps that need to connect to specific TCP/UDP  addresses/ports from sandbox. o Capsicum  works by only allowing operations on existing open FDs. o Need some other mechanism to control what FDs can be opened. 9 o Possible solution: helper program can run outside of capability mode, open TCP/UDP  sockets for sandboxed programs based on policy. References: • http://reverse.put.as/wp-­‐content/uploads/2011/09/Apple-­‐Sandbox-­‐Guide-­‐ v1.0.pdf • http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-­‐ 2.6.git;a=blob;f=Documentation/prctl/seccomp_filter.txt;hb=HEAD • http://en.wikipedia.org/wiki/Mandatory_Integrity_Control
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
;a=blob;f=Documentation/prctl/seccomp_filter.txt;hb=HEAD • http://en.wikipedia.org/wiki/Mandatory_Integrity_Control 10 MIT OpenCourseWare http://ocw.mit.edu 6.858 Computer Systems Security Fall 2014 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/0f397e7b504aa9b146763705619d49ba_MIT6_858F14_lec6.pdf
15.083J/6.859J Integer Optimization Lecture 9: Duality II 1 Outline • Solution of Lagrangean dual • Geometry and strength of the Lagrangean dual 2 The TSP � xe = 2, i ∈ V, e∈δ({i}) � xe ≤ |S| − 1, e∈E(S) S ⊂ V, S =(cid:5) ∅, V, min s.t. xe ∈ {0, 1}. � cexe e∈E � xe = 2, i ∈ V \ {1}, e∈δ({i}) � xe = 2, e∈δ({1}) � xe ≤ |S| − 1, S ⊂ V \ {1}, S =(cid:5) ∅, V \ {1}, e∈E(S) � xe = |V | − 2, e∈E(V \{1}) xe ∈ {0, 1}. � e∈δ({i}) xe = 2, Dualize What is the relation of ZD and ZLP? i ∈ V \ {1}. 3 Solution � � • Z(λ) = mink∈K c (cid:3) x k+λ(cid:3)(b−Axk) , x k, k ∈ K are extreme points of conv(X). • f k = b − Axk and hk = c (cid:3) x k . • Z(λ) = mink∈K hk + f (cid:3) • Recall λt+1 = λt + θt∇Z(λt) kλ , piecewise linear and concave. � � Slide 1 Slide 2 Slide 3 3.1 Subgradients • Prop: f : (cid:8)n (cid:9) → (cid:8) is concave if and only if for any x ∗ ∈ (cid:
https://ocw.mit.edu/courses/15-083j-integer-programming-and-combinatorial-optimization-fall-2009/0f3bef63990e2ad5c559713b2dc7fa6e_MIT15_083JF09_lec09.pdf
8)n (cid:9) → (cid:8) is concave if and only if for any x ∗ ∈ (cid:8)n s ∈ (cid:8)n such that f (x) ≤ f (x ∗ ) + s (cid:3) (x − x ∗ ). 1 , there exists a vector Slide 4 • Def: f concave. A vector s such that for all x ∈ (cid:8)n: f (x) ≤ f (x ∗ ) + s (cid:3) (x − x ∗ ), ∗ is called a subgradient of f at x . The set of all subgradients of f at x ∗ denoted by ∂f (x ) and is called the subdifferential of f at x . ∗ maximizes f over (cid:8)n → (cid:8) be concave. A vector x if and only if is ∗ ∗ • Prop: f : (cid:8)n (cid:9) 0 ∈ ∂f (x ). ∗ � � (cid:3) kλ , Z(λ) = min hk + f k∈K � � E(λ) = k ∈ K | Z(λ) = hk + f (cid:3) λ . k Then, for every λ ∗ ≥ 0 the following relations hold: • For every k ∈ E(λ ∗ ), f k is a subgradient of the function Z(·) at λ ∗ . • ∂Z(λ ∗ ) = conv {f k | k ∈ E(λ ∗ )} , i.e., a vector s is a subgradient of the function Z(·) at λ ∗ if and only if Z(λ ∗ ) is a convex combination of the vectors f k , k
https://ocw.mit.edu/courses/15-083j-integer-programming-and-combinatorial-optimization-fall-2009/0f3bef63990e2ad5c559713b2dc7fa6e_MIT15_083JF09_lec09.pdf
� if and only if Z(λ ∗ ) is a convex combination of the vectors f k , k ∈ E(λ ∗ ). � � 3.2 The subgradient algorithm Input: A nondifferentiable concave function Z(λ). Output: A maximizer of Z(λ) subject to λ ≥ 0. Algorithm: 1. Choose a starting point λ1 ≥ 0; let t = 1. 2. Given λt, check whether 0 ∈ ∂Z(λt). If so, then λt is optimal and the algorithm terminates. Else, choose a subgradient s t of the function Z(λt). t + θtsj t , 0 , where θt is a positive stepsize parameter. Incre­ � t+1 = max λj ment t and go to Step 2. 3. Let λj � 3.2.1 Step length and �∞ • t=1 θt = ∞, • Example: θt = 1/t. • Example: θt = θ0αt , Zˆ • θt = f optimal value ZD. limt→∞ θt = 0. t = 1, 2, . . . , 0 < α < 1. D−Z(λt ) , where f satisfies 0 < f < 2, and ZˆD is an estimate of the ||st ||2 Slide 5 Slide 6 Slide 7 • The stopping criterion 0 ∈ ∂Z(λt) is rarely met. Typically, the algorithm is stopped after a fixed number of iterations. 3.3 Example � � • Z(λ) = min 3 − 2λ, 6 − 3λ,
https://ocw.mit.edu/courses/15-083j-integer-programming-and-combinatorial-optimization-fall-2009/0f3bef63990e2ad5c559713b2dc7fa6e_MIT15_083JF09_lec09.pdf
Example � � • Z(λ) = min 3 − 2λ, 6 − 3λ, 2 − λ, 5 − 2λ, − 2 + λ, 1, 4 − λ, λ, 3 , • θt = 0.8t . Slide 8 2 • λt s t Z(λt) 1.5.00 −3 −9.00 2.2.60 −2 −2.20 3.1.32 −1 −0.68 2 −0.66 4.1.83 1 −0.99 5.1.01 1 −0.66 6.1.34 1 −0.40 7.1.60 8.1.81 −2 −0.62 1 −0.52 9.1.48 1 −0.39 10.1.61 4 Nonlinear problems • ZP = min f (x) s.t. g(x) ≤ 0, � � • Z(λ) = minx∈X f (x) + λ(cid:3) g(x) . • ZD = maxλ≥0 Z(λ). • Y = {(y, z) | y ≥ f (x), z ≥ g(x), for all x ∈ X}. x ∈ X. • ZP = min y s.t. (y, 0) ∈ Y. • Z(λ) ≤ f (x) + λ(cid:3) g(x) ≤ y + λ(cid:3) z, • Geometrically, the hyperplane Z(λ) = y + λ(cid:3) z lies below the set Y . • Theorem: ∀(y, z) ∈ Y. ZD = min y s.t. (y, 0) ∈ conv(Y ). 4.1 Figure 4.2 Example again X = {(1, 0)(cid:3) , (2
https://ocw.mit.edu/courses/15-083j-integer-programming-and-combinatorial-optimization-fall-2009/0f3bef63990e2ad5c559713b2dc7fa6e_MIT15_083JF09_lec09.pdf
). 4.1 Figure 4.2 Example again X = {(1, 0)(cid:3) , (2, 0)(cid:3) , (1, 1)(cid:3) , (2, 1)(cid:3) , (0, 2)(cid:3) , (1, 2)(cid:3) , (2, 2)(cid:3) , (1, 3)(cid:3) , (2, 3)(cid:3)}. 4.3 Subgradient algorithm Input: Convex functions f (x), g1(x), . . . , gm(x) and a convex set X. Slide 9 Slide 10 Slide 11 Slide 12 Output: An approximate minimizer. Algorithm: 1. (Initialization) Select a vector λ and solve minx∈X f (x) + λ(cid:3) g(x) to obtain the optimal value Z and an optimal solution x. Set x 0 = x; Z0 = Z; t = 1. 2. (Stopping criterion) If (|f (x) − Z|/Z) < (cid:6)1 and ( |λi|/m) < (cid:6)2 stop; � m i=1 � � Output x and Z as the solution to the Lagrangean dual problem. 3 f conv(Y ) z(λ) = f + λg ZP ZD g 3. (Subgradient computation) Compute a subgradient s t; λt = max{λj + j θtsj t , 0}, where θt = g Zˆ − ZLP(λ) ||st||2 with Zˆ an upper bound on ZD, and 0 < g < 2. With λ = λt solve minx∈X f (x)+ λ(cid:3) g(x) to obtain the optimal value Zt and an optimal solution x t . � � 4. (Solution update) Update x
https://ocw.mit.edu/courses/15-083j-integer-programming-and-combinatorial-optimization-fall-2009/0f3bef63990e2ad5c559713b2dc7fa6e_MIT15_083JF09_lec09.pdf
optimal value Zt and an optimal solution x t . � � 4. (Solution update) Update x ← αx t + (1 − α)x where 0 < α <1. 5. (Improving step) If Zt > Z, then λ ← λ t , Z ← Z t ; Let t ← t + 1 and go to Step 2. 4 f conv(Y ) ZP = 1 1 ZD = − 3 duality gap g 5 MIT OpenCourseWare http://ocw.mit.edu 15.083J / 6.859J Integer Programming and Combinatorial Optimization Fall 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
https://ocw.mit.edu/courses/15-083j-integer-programming-and-combinatorial-optimization-fall-2009/0f3bef63990e2ad5c559713b2dc7fa6e_MIT15_083JF09_lec09.pdf
Lecture Notes for LG’s Diff. Analysis trans. Paul Gallagher Feb. 23, 2015 1 The Sobolev Inequality Suppose that u 2 C 1 ∇u is \small", does this imply that u is small? c (Rn). Clearly, if ∇u = 0, then u = 0. So, we can ask if Question 1. If u 2 C 1 c (Rn) and ∫ j∇uj = 1, is there a bound for sup juj? Answer 1. If n = 1, then this is true by the Fundamental theorem of calculus. If n > 1, then we have the following scaling example: Let (cid:17) 2 C 1 c be a (cid:12)xed smooth bump function. De(cid:12)ne (cid:17)(cid:21)(x) = (cid:17)(x=(cid:21)). Then sup((cid:17)(cid:21)) = sup((cid:17)), and ∫ ∫ ∫ j∇(cid:17)(cid:21)jdx = (cid:21)(cid:0)1 j(∇(cid:17))(x=(cid:21))jdx = (cid:21)n(cid:0)1 j∇(cid:17)j = (cid:21)n(cid:0)1 Therefore, we can make the L1 norm of the derivative as small as we like, while keeping the L1 norm of the function large. Theorem 1.1 (Sobolev Inequality). If u 2 C 1(Rn c ) then ∥u∥ n L n(cid:0)1 (cid:20) ∥∇u∥L1. Remark 1.1. Note that this will not hold true for p = n . To see this, suppose that we have ∥u∥Lp (cid:20) ∥∇u∥L1. As in the scaling example, pick (cid:17) a smooth bump function, and de(cid:12)ne (cid:17)(cid:21) as before. Then n(cid:0)1 1 ̸
https://ocw.mit.edu/courses/18-156-differential-analysis-ii-partial-differential-equations-and-fourier-analysis-spring-2016/0f7233291fe1c944d7170aeb6f822e42_MIT18_156S16_lec8.pdf
(cid:12)ne (cid:17)(cid:21) as before. Then n(cid:0)1 1 ̸ ∫ j(cid:17)(cid:21)jp = (cid:21)n ∫ ( (cid:17)pdx (cid:20) (cid:21)n ∫ (∫ ) p j∇(cid:17)jdx ) p = (cid:21)n (cid:21)(cid:0)n ( = (cid:21)n (cid:21)(cid:0)n+1 j(∇(cid:17))(x=(cid:21))jdx ∫ ) p j∇(cid:17)(cid:21)jdx (∫ = (cid:21)n+(1(cid:0)n)p j∇(cid:17)(cid:21)jdx ) p Thus, if p = n=(n (cid:0) 1), we can make the right hand side very small simply by making (cid:21) either large or small. Before we prove the Sobolev Inequality, we’ll prove a slightly easier prob- lem: Lemma 1.1. Let u 2 C 1 V oln ((cid:25) (U )) j∇ j u . (cid:20) (cid:0)1 ∫ j c (Rn), U = fjuj > 1g and (cid:25) j : R ! x? n j . Then Proof. WLOG, assume j = n. Then ∫ V ol((cid:25)j(U )) (cid:20) max ∫ Rn(cid:0)1 xn ∫ ju(x1; (cid:1) (cid:1) (cid:1) ; xn)jdx1 (cid:1) (cid:1) (cid:1) dxn(cid:0)1 j @nu(x1; (cid:1) (cid:1) (cid:1) ; xn) jdxndx1 (cid:1) (cid:1) (cid:1) dxn(cid:0)1 (cid:20) (cid:20) Rn(cid:0)1 ∫ R
https://ocw.mit.edu/courses/18-156-differential-analysis-ii-partial-differential-equations-and-fourier-analysis-spring-2016/0f7233291fe1c944d7170aeb6f822e42_MIT18_156S16_lec8.pdf
:1) dxn(cid:0)1 (cid:20) (cid:20) Rn(cid:0)1 ∫ R j∇uj Rn Then we can use the Loomis-Whitney theorem which we proved in the homework: Theorem 1.2 (Loomis-Whitney). If U (cid:26) Rn is open, and j(cid:25)j(U ) all j, then jU j (cid:20) A (cid:0) . n=(n 1) j (cid:20) A for 2 ̸ Proof of Sobolev dimension 2. De(cid:12)ne ∫ u1(x2) = ∫ j@1u(x1; x2)jdx1 u2(x1) = j@2u(x1; x2)jdx2 Then ju(x1; x2)j (cid:20) ui(xj). Therefore, ∫ ∫ u2 (cid:20) u1(x2)u2(x1)dx1dx2 = u1dx2 u2dx1 (cid:20) j∇uj (∫ ) (∫ ) (∫ ) 2 With this in hand, we can move on to the proof of the Sobolev by induc- tion. Proof of General Sobolev. De(cid:12)ne ∫ un(x1; (cid:1) (cid:1) (cid:1) ; xn 1) = (cid:0) j@nu(x1; (cid:1) (cid:1) (cid:1) ; x n)jdxn Then juj (cid:20) un. and ∫ Rn u(cid:0)1 n (cid:20) ∫ Rn j∇uj. We will proceed by induction. ∫ Rn jujn=(n(cid:0)1) (cid:20) (cid:20) (cid:20) (cid:20) ∫ (∫ R ∫ [∫ Rn(cid:0) 1 R ∫ ∫ Rn(cid:0)1 ) dxn 1=(n 1) (cid:0)
https://ocw.mit.edu/courses/18-156-differential-analysis-ii-partial-differential-equations-and-fourier-analysis-spring-2016/0f7233291fe1c944d7170aeb6f822e42_MIT18_156S16_lec8.pdf
1 R ∫ ∫ Rn(cid:0)1 ) dxn 1=(n 1) (cid:0) juju1=(n(cid:0)1) n ] dx1 [∫ n n (cid:0)2 (cid:0)1 (cid:0) n 1 j j u n(cid:0)2 (cid:1) (cid:1) (cid:1) dx n (cid:0)1 ] j (∫ j un Rn(cid:0)1 dxn ) 1=(n(cid:0)1) R Rn(cid:0)1 (∫ j∇ujdx1 (cid:1) (cid:1) (cid:1) dxn(cid:0)1dxn ) n=(n(cid:0)1) un Rn(cid:0)1 j∇uj 3 MIT OpenCourseWare http://ocw.mit.edu 18.156 Differential Analysis II: Partial Differential Equations and Fourier Analysis Spring(cid:3) 2016 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
https://ocw.mit.edu/courses/18-156-differential-analysis-ii-partial-differential-equations-and-fourier-analysis-spring-2016/0f7233291fe1c944d7170aeb6f822e42_MIT18_156S16_lec8.pdf
Chapter 9 Notes, Part 1 - Inference for Proportion and Count Data We want to estimate the proportion p of a population that have a specific attribute, like “what percent of houses in Cambridge have a mouse in the house?” We are given X1, . . . , Xp where Xi’s are Bernoulli, and P (Xi = 1) = p. Xi is 1 if house i has a mouse. Let Y = i Xi so Y ∼ Bin(n, p). An estimator for p is: Y 1 pˆ = = n n i Xi. pˆ is a random variable. For large n (rule of thumb, npˆ ≥ 10, n(1 − pˆ) ≥ 10) the CLT says that approximately: pˆ ∼ N p, pq n where q = 1 − p. Questions: What’s up with that rule of thumb? Where did the pq/n come from? Confidence Intervals The CI can be computed in 2 ways (here for 2-sided case): • CI first try: P −zα/2 ≤ p pˆ − p pq/n ≤ zα/2 = 1 − α. We could solve it for p but the expression is quite large... • CI second try: which yields P −zα/2 ≤ p pˆ − p pˆˆq/n ≤ zα/2 ≈ 1 − α pˆ − zα/2 pˆqˆ n ≤ p ≤ pˆ + zα/2 pˆqˆ n . So that’s the approximate CI for p. Sample size calculation for CI 1 Want a CI of width 2E: pˆ − E ≤ p ≤ pˆ + E so (cid:114) E = zα/2 pˆ
https://ocw.mit.edu/courses/15-075j-statistical-thinking-and-data-analysis-fall-2011/0fa15fa0462a921af5d493f45a3f0809_MIT15_075JF11_chpt09a.pdf
: pˆ − E ≤ p ≤ pˆ + E so (cid:114) E = zα/2 pˆqˆ n which means n = zα/2 (cid:16) E 2 (cid:17) pˆq. ˆ Question: We’ll take ˆpqˆ to be its largest possible value, (1/2) × (1/2). Why do we do this? Why don’t we just use the ˆp and ˆq that we measure from the data? So, we need: n = (cid:16) zα/2 E (cid:17) 2 1 4 observations. Hypothesis testing on proportion for large n H0 H1 : p = p0 p0. : p = q0 Large n and H0 imply ˆp ≈ N p0, p0 n (where q0 = 1 − p0) so we use z-test with test statistic: pˆ − p0 z = pp0q0/n Example For small n one can use the binomial distribution to compute probabilities directly (rather than approximating by normal). (Not covered here.) Chapter 9.2 Comparing 2 proportions Example: The Salk polio vaccine trial: compare rate of polio in control and treatment (vac­ cinated) group. Is this independent samples design or matched pairs? Sample 1: number of successes X ∼ Bin(n1, p1), observe X = x. Sample 2: number of successes Y ∼ Bin(n2, p2), observe Y = y. We could compare rates in several ways: p1 − p2 p1/p2 (cid:17) (cid:16) / (cid:17) p2 1−p2 (cid:16) p1 1−p1 → we’ll use this one “relative risk” “odds ratio” 2 For large samples,
https://ocw.mit.edu/courses/15-075j-statistical-thinking-and-data-analysis-fall-2011/0fa15fa0462a921af5d493f45a3f0809_MIT15_075JF11_chpt09a.pdf
p1 → we’ll use this one “relative risk” “odds ratio” 2 For large samples, we’ll use the CLT: pˆ1 − pˆ2 − (p1 − p2) Z = - pˆ1qˆ1 n1 pˆ2qˆ2+ n2 ≈ N (0, 1) where ˆp1 = X/n1 and ˆp2 = Y /n2. To test H0 : p1 − p2 = δ0, H1 : p1 − p2 = δ0, we can just compute zscores, pvalues, and CI. The test statistic is: z = - pˆ1 − pˆ2 − δ0 pˆ2qˆ2+ n2 pˆ1qˆ1 n1 . This is a little weird because it really should have terms like “p1,0q1,0/n1” in the denomi­ nator, but we don’t have those values under the null hypothesis. So we get an approximation by using ˆp1 and ˆq1 in the denominator. Example For an independent samples design with small samples, use Fisher’s Exact Test which uses the Hypergeometric distribution. For a matched pairs design, use McNemar’s Test which uses the binomial distribution (Both beyond the scope.) Two Challenges 3 MIT OpenCourseWare http://ocw.mit.edu 15.075J / ESD.07J Statistical Thinking and Data Analysis Fall 2011 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
https://ocw.mit.edu/courses/15-075j-statistical-thinking-and-data-analysis-fall-2011/0fa15fa0462a921af5d493f45a3f0809_MIT15_075JF11_chpt09a.pdf
Data Networks Lecture 1 Introduction Eytan Modiano Eytan Modiano Slide 1 6.263: Data Networks • Fundamental aspects of network Design and Analysis: – Architecture Layering Topology design – Protocols Pt.-to-Pt. Multiple access End-to-end – Algorithms Error recovery Routing Flow Control – Analysis tools Probabilistic modeling Queueing Theory Eytan Modiano Slide 2 Course Information • Lecturer: Professor Eytan Modiano • Requirements & Grading – About one problem set per week (10% of grade) – Project (5% of grade) – Midterm exam (35 %) – Final Exam during finals week (50%) • Prerequisite Policy: 6.041, or an equivalent class in probability • Textbook: Bertsekas & Gallager, Data Networks (2nd Edition) Eytan Modiano Slide 3 LEC # TOPICS Tentative syllabus 1 2 3 4 5 6 7 8 9 10 11 12 Introduction, OSI 7-layer architecture Data Link Layers, Framing, error detection Retransmission Algorithms Retransmission Algorithms Queueing Models - Introduction & Little's theorem M/M/1, M/M/m, queues etc. Networks of queues M/G/1 queues, M/G/1 w/ vacations M/G/1 queues and reservations, priority queues Stability of queueing systems M/G/1 queue occupancy distribution Quiz Eytan Modiano Slide 4 LEC # TOPICS Tentative syllabus, continued Multiple access & Aloha Stabilized Aloha, Tree Algorithms CSMA, CSMA/CD and Ethernet High-speed LANs, Token rings, Satellite reservations Introduction to switch architecture High Speed Switch Scheduling Broadcast routing & Spanning trees Shortest path routing Distributed routing algorithms, optimal routing Flow Control - Window/Credit Schemes Flow Control - Rate Based Schemes Transport layer and TCP/IP ATM Networks Special topic: Optical Networks, Wireless networks Final Exam during final exam week. Date and time to be announced. 13 14 15
https://ocw.mit.edu/courses/6-263j-data-communication-networks-fall-2002/0feb60d4d98f77a9c08991b4960139f3_Lecture1.pdf