Unit 3 MCAP MCQ - MCQ type material PDF

Title Unit 3 MCAP MCQ - MCQ type material
Author Arjun Rajendran
Course Multi core architectures and programming (Mcap)
Institution Anna University
Pages 17
File Size 179.3 KB
File Type PDF
Total Downloads 41
Total Views 210

Summary

MCQ type material...


Description

UNIT 3 SHARED MEMEORY PROGRAMMING WITH OPENMP 1. OpenMP program is an API for __________________. a) shared memory parallel programming b) distributed memory parallel programming c) Both of above d) None of above Answer: a) shared memory parallel programming 2. The format of directive in openMP a) !pragma omp b) $pragma omp c) #pragma omp d) ~pragma omp Answer: c) #pragma omp 3. #pragma omp parallel private(i) for (int i = 0; i < 100; i++) { a[i] = i; } How many iterations are executed if four threads execute the above program? a) 20 b) 40 c) 25 d) 35 Answer: c) 25 Explanation: Loop is splitted among four threads (100/4= 25) 4. Code in an OpenMP program that is not covered by a pragma is executed by all threads. a) TRUE b) FALSE Answer: b) FALSE Explanation: It is executed by single thread 5. OpenMP program need less memory a) TRUE b) FALSE Answer: a) TRUE 6. The following code force threads to wait till all are done a) #pragma omp parallel b) #pragma omp barrier c) #pragma omp critical d) #pragma omp sections Answer: b) #pragma omp barrier 7. Directives appear just before a block of code, which is delimited by

a) ( … ) b) [ … ] c) { … } d) < … > Answer: c) { … } 8. The purpose of “#pragma omp for nowait” is a) Loop work is to be divided b) Work to be done in a loop when done, don’t wait c) Work to be done using implicit loop d) Work to be done in a loop Answer: b) Work to be done in a loop when done, don’t wait 9. The purpose of “#pragma omp for” is a) Loop work is to be divided b) Work to be done in a loop when done, don’t wait c) Work to be done using implicit loop d) Work to be done in a loop Answer: d) Work to be done in a loop 10. The purpose of “#pragma omp sections” is a) Loop work is to be divided into user defined sections b) Work to be done in a loop when done, don’t wait c) Work to be done using implicit loop d) Work to be done in a loop Answer: a) Loop work is to be divided into user defined sections 11. Which of the following code indicate parallel section of code? a) #pragma omp sections b) #pragma omp parallel c) #pragma omp critical d) None of the above Answer: b) #pragma omp parallel 12. Which of the following code indicate that only one thread can do at a time? a) #pragma omp parallel b) #pragma omp barrier c) #pragma omp sections d) #pragma omp critical Answer: d) #pragma omp critical 13. Which of the following code indicate that variable must be kept private? a) #pragma omp parallel private b) #pragma omp parallel reduction c) #pragma omp parallel shared d) None of the above Answer: a) #pragma omp parallel private 14. Which of the following code indicate that variable must be shared? a) #pragma omp parallel private b) #pragma omp parallel reduction c) #pragma omp parallel shared d) None of the above

Answer: c) #pragma omp parallel shared 15. OpenMP assigns piece of computations to_________ a) Process b) Thread c) Program d) All the above Answer: b) Thread 16. OpenMP program begins with a) One master thread executing b) Two master thread executing c) Three master thread executing d) Many master thread executing Answer: a) One master thread executing 17. “MP”in OpenMP stands for a) Multiprogramming b) Multithreadimg c) Multiprocessing d) None of the above Answer: c) Multiprocessing 18. The following command is used to execute OpenMP program say program name hello.c with 4 threads a) $./omp 4 hello b) $./omp hello -4 c) $./omp -4 hello d) $./omp hello 4 Answer: d) $./omp hello 4 19. Consider the following statements (i) Pthreads require that programmer explicitly specify the behavior of each thread (ii) Pthreads does not allow programmer to explicitly specify the behavior of each thread (iii) OpenMP allows programmer to simply state that a block of code should be executed in parallel (iv) Pthreads program can be run with C Compiler Which of the above statement is/are true? a) (i) and (ii) b) (i),(iii) and (iv) c) (i),(ii) and (iii) d) (i),(ii), (iii) and (iv) Answer: b) (i),(iii) and (iv) 20. Each thread also has access to another type of memory that must not be accessed by other threads is called a) threadprivate memory b) threadshared memory c) threadparallel memory d) None of the above

