| [004075f] | 1 | /*
|
|---|
| 2 |
|
|---|
| 3 | DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|---|
| 4 |
|
|---|
| 5 | Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
|---|
| 6 |
|
|---|
| 7 | The contents of this file are subject to the terms of the BSD License("BSD")(the "License").
|
|---|
| 8 | You can obtain a copy of the License at: http://www.opensparc.net/pubs/t1/licenses/BSD+_License.txt
|
|---|
| 9 |
|
|---|
| 10 | The BSD License
|
|---|
| 11 |
|
|---|
| 12 | Redistribution and use in source and binary forms, with or without
|
|---|
| 13 | modification, are permitted provided that the following conditions are met:
|
|---|
| 14 |
|
|---|
| 15 | * Redistribution of source code must retain the above copyright
|
|---|
| 16 | notice, this list of conditions and the following disclaimer.
|
|---|
| 17 | * Redistribution in binary form must reproduce the above copyright
|
|---|
| 18 | notice, this list of conditions and the following disclaimer in
|
|---|
| 19 | the documentation and/or other materials provided with the
|
|---|
| 20 | distribution.
|
|---|
| 21 | * Neither the name of Sun Microsystems, Inc. or the names of
|
|---|
| 22 | contributors may be used to endorse or promote products derived
|
|---|
| 23 | from this software without specific prior written permission.
|
|---|
| 24 |
|
|---|
| 25 | This software is provided "AS IS," without a warranty of any kind. ALL
|
|---|
| 26 | EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
|---|
| 27 | IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|---|
| 28 | NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|---|
| 29 | ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
|
|---|
| 30 | RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
|
|---|
| 31 | IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
|
|---|
| 32 | OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
|---|
| 33 | PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
|
|---|
| 34 | ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
|
|---|
| 35 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|---|
| 36 |
|
|---|
| 37 | You acknowledge that this software is not designed, licensed or intended for
|
|---|
| 38 | use in the design, construction, operation or maintenance of any nuclear facility.
|
|---|
| 39 |
|
|---|
| 40 | */
|
|---|
| 41 |
|
|---|
| 42 | #include <stdio.h>
|
|---|
| 43 | #include <stdlib.h>
|
|---|
| 44 |
|
|---|
| 45 | #ifdef _OPENMP
|
|---|
| 46 | #include <omp.h>
|
|---|
| 47 | #define TRUE 1
|
|---|
| 48 | #define FALSE 0
|
|---|
| 49 | #else
|
|---|
| 50 | #define omp_get_thread_num() 0
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|
| 53 | int main(int argc, char *argv[])
|
|---|
| 54 | {
|
|---|
| 55 |
|
|---|
| 56 | int TID = omp_get_thread_num();
|
|---|
| 57 |
|
|---|
| 58 | printf("Thread ID of the master thread is %d\n",TID);
|
|---|
| 59 |
|
|---|
| 60 | #ifdef _OPENMP
|
|---|
| 61 | (void) omp_set_dynamic(FALSE);
|
|---|
| 62 | if (omp_get_dynamic()) {printf("Warning: dynamic adjustment of threads has been set\n");}
|
|---|
| 63 | (void) omp_set_num_threads(4);
|
|---|
| 64 | #endif
|
|---|
| 65 |
|
|---|
| 66 | #pragma omp parallel
|
|---|
| 67 | {
|
|---|
| 68 | int TID = omp_get_thread_num();
|
|---|
| 69 |
|
|---|
| 70 | printf("In parallel region - Thread ID is %d\n",TID);
|
|---|
| 71 | } /*-- End of parallel region --*/
|
|---|
| 72 |
|
|---|
| 73 | return(0);
|
|---|
| 74 | }
|
|---|