B. Kuhn, Paul Petersen, E. O'Toole
{"title":"OpenMP与C/ c++中的线程","authors":"B. Kuhn, Paul Petersen, E. O'Toole","doi":"10.1002/1096-9128(200010)12:12%3C1165::AID-CPE529%3E3.0.CO;2-L","DOIUrl":null,"url":null,"abstract":"When comparing OpenMP to other parallel programming models, it is easier to choose between OpenMP and MPI than between OpenMP and POSIX Threads (Pthreads). With languages like C and C++, developers have frequently chosen Pthreads to incorporate parallelism in applications. Few developers are currently using OpenMP C/C++, but they should. We show that converting Genehunter, a hand-threaded C program, to OpenMP increases robustness without sacrificing performance. It is also a good case study as it highlights several issues that are important in understanding how OpenMP uses threads. \n \nGenehunter is a genetics program which analyzes DNA assays from members of a family tree where a disease is present in certain members and not in others. This analysis is done in an attempt to identify the gene most likely to cause the disease. This problem is called linkage analysis. The same sections of Genehunter were parallelized first by hand-threading and then with OpenMP on Compaq Alpha Tru64 systems. We present examples using both methods and illustrate the tools that proved useful in the process. Our basic conclusion is that, although we could express the parallelism using either Pthreads or OpenMP, it was easier to express the parallelism at a higher level of abstraction. OpenMP allowed enough control to express the parallelism without exposing the implementation details. Also, due to the higher level specification of parallelism with OpenMP, the tools available to assist in the construction of correct and efficient programs provide more useful information than the equivalent tools available for hand-threaded programs. \n \nThe following concepts are presented: \n \n \ndifferences between coding styles for OpenMP and Pthreads; \n \n \ndata scoping specification for correct parallel programming; \n \n \nadapting a signal based exception mechanism to a parallel program; \n \n \nOpenMP tools: Debuggers—Ladebug, TotalView and Assure; Profilers—Hiprof and GuideView; \n \n \nperformance tuning with memory allocation, synchronization, and scheduling. \n \n \n \nGenehunter does not cover a few important topics in C/C++ programming style, which will be discussed separately. These are: \n \n \ninterfacing a GUI team of threads with an OpenMP compute team; \n \n \ncoordinating data structure with scheduling. \n \n \n \nCopyright © 2000 John Wiley & Sons, Ltd.","PeriodicalId":199059,"journal":{"name":"Concurr. Pract. Exp.","volume":"63 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2000-10-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"41","resultStr":"{\"title\":\"OpenMP versus threading in C/C++\",\"authors\":\"B. Kuhn, Paul Petersen, E. O'Toole\",\"doi\":\"10.1002/1096-9128(200010)12:12%3C1165::AID-CPE529%3E3.0.CO;2-L\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"When comparing OpenMP to other parallel programming models, it is easier to choose between OpenMP and MPI than between OpenMP and POSIX Threads (Pthreads). With languages like C and C++, developers have frequently chosen Pthreads to incorporate parallelism in applications. Few developers are currently using OpenMP C/C++, but they should. We show that converting Genehunter, a hand-threaded C program, to OpenMP increases robustness without sacrificing performance. It is also a good case study as it highlights several issues that are important in understanding how OpenMP uses threads. \\n \\nGenehunter is a genetics program which analyzes DNA assays from members of a family tree where a disease is present in certain members and not in others. This analysis is done in an attempt to identify the gene most likely to cause the disease. This problem is called linkage analysis. The same sections of Genehunter were parallelized first by hand-threading and then with OpenMP on Compaq Alpha Tru64 systems. We present examples using both methods and illustrate the tools that proved useful in the process. Our basic conclusion is that, although we could express the parallelism using either Pthreads or OpenMP, it was easier to express the parallelism at a higher level of abstraction. OpenMP allowed enough control to express the parallelism without exposing the implementation details. Also, due to the higher level specification of parallelism with OpenMP, the tools available to assist in the construction of correct and efficient programs provide more useful information than the equivalent tools available for hand-threaded programs. \\n \\nThe following concepts are presented: \\n \\n \\ndifferences between coding styles for OpenMP and Pthreads; \\n \\n \\ndata scoping specification for correct parallel programming; \\n \\n \\nadapting a signal based exception mechanism to a parallel program; \\n \\n \\nOpenMP tools: Debuggers—Ladebug, TotalView and Assure; Profilers—Hiprof and GuideView; \\n \\n \\nperformance tuning with memory allocation, synchronization, and scheduling. \\n \\n \\n \\nGenehunter does not cover a few important topics in C/C++ programming style, which will be discussed separately. These are: \\n \\n \\ninterfacing a GUI team of threads with an OpenMP compute team; \\n \\n \\ncoordinating data structure with scheduling. \\n \\n \\n \\nCopyright © 2000 John Wiley & Sons, Ltd.\",\"PeriodicalId\":199059,\"journal\":{\"name\":\"Concurr. Pract. Exp.\",\"volume\":\"63 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2000-10-01\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"41\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Concurr. Pract. Exp.\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.1002/1096-9128(200010)12:12%3C1165::AID-CPE529%3E3.0.CO;2-L\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Concurr. Pract. Exp.","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1002/1096-9128(200010)12:12%3C1165::AID-CPE529%3E3.0.CO;2-L","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 41
OpenMP versus threading in C/C++
When comparing OpenMP to other parallel programming models, it is easier to choose between OpenMP and MPI than between OpenMP and POSIX Threads (Pthreads). With languages like C and C++, developers have frequently chosen Pthreads to incorporate parallelism in applications. Few developers are currently using OpenMP C/C++, but they should. We show that converting Genehunter, a hand-threaded C program, to OpenMP increases robustness without sacrificing performance. It is also a good case study as it highlights several issues that are important in understanding how OpenMP uses threads.
Genehunter is a genetics program which analyzes DNA assays from members of a family tree where a disease is present in certain members and not in others. This analysis is done in an attempt to identify the gene most likely to cause the disease. This problem is called linkage analysis. The same sections of Genehunter were parallelized first by hand-threading and then with OpenMP on Compaq Alpha Tru64 systems. We present examples using both methods and illustrate the tools that proved useful in the process. Our basic conclusion is that, although we could express the parallelism using either Pthreads or OpenMP, it was easier to express the parallelism at a higher level of abstraction. OpenMP allowed enough control to express the parallelism without exposing the implementation details. Also, due to the higher level specification of parallelism with OpenMP, the tools available to assist in the construction of correct and efficient programs provide more useful information than the equivalent tools available for hand-threaded programs.
The following concepts are presented:
differences between coding styles for OpenMP and Pthreads;
data scoping specification for correct parallel programming;
adapting a signal based exception mechanism to a parallel program;
OpenMP tools: Debuggers—Ladebug, TotalView and Assure; Profilers—Hiprof and GuideView;
performance tuning with memory allocation, synchronization, and scheduling.
Genehunter does not cover a few important topics in C/C++ programming style, which will be discussed separately. These are:
interfacing a GUI team of threads with an OpenMP compute team;
coordinating data structure with scheduling.
Copyright © 2000 John Wiley & Sons, Ltd.