Ans: a) threadprivate 21. OpenMP API defines which of the following Worksharing constructs a) Loop constructs b) Section constructs c) Single constructs d) All the above Answer: d) All the above 22. Which of the following statement is/are t rue ṭ about loop constructs? a) Only one schedule clause can appear on a loop directive. b) Only one collapse clause canSappear on a loop directive. c) All loops associated with the loop construct must be perfectly nested d) All the above Answer: d)All the above 23. Which clause is used to specify how many loops are associated with loop constructs? a) Collapse clause b) Schedule clause c) Ordered clause d) Shared clause Answer: a)Collapse clause 24. Standalone directives ______________ a) Can have an associated executable code b) There is no restrictions on placement of standalone directive within the program c) Do not have any associated executable user code d) None of the above Answer: c) Do not have any associated executable user code 25. The sections construct is a non-iterative work sharing construct thatcontains a set of structured blocks that are to be distributed among andexecuted by the threads in a team a) True b) False Answer: True 26. Which of the following statement is/are true about section construct? a) The section directives must be encountered elsewhere in the sections region. b) The code enclosed in a sections construct must be a structured block. c) Only any number of nowait clause can appear on a sections directive. d) All the above Answer: b) The code enclosed in a sections construct must be a structured block. 27. The associated structured block is executed by only one of the threads in the team (not necessarily the master thread) a) Single construct clause b) Section construct clause c) Loop construct d) None of the above Answer: a)Single construct clause 28. Master thread has thread number a) Any number

b) 0 c) 1 d) 2 Answer: b) 0 29. The method used to enable nested parallel region is a) omp_nested() b) omp_get_nested() c) omp_set_nested d) None of the above Answer: c)omp_set_nested() 30. The method used to determine if nested parallel region is enabled or not. a) omp_nested() b) omp_get_nested() c) omp_set_nested d) None of the above Answer: a)omp_get_nested() 31. Which of the following clause is used to indicate number of threads a) NUM_THREADS b) NUM_OF_THREADS c) THREAD_NUM d) NUMBER_OF_THREAD Answer: a) NUM_THREADS 32. Variables defined in the shared clause are shared among all threads a) True b) False Answer:a)True 33. Which of the following about OpenMP is incorrect: a) OpenMP is an API that enables explicit multi-threaded parallelism. b) The primary components of OpenMP are compiler directives, runtime library, and environment variables. c) OpenMP is designed for distributed memory parallel systems and guarantees efficient use of memory. d) OpenMP supports UMA and NUMA architectures. Answer: c) OpenMP is designed for distributed memory parallel systems and guarantees efficient use of memory. 34. #pragma omp master a) Specifies that only the master thread should execute a section of the program. b) Specify that master thread has been created c) Both a) and b) d) None of the above Answer: a) Specifies that only the master thread should execute a section of the program 35. Which of the following is/are synchronization clause? a) Critical b) Ordered

c) Barrier d) All the above Answer:d) All the above 36. Which one of the following is/are type of scheduling? a) Static b) Dynamic c) Guided d) All the above Answer: All the above 37. Data Parallelism is a) form of parallelization across multiple processors in parallel computing environments. b) It focuses on distributing the data across different nodes, which operate on the data in parallel. c) It can be applied on regular data structures like arrays and matrices by working on each element in parallel. d) All the above Answer: d)All the above 38. The four steps to data parallelism are a) Assignment, Decomposition, Mapping, Orchestration b) Orchestration, Decomposition, Assignment, Mapping c) Decomposition, Assignment, Orchestration, Mapping d) Decomposition, Assignment, Mapping, Orchestration Answer: c) Decomposition, Assignment, Orchestration, Mapping 39. Which are the OpenMP clauses supported by Single directive a) copyprivate b) firstprivate c) nowait d) All the above Answer: d)All the above 40. The two types of locks in OpenMP directives to destroy lock datastructures are a) Simple and Complex Locks b) Simple and Nested Locks c) Nested and Composite Locks d) Simple and Composite Locks Answer: b) Simple and Nested Locks 41. Which of the statement is/are true about single construct? a) The copyprivate clause must not be used with the nowait clause b) At most one nowait clause can appear on a single construct. c) Both a) and b) d) None of the above Answer: c) Both a) and b) 42. Which of the following is/are true about worksharing construct? a) Each worksharing region must be encountered by all threads in a team or by none at all, unless cancellation has been requested for the innermost enclosing parallel region.

