HP C/aC++ for PA-RISC Software manual OpenMP Clauses

Page 114

where [clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses.

clause may be one of the following:

if (scalar-expression))

untied

default (shared none)

private (list)

firstprivate (list)

shared (list)

The TASK directive defines an explicit task.

OMP TASKWAIT Pragma

#pragma omp taskwait new-line

The TASKWAIT directive specifies a wait on the completion of child tasks generated since the beginning of the current task.

Because the TASKWAIT construct does not have a C language statement as part of its syntax, there are some restrictions on its placement within a program. The TASKWAIT directive may be placed only at a point where a base language statement is allowed. The TASKWAIT directive may not be used in place of the statement following an if, while, do, switch, or label.

OMP THREADPRIVATE Pragma

#pragma omp threadprivate (list)

where (list) is a comma-separated list of variables that do not have an incomplete type.

The threadprivate directive makes the named file-scope, namescope-scope, or static block-scopevariables private to a thread.

OpenMP Clauses

Clauses on directives may be repeated as needed, subject to the restrictions listed in the description of each clause. The order in which clauses appear in directives is not significant. If variable-list appears in a clause, it must specify only variables. The following is the list of clauses in OpenMP directives:

private

private(list)

The private clause declares the variables in the list to be private to each thread in a team. A new object with automatic storage duration is allocated within the associated structured block for each thread in the stream.

firstprivate

firstprivate(list)

The firstprivate clause provides a superset of the functionality provided by the private clause. Variables specified in the list have private clause semantics described earlier. The new private object is initialized, as if there is an implied declaration inside the structured block and the initializer is the value of the original object.

lastprivate

lastprivate(list)

114 Pragma Directives and Attributes

