Mercurial > hg > CbC > CbC_gcc
comparison gcc/omp-general.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* General types and functions that are uselful for processing of OpenMP, | 1 /* General types and functions that are uselful for processing of OpenMP, |
2 OpenACC and similar directivers at various stages of compilation. | 2 OpenACC and similar directivers at various stages of compilation. |
3 | 3 |
4 Copyright (C) 2005-2017 Free Software Foundation, Inc. | 4 Copyright (C) 2005-2018 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
9 the terms of the GNU General Public License as published by the Free | 9 the terms of the GNU General Public License as published by the Free |
141 fd->ordered = 0; | 141 fd->ordered = 0; |
142 fd->sched_kind = OMP_CLAUSE_SCHEDULE_STATIC; | 142 fd->sched_kind = OMP_CLAUSE_SCHEDULE_STATIC; |
143 fd->sched_modifiers = 0; | 143 fd->sched_modifiers = 0; |
144 fd->chunk_size = NULL_TREE; | 144 fd->chunk_size = NULL_TREE; |
145 fd->simd_schedule = false; | 145 fd->simd_schedule = false; |
146 if (gimple_omp_for_kind (fd->for_stmt) == GF_OMP_FOR_KIND_CILKFOR) | |
147 fd->sched_kind = OMP_CLAUSE_SCHEDULE_CILKFOR; | |
148 collapse_iter = NULL; | 146 collapse_iter = NULL; |
149 collapse_count = NULL; | 147 collapse_count = NULL; |
150 | 148 |
151 for (t = gimple_omp_for_clauses (for_stmt); t ; t = OMP_CLAUSE_CHAIN (t)) | 149 for (t = gimple_omp_for_clauses (for_stmt); t ; t = OMP_CLAUSE_CHAIN (t)) |
152 switch (OMP_CLAUSE_CODE (t)) | 150 switch (OMP_CLAUSE_CODE (t)) |
250 var = TREE_CODE (loop->v) == SSA_NAME ? SSA_NAME_VAR (loop->v) : loop->v; | 248 var = TREE_CODE (loop->v) == SSA_NAME ? SSA_NAME_VAR (loop->v) : loop->v; |
251 loop->n1 = gimple_omp_for_initial (for_stmt, i); | 249 loop->n1 = gimple_omp_for_initial (for_stmt, i); |
252 | 250 |
253 loop->cond_code = gimple_omp_for_cond (for_stmt, i); | 251 loop->cond_code = gimple_omp_for_cond (for_stmt, i); |
254 loop->n2 = gimple_omp_for_final (for_stmt, i); | 252 loop->n2 = gimple_omp_for_final (for_stmt, i); |
255 gcc_assert (loop->cond_code != NE_EXPR | 253 gcc_assert (loop->cond_code != NE_EXPR); |
256 || gimple_omp_for_kind (for_stmt) == GF_OMP_FOR_KIND_CILKSIMD | |
257 || gimple_omp_for_kind (for_stmt) == GF_OMP_FOR_KIND_CILKFOR); | |
258 omp_adjust_for_condition (loc, &loop->cond_code, &loop->n2); | 254 omp_adjust_for_condition (loc, &loop->cond_code, &loop->n2); |
259 | 255 |
260 t = gimple_omp_for_incr (for_stmt, i); | 256 t = gimple_omp_for_incr (for_stmt, i); |
261 gcc_assert (TREE_OPERAND (t, 0) == var); | 257 gcc_assert (TREE_OPERAND (t, 0) == var); |
262 loop->step = omp_get_for_step_from_incr (loc, t); | 258 loop->step = omp_get_for_step_from_incr (loc, t); |
421 return g; | 417 return g; |
422 } | 418 } |
423 | 419 |
424 /* Return maximum possible vectorization factor for the target. */ | 420 /* Return maximum possible vectorization factor for the target. */ |
425 | 421 |
426 int | 422 poly_uint64 |
427 omp_max_vf (void) | 423 omp_max_vf (void) |
428 { | 424 { |
429 if (!optimize | 425 if (!optimize |
430 || optimize_debug | 426 || optimize_debug |
431 || !flag_tree_loop_optimize | 427 || !flag_tree_loop_optimize |
432 || (!flag_tree_loop_vectorize | 428 || (!flag_tree_loop_vectorize |
433 && global_options_set.x_flag_tree_loop_vectorize)) | 429 && global_options_set.x_flag_tree_loop_vectorize)) |
434 return 1; | 430 return 1; |
435 | 431 |
436 int vf = 1; | 432 auto_vector_sizes sizes; |
437 int vs = targetm.vectorize.autovectorize_vector_sizes (); | 433 targetm.vectorize.autovectorize_vector_sizes (&sizes); |
438 if (vs) | 434 if (!sizes.is_empty ()) |
439 vf = 1 << floor_log2 (vs); | 435 { |
440 else | 436 poly_uint64 vf = 0; |
441 { | 437 for (unsigned int i = 0; i < sizes.length (); ++i) |
442 machine_mode vqimode = targetm.vectorize.preferred_simd_mode (QImode); | 438 vf = ordered_max (vf, sizes[i]); |
443 if (GET_MODE_CLASS (vqimode) == MODE_VECTOR_INT) | 439 return vf; |
444 vf = GET_MODE_NUNITS (vqimode); | 440 } |
445 } | 441 |
446 return vf; | 442 machine_mode vqimode = targetm.vectorize.preferred_simd_mode (QImode); |
443 if (GET_MODE_CLASS (vqimode) == MODE_VECTOR_INT) | |
444 return GET_MODE_NUNITS (vqimode); | |
445 | |
446 return 1; | |
447 } | 447 } |
448 | 448 |
449 /* Return maximum SIMT width if offloading may target SIMT hardware. */ | 449 /* Return maximum SIMT width if offloading may target SIMT hardware. */ |
450 | 450 |
451 int | 451 int |
610 oacc_get_fn_attrib (tree fn) | 610 oacc_get_fn_attrib (tree fn) |
611 { | 611 { |
612 return lookup_attribute (OACC_FN_ATTRIB, DECL_ATTRIBUTES (fn)); | 612 return lookup_attribute (OACC_FN_ATTRIB, DECL_ATTRIBUTES (fn)); |
613 } | 613 } |
614 | 614 |
615 /* Return true if FN is an OpenMP or OpenACC offloading function. */ | |
616 | |
617 bool | |
618 offloading_function_p (tree fn) | |
619 { | |
620 tree attrs = DECL_ATTRIBUTES (fn); | |
621 return (lookup_attribute ("omp declare target", attrs) | |
622 || lookup_attribute ("omp target entrypoint", attrs)); | |
623 } | |
624 | |
615 /* Extract an oacc execution dimension from FN. FN must be an | 625 /* Extract an oacc execution dimension from FN. FN must be an |
616 offloaded function or routine that has already had its execution | 626 offloaded function or routine that has already had its execution |
617 dimensions lowered to the target-specific values. */ | 627 dimensions lowered to the target-specific values. */ |
618 | 628 |
619 int | 629 int |