b) The sequence of worksharing regions and barrier regions encountered must be the same for every thread in a team c) Both a) and b) d) None of the above Answer: c) Both a) and b) 43. Which OpenMP library function is used to set the number of threads in upcoming parallel regions a) omp_get_num_threads() b) omp_set_num_threads() c) omp_get_thread_num() d) omp_set_thread_num() Answer: b) omp_set_num_threads() 44. Which function returns number of threads in parallel region? a) omp_get_num_threads() b) omp_set_num_threads() c) omp_get_thread_num() d) omp_set_thread_num() Answer: a) omp_get_num_threads() 45. Which function Returns an integer that is equal to or greater than the number of threads that would be available if a parallel region without num_threads were defined at that point in the code. a) omp_get_num_threads() b) omp_set_num_threads() c) omp_get_thread_num() d) omp_get_max_threads() Answer: b) omp_get_max_threads() 46. omp_get_thread_num a) returns thread number of threads executing within its thread team b) returns number of threads executing in parallel c) returns number of processors that are available when function is called d) None of the above Answer: a) returns thread number of threads executing within its thread team 47. omp_get_num_procs a) returns thread number of threads executing within its thread team b) returns number of threads executing in parallel c) returns number of processors that are available when function is called d) None of the above Answer: c) returns number of processors that are available when function is called 48. omp_set_dynamic() is used to a) Indicates that the number of threads available in upcoming parallel regions can be fixed b) Indicates that the number of threads available in upcoming parallel regions can be adjusted by the run time. c) Indicate that nested parallelism is enabled d) None of the above Answer: b) Indicates that the number of threads available in upcoming parallel

regions can be adjusted by the run time. 49. omp_get_dynamic() is used to a) Returns the number of threads available in upcoming parallel regions can be fixed b) Returns a value that indicates if the number of threads available in upcoming parallel regions can be fixed. c) Returns a value that indicates if the number of threads available in upcoming parallel regions can be adjusted by the run time. d) None of the above Answer: c) Returns a value that indicates if the number of threads available in upcoming parallel regions can be adjusted by the run time. 50. Whenever a statement in a program reads or writes a memory location and another statement reads or writes the same memory location, and at least one of the two statements writes the location, a) then there is no data dependence on that memory location between the two statements b) then there is a data dependence on that memory location between the two statements c) then there can be neither data dependence or no data dependency d) then there can be either data dependence or no data dependency Answer: a) then there is no data dependence on that memory location between the two statements 51. Setting OMP_NESTED environment variable to TRUE to enable nested parallel region. a) TRUE b) FALSE Answer: a)TRUE 52. Which of the following statement is/are true about data dependences a) OpenMP compilers don’t check for dependences among iterations in a loop that’s being parallelized with a parallel for directive. It’s up to us, the programmers, to identify these dependences. b) A loop in which the results of one or more iterations depend on other iterations cannot, in general, be correctly parallelized by OpenMP. c) Both a) and b) d) None of the above Answer: c)Both a) and b) 53. OpenMP flush operation is applied to a) set of functions b) set of variables c) both a) and b) d) None of the above Answer: b) set of variables 54. OpenMP flush operation is applied to set of variables called a) flushmask b) flushtest c) flushpack d) flushset Answer: d) flush set 55. A barrier directive will cause the threads in a team to block until all the threads have reached the directive.

a) TRUE b) FALSE Answer: a)TRUE 56. Which directive Specifies that a memory location that will be updated atomically a) Barrier directive b) Atomic directive c) Critical directive d) None of the above Answer: b) Atomic directive 57. Atomic directives supports OpenMP Clause. a) TRUE b) FALSE Answer: b) FALSE 58. ______________ refers to the behavior of the memory system when a single memory location is accessed by multiple threads. a) Consistency b) Coherence c) Caching d) None of the above Answer: b)Coherence 59. ___________ refers to the ordering of accesses to different memory locations, observable from various threads in the system a) Consistency b) Coherence c) Caching d) None of the above Answer: b) Consistency 60. Which of the following directives Specifies that code under a parallelized for loop should be executed like a sequential loop. a) Barrier b) Critical c) flush d) Ordered Answer: d)Ordered 61. Which directive Specifies that all threads have the same view of memory for all shared objects a) Barrier b) Critical c) flush d) Ordered Answer: c) flush 62. Which directive synchronizes all threads in a team a) Barrier b) Critical c) flush d) Ordered