Image 114
Contents HP aC++/HP C A.06.28 Programmers Guide Page Contents +FP Contents Contents Contents Copyright Notice and Identification Pragmas Pragma Directives and AttributesInitialization and Termination Pragmas Data Alignment PragmasContents Preprocessing Directives 119 Using HP aC++ Templates 132 Standardizing Your Code 138Optimizing HP aC++ Programs 156 Exception Handling 161Tools and Libraries 175 170Mixing C++ with Other Languages 188 Distributing Your C++ Products 195 Migrating from HP C++ cfront to HP aC++ 198Strings 194 Arrays Files in Fortran Documentation feedback 221 Diagnostic Messages 222 Glossary 223 Index 227HP secure development lifecycle About This Document Intended AudienceWhat’s in This Document Typographical Conventions This document uses the following conventionsHP-UX Release Name and Release Identifier Publishing HistoryRelated Documents HP-UX 11i ReleasesHP Encourages Your Comments Following is a list of documents available with this releaseC89 C99 ecom Ctcom Getting Started with HP aC++Components of the Compilation System Other HP aC++ executable files areExecuting the Program Using the aCC CommandCompiling a Simple Program Debugging ProgramsCompiler Command Syntax and Environmental Variables Examples of the aCC Command++ Source File .C file Files on the aCC Command LineAssembly Language Source Files .s Files Preprocessed Source Files .i FilesObject Files .o Files Configuration Files .conf FilesEnvironment Variables Library Files .a and .so FilesCxxopts Environment Variable ACCFULLPATHNAMES Environment VariableACCMAXERR Environment Variable Cclibdir Environment VariableCcrootdir Environment Variable ACC -L/mnt/proj/lib file.o ACC file.oTmpdir Environment Variable Floating InstallationCxxmapfile Environment Variable Export CCROOTDIR=/mnt/CXX2.1Setting up Floating Installation HP aC++Command-Line Options ACC +DO11.22 +O3 app.C Options to Control Code GenerationACC -c sub.C prog.C ILP32 Data Model and LP64 Data ModelUsing +DS to Specify Instruction Scheduling Compiling in Networked EnvironmentsData Alignment and Storage ACC -S prog.CSize and Alignment of HP Compiler Data Types +expandtypesindiag Debugging OptionsFshort-enums ACC +u1 app.CG1 Algorithm When to use -g, -g0, and -g1Differences Between -g, -g0, and -g1 Options +macrodebug+pathtrace=kind +noobjdebug+pathtrace Local+pathtrace=globallocal Error HandlingNone ACC +p file.C+wn +Wargs+Wcontextlimit +Weargs +wperfadvice+We +Wv+wsecurity Exception HandlingExtensions to the Language +noeh+Onofenvaccess Floating-Point Processing Options+Onocxlimitedrange Nofpwidetypes FpevalFpevaldec +decfp+Oprefetchlatency +FPmode+Onolibmerrno +OnopreservedfpregsHeader File Options ACC -I include file.C Idirs -I- -Idirs Online Help Option +helpInlining Options +inlinelevel numExec Library OptionsDynamic Lname+nostl Linker OptionsMinshared +Onolibcalls=+Onodynopt UsymbolUsymbol +Onodynopt+ild Options for Naming the Output FileNative Language Support Option +ildrelinkBasic Optimization Level Options Handling Null Pointers OptionsCode Optimizing Options ACC -z file.C+O2 +O0+O1 +O3ACC +O3 prog.C Additional Optimization Options for Finer Control+O4 +O4Ipo +nonrv+Onofailsafe +Onolimit Advanced +Ooptimization Options+Onoaggressive +Onoptrstoglobals=list+Onodataprefetch +Onocrossregionaddressing+Onodatalayout +Onofltacc+Ofrequentlycalled +Onoinitcheck+Onoinline +Olit+Ointegeroverflow +Onoloopunroll +Olevel+Onolooptransform +Onoopenmp+Onoparmsoverlap +opts+Onoparminit +Onoprocelim+Orarelycalled +Onosignedpointers+Oshortdata +Onostoreordering +OtypesafetyProfile-Based Optimization Options +OunrollfactorDisplaying Optimization Information Parallel Processing OptionsInformation Embedding Options Annotate=structsOption Matrix for -mt Required if -DPOSIXCSOURCEis used+Onoautopar +tls=staticdynamicFast Performance Options+wlock +Ofast+nosrcpos +Ofaster+Onotlscallschangetp +DSmodel+ub Porting Options+sb +uc+wendian +w64bit+wdriver This warning can be suppressed by adding an extra castPreprocessor Options DnameRedirecting Output From This Option +maked Maked+Maked ExamplesProfiling Code Options Uname+profilebucketsize +check=all Runtime Checking Options+check +check=none+check=boundsarray +check=boundspointer Compiling with +check=boundspointerCheck off by one out-of-bounds access Check off by any number out-of-bounds access+check=globals +check=lock+check=malloc +check=stackframevariablesnone +check=threadCh = intval & 0xff +check=truncateexplicit +check=truncateexplicitimplicit+check=uninit +check=truncateimplicitStandards Related Options AarmAarm Ag++ AC89AC99 AgccAOa and -AOe +legacycpp+legacyv5 +std=c89c99c++98c++11gccg++gnu +stl=rwnoneWc,-koeniglookup,onoff +tru64Wc,-ansiforscope,onoff +tru64More Examples of -t Subprocesses of the CompilerTx,name Tx,nameWx,args Bextern Symbol Binding OptionsBdefault Passing Options to the Linker with -WBprotected BhiddenBhiddendef BprotecteddataTemplate Options Trigraph Processing Suppression Option +instincludesuffixesVerbose Compile and Link Information Process Compiler 94/u 65/s 35/r 37/u 76/s 02/r Concatenating Options ACC -V app.CACC myfile.C -v -g1 ACC myfile.C -vg1 ACC -vg1 myfile.C Pragma Directives and Attributes Initialization and Termination PragmasCopyright Notice and Identification Pragmas #pragma Versionid Software Product, Version 12345.A.01.05 Data Alignment Pragmas#pragma Versionid string #pragma align NData Alignment Pragmas Basic Example Template ExampleImplicit Access to Unaligned Data Handling Unaligned Data#pragma unalign Typedef T1 T2 Interaction between pack and unalign pragmas is as followsOptimize Pragma Optimization PragmasOptlevel Pragma Floattrapson PragmaNoinline Pragma Diagnostic Pragmas Other PragmasEstimatedfrequency Pragma Defaultbinding PragmaBinding Pragma Extern PragmaHpdefinedexternal Pragma Hdrstop PragmaHidden Pragma Hpdefinedinternal PragmaProtected Pragma POP PragmaPragma once Ptrsstronglytyped PragmaStdc FLOATCONSTDECIMAL64 Pragma #pragma Stdc FLOATCONSTDECIMAL64 on OFF DefaultStdc Cxlimitedrange Pragma Stdc Fpcontract PragmaStdc Fenvaccess Pragma Unrollfactor PragmaOMP Atomic Pragma OMP for Pragma OMP Barrier PragmaOMP Critical Pragma OMP Flush PragmaOMP Parallel Pragma OMP Master PragmaOMP Ordered Pragma OMP Parallel for PragmaOMP Single Pragma OMP Parallel Sections PragmaOMP Sections Pragma OMP Task PragmaOpenMP Clauses Shared DefaultCopyprivate CopyinAttributes Attribute nonexposing Attribute nonexposingAttribute noreturn Attribute noreturnAttribute format Attribute visibilityAttribute warnunusedresult Syntax Preprocessing DirectivesOverview of the Preprocessor Usage GuidelinesDescription Source File Inclusion #include, #includenextSyntax Assertions #assert, #unassertExamples Macro Replacement #define, #undef#define mac very very long\ Replacement string Macros with ParametersExample Specifying String Literals with the # OperatorConcatenating Tokens with the ## Operator Following illustrates the ## operatorVar1 is Using Macros to Define ConstantsOther Macros #define Arraysize 1000float xARRAYSIZEUsing Constants and Inline Functions Instead of Macros Assertions #assert, #unassert Predefined MacrosConditional Compilation #if, #ifdef, .. #endif HP aC++ predefines the following predicatesCode that compiles if the expression evaluates to zero Using the #ifdef and #ifndef Directives Using the defined OperatorUsing the #if Directive Using the #else DirectiveLine Control #line Example#line 5 myfile Pragma Directive #pragma and Pragma Operator This macro enables the following non-standard featuresIostream Performance Improvement Pragma See page 96 for more information on pragmasExamples Error Directive #errorTrigraph Sequences Line below contains the trigraph sequence ??=When this line is compiled it becomes ??=line 5 myfileScope and Precedence Using HP aC++ TemplatesInvoking Compile-Time Instantiation Template ProcessingPerformance Explicit InstantiationUsage Template class TablecharFunction Template Command-Line Option InstantiationCompile-Time Instantiation ACC -c +instcompiletime a.C ACC -c a.CPossible Duplicate Symbols in Archive Libraries Why Use Compile-Time InstantiationPossible Duplicate Symbols in Shared Libraries ScopeBuilding an Archive Library with +instauto/+instclose ++ Template TutorialClass Templates Building an Archive Library with Compile-time InstantiationFunction Templates Bool Keyword Standardizing Your CodeHP aC++ Keywords HP aC++ KeywordsCompile time error message is Dynamiccast KeywordAbove generates a compile-time error Explicit Keyword Classic example of this problem is an array class Mutable Keyword Namespace and using Keywords Connections Across Translation UnitsAn Auxiliary Translation Unit Using- declarations and using- directivesUsing Nx // Where N is a namespace, x is a name in N IntPage Class Base Virtual void f Must have a virtual function to Volatile Keyword Wchart Keyword Template KeywordTypename Keyword Overloading new and delete for Arrays Use it as the name of the template C belowDeclare a class as a member of the class template C2 below Example Rangeerror Standard Exception ClassesInvalidargument Exceptions Thrown by the Standard C++ Library Typeinfo ClassFollowing exceptions are thrown by the Standard C++ Library Unsupported Functionality Int before const typeinfo& constMemfun1reft Memfunreft Iostream Requesting Optimization Setting Basic Optimization LevelsOptimizing HP aC++ Programs Level 1 OptimizationLevel 4 Optimization Additional Options for Finer ControlLevel 3 Optimization Enabling Aggressive OptimizationsEnabling Only Conservative Optimizations Removing Compilation Time Limits When OptimizingProfile-Based Optimization Limiting the Size of Optimized CodeMaintaining Profile Data Files InstrumentationCollecting Data for Profiling Sample.exe input.file1 Sample.exe input.file2ACC -o sample.exe +Oprofile=use +O3 sample.C Pragmas That Control OptimizationPerforming Profile-Based Optimization See Optimization Pragmas page 103 for more informationException Handling Exception Handling in C++Basic Exception Handling Example Function Try Block ExamplesDebugging Exception Handling Performance Considerations Using ThreadsUsing Locks Rogue Wave Standard C++ LibraryRogue Wave Standard C++ Library 1.2.1 and Tools.h++ Required Command-line OptionsRogue Wave Standard C++ Library LpthreadThis option applies only to kernel threadsLimitations Using -DTHREADSAFE with the cfront Compatible libstreamUsing -DHPACCTHREADSAFERBTREE Cout endlPthreads Posix Threads Exception HandlingACC -mt prog.c Parallel Programming Using OpenMP Function ScopingOpenMP Implementation OpenMP Header File OpenMP LibraryOpenMP APIs are defined in the library libomp Openmp Macro +Onoopenmp Command Line OptionEnvironment Variables in OpenMP Where, kind is either of of static, dynamic, or guidedExport OMPDYNAMIC=value Setenv Ompdynamic value Runtime Library Functions in OpenMPExecution Environment Functions Export OMPNESTED=value Setenv Ompnested valueOmpgetmaxthreads OmpsetnumthreadsOmpgetnumthreads OmpgetthreadnumOmpgetdynamic Lock FunctionsOmpsetdynamic OmpsetnestedOmpsetlock and ompsetnestlock Ompinitlock and ompinitnestlockOmpdestroylock and ompdestroynestlock Ompunsetlock and ompunsetnestlockOmpgetwtime Timing FunctionsOmptestlock and omptestnestlock Functions OmpgetwtickTools and Libraries HP Specific Features of lex and yaccCreating and Using Libraries Locale directive for lexStandard C++ Library Introduction to Using the Standard C++ LibraryHP aC++ Libraries IntroductionDifferences between Standard C++ Library and Other Libraries Non-Object-Oriented Design of the Standard C++ LibraryStandard C++ Library Reference Incompatibilities Between the Library and the StandardHP aC++ Runtime Support Library ACC -DHPACCUSINGMULTIPLIESINFUNCTIONAL test.cTools.h++ Library IOStream LibraryLinking with Shared or Archive Libraries Creating and Using Shared LibrariesLinking to C++ Libraries Specifying Other LibrariesCreating a Shared Library Using a Shared LibraryExample of Creating and Using a Shared Library Linking Archive or Shared LibrariesAdvanced Shared Library Features Forcing the Export of Symbols in mainUpdating a Shared Library Routines and Options to Manage C++ Shared Libraries Binding TimesSide Effects of C++ Shared Libraries Linker Options to Manage Shared LibrariesStandard HP-UX Libraries and Header Files Allocation Policies for ContainersFor -AA Standard Library For a string typeHP aC++ File Locations HP aC++ Executable FilesHP aC++ Runtime Libraries and Header Files Usr/lib/hpux##/libCsup.soUsr/lib/hpux##/libCsup11.so ISO C++11 standard compliant Mixing C++ with Other Languages Calling Other LanguagesData Compatibility between C and C++ Syntax of extern C Using the extern C Linkage SpecificationHP aC++ Calling HP C Examples of extern CDifferences in Argument Passing Conventions Main FunctionExamples HP aC++ Calling HP C HP C Calling HP aC++ Running the ExampleEnter the nameJoann Joann has a balance To compile the example, run the following commands Compiling and Running the Sample ProgramsFunction Naming Conventions Using Reference Variables to Pass ArgumentsCalling HP Fortran 90 from HP aC++ Example of Reference Variables as ArgumentsArrays Using extern C LinkageStrings Files in FortranDistributing Your C++ Products Applications that use HP aC++ Shared LibrariesInstalling your Application Linking Your HP aC++ Libraries with Other LanguagesHP aC++ Files You May Distribute Terms for Distribution of HP aC++ Files Getting Started with Migration Migrating from HP C++ cfront to HP aC++General Guidelines for Migration CC +p cfrontfile.CWriting Code for both Compilers Command-Line DifferencesNew Command-Line Options Explicit Loading and Unloading of Shared LibrariesObsolete Command-Line Options Describes obsolete command-line options for HP aC++Changed Command-Line Options PtvException Handling is the Default Migration Considerations when DebuggingMigration Considerations when Using Exception Handling See Debugging Options page 35 for complete informationPossible Differences when Exiting a Signal Handler Memory Allocation Failure and operator newDifferences in setjmp/longjmp Behavior Calling unexpectedUnreachable catch Clauses Throwing an Object having an Ambiguous Base ClassMigration Considerations when Using Libraries Standards Based LibrariesManip3C++ iostream manipulators HP C++ cfront Compatibility LibrariesFstream3C++ iostream and streambuf specialized to files Man 3s filebufHP C++ cfront Task Library Not Supported Migration Considerations Related to PreprocessingHP C++ cfront Complex Library Not Supported Replace #include with complexChanges in C++ Semantics Migration Considerations Related to StandardizationObsolete Preprocessor Options Implicit Typing of Character String LiteralsOverload Resolution Ambiguity of Subscripting Operator Execution Order of Static Constructors in Shared LibrariesChanges in C++ Syntax More Frequent Inlining of Inline CodeExplicit int Declaration Equivalent, valid HP aC++ code follows For Statement, New Scoping RulesStruct as Template Type Parameter is Permitted WC,-ansiforscope,onTokens after #endif This code compiles without error with HP aC++Base Template Class Reference Syntax Change Overload not a KeywordDangling Comma in enum Static Member Definition RequiredDeclaring friend Classes Duplicate Formal Argument Names Using in Class DefinitionsIncorrect Syntax for Calls to operator new Ambiguous Function or Object DeclarationOverloaded Operations ++ Reference InitializationCompiling this code HP aC++ generates the following error Using operator new to Allocate ArraysOn HP aC++, the following error is generated Parentheses in Static Member Initialization ListQualified-id Required in Static Member Initialization List Non-constant Reference InitializationDigraph White Space Separators Migration Considerations when Using TemplatesVerbose Template Processing Information CA aConverting Directed Mode to Explicit Instantiation Common Template Migration Syntax ChangesCfront Implicit Include Convention Documentation feedback Diagnostic Messages AC++ Message CatalogFrequently Encountered Messages Glossary AggressiveInternational Standard defines only synchronous exceptions See template Glossary Symbols IndexCrootdir FLOATTRAPSON, 103 FREQUENTLYCALLED, 106 HDRSTOP, 107 Hidden Index
Related manuals
Manual 15 pages 49.53 Kb