Answer: a)Barrier 63. Which directive Specifies that a variable is private to a thread. a) firstprivate b) threadprivate c) lastprivate d) private Answer: b)threadprivate 64. What is the output of the following program? #include #include #define MAX 10 int main() { int count = 0; #pragma omp parallel num_threads(MAX) { #pragma omp atomic count++; } printf_s("Number of threads: %d\n", count); } a) 0 b) 5 c) 10 d) 20 Answer: c)10 65. The parallel directive supports the following clauses a) If b) Private c) Shared d) All the above Answer: d) All the above 66. num_threads applies to the which directives: a) parallel b) for c) section d) All the above Answer: d) All the above 67. Which clause Specifies whether a loop should be executed in parallel or in serial. a) Ordered b) If c) Schedule d) Nowait Answer: b) if 68. Schedule clause applies to which directive a) critical b) section

c) single d) for Answer: d) for 69. Ordered clause applies to which directive a) critical b) section c) single d) for Answer: d) for 70. Which directives Identifies code sections to be divided among all threads a) critical b) section c) single d) for Answer: b) section 71. Which of the following environment variable used in OpenMP? a) OMP_NESTED b) OMP_DYNAMIC c) OMP_NUM_THREADS d) All the above Answer:d) All the above 72. Initial task region is a) initial thread executes sequentially, as if enclosed in an implicit task region b) initial thread Can executes in parallel c) initial thread Can be execute either in sequential or parallel d) None of the above Answer: a) initial thread executes sequentially, as if enclosed in an implicit task region 73. A block of code is _______________ if it can be simultaneously executed by multiple threads without causing problems a) threadsafe b) threadprivate c) threadmemory d) None of the above Answer: a) threadsafe 74. ICV stands for a) Implicit Control Variables b) Internal Control Variables c) Internal Command Variables d) Implicit Command Variables Answer: b) Internal Control Variables 75. What are the ICVs stored values affect loop region? a) Run-sched-var b) Def-sched-var c) Both a) and b) d) None of the above

Answer: c) Both a) and b) 76. Which of the following statement is/are true about SECTION construct? a) It is illegal to branch (goto) into or out of section blocks. b) SECTION directives must occur within the lexical extent of an enclosing SECTIONS directive (no orphan SECTIONs). c) Both a) and b) d) None of the above Answer: c) Both a) and b) 77. What are the ICVs stored values affect program execution? a) Stacksize-var b) Wait-policy-var c) Cancel-var d) All the above Answer: d) All the above 78. Which function returns a nonzero value if it's called within the dynamic extent of a parallel region executing in parallel a) omp_in_parallel b) omp_parallel c) omp_parallel_in d) None of the above Answer: a) omp_in_parallel 79. reduction clause applies to the following directives: a) parallel b) for c) section d) All the above Answer: d) All the above 80. Which header file is used to include the OpenMP header for C program along with the standard header files. a) #include b) #include c) #include d) None of the above Answer: c) #include 81. Message queue provides _________________ a) Synchronous communication protocol b) Asynchronous communication protocol c) Both a) and b) d) None of the above Answer: b)Asynchronous communication protocol 82. If the team consist of only one thread, then work sharing region is not executed in parallel. a) TRUE b) FALSE Answer: a) TRUE

83. Which of the following clause specifies that each thread should have its own instance of a variable, and that the variable should be initialized with the value of the variable, because it exists before the parallel construct. a) private b) firstprivate c) lastprivate d) default Answer: b) firstprivate 84. Which of the following clause specifies that each thread should have its own instance of a variable.. a) private b) firstprivate c) lastprivate d) default Answer: a) private 85. Which of the following clause specifies that the enclosing context's version of the variable is set equal to the private version of whichever thread executes the final iteration (for-loop construct) or last section (#pragma sections a) private b) firstprivate c) lastprivate d) default Answer: c) lastprivate 86. Which of the following clause specifies that one or more variables that are private to each thread are the subject of a reduction operation at the end of the parallel region a) private b) firstprivate c) lastprivate d) reduction Answer: d) reduction 87. Which of the following clause specifies that one or more variables should be shared among all the threads? a) shared b) copyprivate c) both a) and b) d) none of the above Answer: c) both a) and b) 88. nowait clause doesn’t Overrides the barrier implicit in a directive. a) TRUE b) FALSE Answer: b) FALSE 89. If loop directive doesn’t have schedule class, then which of the following is true? a) current value of def_shared_var determine the schedule b) current value of run_shared_var determine the schedule c) value of schedule class determine the schedule d) none of the above

Answer: a) current value of def_shared_var determine the schedule 90. If loop has schedule class that specifies the run time schedule kind, then which of the following is true? a) current value of def_shared_var determine the schedule b) current value of run_shared_var determine the schedule c) value of schedule class determine the schedule d) none of the above Answer: b) current value of run_shared_var determine the schedule 91. A data race is defined to be accesses to a single variable by at least two threads, at least one...


Similar Free PDFs