From patchwork Thu Apr 4 23:18:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 233996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id DEA862C00A3 for ; Fri, 5 Apr 2013 10:18:26 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=Hya+nf3FcORjFhgPp8P9hNMMS7vrWlAA4thV4hWlSNkMBJ 1zRB4vdifyCMVXYHvAECMX7CMngDXaT6XvR1o0EKKPZfdH1cY0UPrn8I+/rFzW9c rsqHJVR4qRwZwY7PhhXSZycCJOVSHB8iouq+M+zVfmoEqe2yn4hXFcQxfCrF8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=qd22s2xqY/F4t6NWxavp+psJLXI=; b=s2r5KU2fDkG8dr0CXDIq kmDHpeqOGmQPRpdEHXLm0jG5hIVJ4ABizkSF+NMUUiGY7VlFpu80yNWVyrtLvc3K /YYLIYlggkI1S0xgYv1nHNhxtTgja0yGPJQ2tbOwd1NFBi+01XbUcTTQF4qo9DH5 3S7bm7iMWHkxVe+4D1cp9Gw= Received: (qmail 2937 invoked by alias); 4 Apr 2013 23:18:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2924 invoked by uid 89); 4 Apr 2013 23:18:14 -0000 X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 04 Apr 2013 23:18:09 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r34NI7wh012799 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Apr 2013 19:18:07 -0400 Received: from houston.quesejoda.com (vpn-61-114.rdu2.redhat.com [10.10.61.114]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r34NI6YK001258; Thu, 4 Apr 2013 19:18:06 -0400 Message-ID: <515E0A2E.3000500@redhat.com> Date: Thu, 04 Apr 2013 18:18:06 -0500 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: "Iyer, Balaji V" , gcc-patches Subject: [cilkplus] misc cleanups for <#pragma simd> implementation X-Virus-Found: No Hi Balaji. This is a patch against, the [cilkplus] branch (not the [cilkplus-merge] branch). I have taken the liberty to start cleaning up the <#pragma simd> stuff on your development branch, while the array notation patchset is being reviewed by Joseph. Herein lies a potpourri of fixes, refactoring, and cleanups. They should all be pretty obvious. There are two main functional changes: 1. I removed setting of flag_vectorize in the front-end. This is certainly not going to fly. Instead, I am issuing an error when <#pragma simd> is used without -ftree-vectorize. For testing I have added the appropriate flag when tests are running at lower optimization levels. 2. I noticed some of the errors wrt <#pragma simd> were pointing to the wrong place. I have saved the location_t of the original #pragma and saved this in the global pragma simd table. This makes errors more meaningful. I have added various FIXME notes throughout for things I plan to tackle next. If you prefer me not adding such notes, I can remove them, but rest assured, I'll work on them shortly. I have renamed the {compile,errors,execute}.exp files to something less ambiguous. As explained before, this makes it easier to test individual components, ala "make check-gcc RUNTESTFLAGS=foo.exp". There are no regressions with this patch, but I noticed all the tests in gcc.dg/cilk-plus/pragma_simd_tests/execute/ were failing before my patch: /usr/bin/ld: cannot find -lcilkrts collect2: error: ld returned 1 exit status compiler exited with status 1 I don't see a -L in the command line, but I didn't bother to look into it. It was broken before ;-). Finally, building the toolchain seems to automagically regenerate the following files: # modified: ../../../libcilkrts/Makefile.in # modified: ../../../libcilkrts/aclocal.m4 # modified: ../../../libcilkrts/configure Is this on purpose? Should I check in the modified files? FWIW, I am *not* including these modified files into this patch. Oh, one more thing... assuming you are keeping a merged set of ChangeLog entries for eventual merging, I am only including changelog entries for new code I am touching. I assume, there are already entries for code you have already touched. OK to commit to cilkplus branch? commit 2e7512b89697723cae25685a9b50ba7070da998d Author: Aldy Hernandez Date: Wed Apr 3 15:09:28 2013 -0500 Minor cleanups and refactoring of pragma simd code. Add location information to pragma simd table entries. Rename compile.exp, errors.exp, and execute.exp for the cilk_keywords test directory. Getting rid of the naming redundancy makes it possible to test on set at a time: make check-gcc RUNTESTFLAGS=cilkplus_keywords_c_compile.exp diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index f00d28d..98265ba 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -117,26 +117,11 @@ c_parse_init (void) ridpointers [(int) c_common_reswords[i].rid] = id; } - /* Here we initialize the simd_values structure. We only need it - initialized the first time, after each consumptions, for-loop will - automatically consume the values and delete the information. */ - cilkplus_local_simd_values.index = 0; - cilkplus_local_simd_values.pragma_encountered = false; - cilkplus_local_simd_values.types = P_SIMD_NOASSERT; - cilkplus_local_simd_values.vectorlength = NULL_TREE; - cilkplus_local_simd_values.vec_length_list = NULL; - cilkplus_local_simd_values.vec_length_size = 0; - cilkplus_local_simd_values.private_vars = NULL_TREE; - cilkplus_local_simd_values.priv_var_list = NULL; - cilkplus_local_simd_values.priv_var_size = 0; - cilkplus_local_simd_values.linear_vars = NULL_TREE; - cilkplus_local_simd_values.linear_var_size = 0; - cilkplus_local_simd_values.linear_var_list = NULL; - cilkplus_local_simd_values.linear_steps = NULL_TREE; - cilkplus_local_simd_values.linear_steps_list = NULL; - cilkplus_local_simd_values.linear_steps_size = 0; - cilkplus_local_simd_values.reduction_vals = NULL; - cilkplus_local_simd_values.ptr_next = NULL; + /* Only initialize the first time. After each consumption, the + for-loop handling code (c_finish_loop) will automatically consume + the values and delete the information. */ + memset (&cilkplus_local_simd_values, 0, + sizeof (cilkplus_local_simd_values)); clear_pragma_simd_list (); } @@ -1251,12 +1236,16 @@ static void c_parser_objc_at_synthesize_declaration (c_parser *); static void c_parser_objc_at_dynamic_declaration (c_parser *); static bool c_parser_objc_diagnose_bad_element_prefix (c_parser *, struct c_declspecs *); + +// FIXME: Re-work this so there are only prototypes for mutually +// recursive functions. +/* Cilk Plus supporting routines. */ static void c_parser_cilk_for_statement (c_parser *, tree); -void c_parser_simd_linear (c_parser *); -void c_parser_simd_private (c_parser *); -void c_parser_simd_assert (c_parser *, bool); -void c_parser_simd_vectorlength (c_parser *); -void c_parser_simd_reduction (c_parser *); +static void c_parser_simd_linear (c_parser *); +static void c_parser_simd_private (c_parser *); +static void c_parser_simd_assert (c_parser *, bool); +static void c_parser_simd_vectorlength (c_parser *); +static void c_parser_simd_reduction (c_parser *); static tree c_parser_array_notation (location_t, c_parser *, tree, tree); /* Parse a translation unit (C90 6.7, C99 6.9). @@ -8799,7 +8788,7 @@ c_parser_objc_at_dynamic_declaration (c_parser *parser) #pragma simd assert #pragma simd noassert */ -void +static void c_parser_simd_assert (c_parser *parser, bool is_assert) { c_token *token; @@ -8856,7 +8845,7 @@ c_parser_simd_assert (c_parser *parser, bool is_assert) #pragma simd linear (:[], ...) */ -void +static void c_parser_simd_linear (c_parser *parser) { tree linear_var_list = NULL_TREE, linear_steps_list = NULL_TREE; @@ -8967,14 +8956,13 @@ c_parser_simd_linear (c_parser *parser) } } cilkplus_local_simd_values.pragma_encountered = true; - return; } /* This function will parse the pragma simd private in the Cilkplus language extension. The correct syntax is: #pragma simd private ( [, ]) */ -void +static void c_parser_simd_private (c_parser *parser) { tree private_var = NULL_TREE; @@ -9068,15 +9056,13 @@ c_parser_simd_private (c_parser *parser) c_parser_for_statement (parser); } } - - return; } /* This function will parse the pragma simd vectorlength in the Cilkplus language extension. The correct syntax is: #pragma simd vectorlength ( [, ]*) */ -void +static void c_parser_simd_vectorlength (c_parser *parser) { tree vec_length_list = NULL_TREE, v_length_value = NULL_TREE; @@ -9168,8 +9154,6 @@ c_parser_simd_vectorlength (c_parser *parser) c_parser_for_statement (parser); } } - - return; } /* This function will parser the Pragma SIMD Reduction in the Cilkplus language @@ -9177,7 +9161,7 @@ c_parser_simd_vectorlength (c_parser *parser) #pragma simd reduction (: [, ]*) */ -void +static void c_parser_simd_reduction (c_parser *parser) { c_token *token; @@ -9299,7 +9283,6 @@ c_parser_simd_reduction (c_parser *parser) values given in the local_pragma_simd variable. */ c_parser_for_statement (parser); } - return; } /* This function helps parse the grainsize pragma available in the Cilkplus @@ -9353,9 +9336,35 @@ c_parser_cilk_grainsize (c_parser *parser) } else c_parser_skip_to_pragma_eol (parser); - return; } - + +/* Helper function for c_parser_pragma. Perform some sanity checking + for <#pragma simd> constructs. Returns FALSE if there was a + problem. */ + +static bool +c_parser_pragma_simd_ok_p (c_parser *parser, enum pragma_context context) +{ + if (!flag_enable_cilk) + { + warning (0, "pragma simd ignored because -fcilkplus is not enabled"); + c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); + return false; + } + if (!flag_tree_vectorize) + { + warning (0, "pragma simd is useless without -ftree-vectorize"); + c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); + return false; + } + if (context == pragma_external) + { + c_parser_error (parser,"pragma simd must be inside a function"); + return false; + } + return true; +} + /* Handle pragmas. Some OpenMP pragmas are associated with, and therefore should be considered, statements. ALLOW_STMT is true if we're within the context of a function and such pragmas are to be allowed. Returns @@ -9364,6 +9373,7 @@ c_parser_cilk_grainsize (c_parser *parser) static bool c_parser_pragma (c_parser *parser, enum pragma_context context) { + location_t loc = c_parser_peek_token (parser)->location; unsigned int id; id = c_parser_peek_token (parser)->pragma_kind; @@ -9420,7 +9430,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) return false; case PRAGMA_OMP_SECTION: - error_at (c_parser_peek_token (parser)->location, + error_at (loc, "%<#pragma omp section%> may only be used in " "%<#pragma omp sections%> construct"); c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); @@ -9432,165 +9442,66 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) return false; case PRAGMA_CILK_GRAINSIZE: - if (context == pragma_external) - { - c_parser_error (parser,"pragma grainsize must be inside a function"); - return false; - } - if (flag_enable_cilk) - c_parser_cilk_grainsize (parser); - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + cilkplus_local_simd_values.loc = loc; + c_parser_cilk_grainsize (parser); return false; - break; case PRAGMA_SIMD_ASSERT: - flag_tree_vectorize = 1; - - if (context == pragma_external) - { - c_parser_error (parser, - "pragma simd assert must be inside a function"); - return false; - } - if (flag_enable_cilk) - { - c_parser_consume_pragma (parser); - c_parser_simd_assert (parser, true); - } - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + cilkplus_local_simd_values.loc = loc; + c_parser_consume_pragma (parser); + c_parser_simd_assert (parser, true); return false; case PRAGMA_SIMD_NOASSERT: - flag_tree_vectorize = 1; - if (context == pragma_external) - { - c_parser_error (parser, - "pragma simd assert should be inside a function"); - return false; - } - if (flag_enable_cilk) - { - c_parser_consume_pragma (parser); - c_parser_simd_assert (parser, false); - } - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + cilkplus_local_simd_values.loc = loc; + c_parser_consume_pragma (parser); + c_parser_simd_assert (parser, false); return false; case PRAGMA_SIMD_VECTORLENGTH: - flag_tree_vectorize = 1; - - if (context == pragma_external) - { - c_parser_error (parser, - "pragma simd assert should be inside a function"); - return false; - } - if (flag_enable_cilk) - { - c_parser_consume_pragma (parser); - c_parser_simd_vectorlength (parser); - } - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + cilkplus_local_simd_values.loc = loc; + c_parser_consume_pragma (parser); + c_parser_simd_vectorlength (parser); return false; case PRAGMA_SIMD_PRIVATE: - flag_tree_vectorize = 1; - - if (context == pragma_external) - { - c_parser_error (parser, - "pragma simd assert should be inside a function"); - return false; - } - if (flag_enable_cilk) - { - c_parser_consume_pragma (parser); - c_parser_simd_private (parser); - } - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } - - return false; + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + cilkplus_local_simd_values.loc = loc; + c_parser_consume_pragma (parser); + c_parser_simd_private (parser); + return false; case PRAGMA_SIMD_LINEAR: - - flag_tree_vectorize = 1; - if (context == pragma_external) - { - c_parser_error (parser, - "pragma simd assert should be inside a function"); - return false; - } - if (flag_enable_cilk) - { - c_parser_consume_pragma (parser); - c_parser_simd_linear (parser); - } - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + cilkplus_local_simd_values.loc = loc; + c_parser_consume_pragma (parser); + c_parser_simd_linear (parser); return false; case PRAGMA_SIMD_REDUCTION: - - flag_tree_vectorize = 1; - if (context == pragma_external) - { - c_parser_error (parser, - "pragma simd assert should be inside a function"); - return false; - } - if (flag_enable_cilk) - { - c_parser_consume_pragma (parser); - c_parser_simd_reduction (parser); - } - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + cilkplus_local_simd_values.loc = loc; + c_parser_consume_pragma (parser); + c_parser_simd_reduction (parser); return false; case PRAGMA_SIMD_EMPTY: - flag_tree_vectorize = 1; - optimize = 2; - if (context == pragma_external) - { - c_parser_error (parser, "pragma simd should be inside a function"); - return false; - } - if (flag_enable_cilk) - { - c_parser_consume_pragma (parser); - c_parser_simd_assert (parser, false); - } - else - { - warning (0, "pragma grainsize ignored"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); - } + if (!c_parser_pragma_simd_ok_p (parser, context)) + return false; + c_parser_consume_pragma (parser); + c_parser_simd_assert (parser, false); + cilkplus_local_simd_values.loc = loc; return false; default: diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 5c7e6cc..e74fd29 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -9115,15 +9115,7 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body, psv_head_insert (*cilkplus_ps_values); else LABEL_EXPR_PRAGMA_SIMD_INDEX (top) = INVALID_PRAGMA_SIMD_SLOT; - - /* Now we initialize them all to zeros. */ - cilkplus_ps_values->pragma_encountered = false; - cilkplus_ps_values->types = P_SIMD_NOASSERT; - cilkplus_ps_values->vectorlength = NULL_TREE; - cilkplus_ps_values->private_vars = NULL_TREE; - cilkplus_ps_values->linear_vars = NULL_TREE; - cilkplus_ps_values->linear_steps = NULL_TREE; - cilkplus_ps_values->reduction_vals = NULL; + memset (&cilkplus_ps_values, 0, sizeof (cilkplus_ps_values)); } add_stmt (top); diff --git a/gcc/gimple.c b/gcc/gimple.c index 7516b46..83288df 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -574,7 +574,8 @@ gimple gimple_build_label (tree label) { gimple p = gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, 1); - GIMPLE_PRAGMA_SIMD_INDEX (p) = PRAGMA_SIMD_INDEX (label); + if (flag_enable_cilk) + GIMPLE_PRAGMA_SIMD_INDEX (p) = PRAGMA_SIMD_INDEX (label); gimple_label_set_label (p, label); return p; } @@ -2028,7 +2029,8 @@ gimple_set_bb (gimple stmt, basic_block bb) { stmt->gsbase.bb = bb; - if ( (bb != NULL) && (gimple_code (stmt) == GIMPLE_LABEL)) + if (flag_enable_cilk + && bb && (gimple_code (stmt) == GIMPLE_LABEL)) bb->pragma_simd_index = GIMPLE_PRAGMA_SIMD_INDEX (stmt); /* If the statement is a label, add the label to block-to-labels map diff --git a/gcc/pragma_simd.c b/gcc/pragma_simd.c index c39fd62..7381060 100644 --- a/gcc/pragma_simd.c +++ b/gcc/pragma_simd.c @@ -42,12 +42,65 @@ along with GCC; see the file COPYING3. If not see struct pragma_simd_values *psv_head; -/* This function Empties the pragma simd data structure. */ +/* Verify that the <#pragma simd> clauses have been properly resolved. + INDEX is the pragma_simd_index into the global table. */ + +void +pragma_simd_verify_clauses (int index) +{ + struct pragma_simd_values *vals = psv_find_node (index); + location_t loc = vals ? vals->loc : UNKNOWN_LOCATION; + + if ((!clause_resolved_p (P_SIMD_VECTORLENGTH, index))) + { + if (pragma_simd_assert_requested_p (index)) + { + error_at (loc, "vectorlength in pragma simd not picked from list"); + exit (ICE_EXIT_CODE); + } + else + warning_at (0, loc, + "vectorlength in pragma simd not picked from list"); + } + if (!clause_resolved_p (P_SIMD_PRIVATE, index)) + { + if (pragma_simd_assert_requested_p (index)) + { + error_at (loc, "unable to make all variables private"); + exit (ICE_EXIT_CODE); + } + else + warning_at (0, loc, + "unable to make all variables private in pragma simd"); + } + if (!clause_resolved_p (P_SIMD_LINEAR, index)) + { + if (pragma_simd_assert_requested_p (index)) + { + error_at (loc, "unable to pick requested step-size in pragma simd"); + exit (ICE_EXIT_CODE); + } + else + warning (loc, "unable to pick requested step-size in pragma simd"); + } + if (!clause_resolved_p (P_SIMD_REDUCTION, index)) + { + if (pragma_simd_assert_requested_p (index)) + { + error_at (loc, "unable to satisfy all reductions in pragma simd"); + exit (ICE_EXIT_CODE); + } + else + warning_at (0, loc, "unable to satisfy all reductions in pragma simd"); + } +} + +/* Clear the pragma simd data structure. */ + void clear_pragma_simd_list (void) { psv_head = NULL; - return; } /* this function will check and see if a certain clause is resolved @@ -104,6 +157,7 @@ set_OK_for_certain_clause (enum pragma_simd_kind clause_type, bool set_value, if (!psv_head) return; + // FIXME: Why not use psv_find_node? for (ps_iter = psv_head; ps_iter != NULL; ps_iter = ps_iter->ptr_next) { if (ps_iter->pragma_encountered && (ps_iter->index == pragma_simd_index)) @@ -155,9 +209,10 @@ all_reductions_satisfied_p (int pragma_simd_index) } return true; } - -/* This function will search the pragma simd list to see if a node for a - certain loop exist (based on an index). */ + +// FIXME: We should really rewrite all this psv* business to use vectors. +/* Given an index into the pragma simd list (PSV_INDEX), find its + entry and return it. */ struct pragma_simd_values * psv_find_node (int psv_index) @@ -171,17 +226,15 @@ psv_find_node (int psv_index) return NULL; for (ps_iter = psv_head; ps_iter != NULL; ps_iter = ps_iter->ptr_next) - { - if ((ps_iter->index == psv_index) && ps_iter->pragma_encountered) - return ps_iter; - } + if ((ps_iter->index == psv_index) && ps_iter->pragma_encountered) + return ps_iter; - /* We should not get here. */ + gcc_unreachable (); return NULL; } -/* this function will insert a value at the head of the list that holds - pragma simd information for the loops. */ +/* Insert LOCAL_SIMD_VALUES into the global pragma simd table. Return + the index into the table for the new entry. */ int psv_head_insert (struct pragma_simd_values local_simd_values) @@ -194,13 +247,9 @@ psv_head_insert (struct pragma_simd_values local_simd_values) if (psv_head == NULL) { psv_head = (struct pragma_simd_values *) - xmalloc (sizeof (struct pragma_simd_values)); - gcc_assert (psv_head != NULL); + xcalloc (1, sizeof (struct pragma_simd_values)); + psv_head->loc = local_simd_values.loc; psv_head->pragma_encountered = local_simd_values.pragma_encountered; - /* We keep the head pointer index to be invalid pragma simd slot + 1. - * This is done before fi we want to debug then we can set invalid pragma - * simd_slot value to some arbitary number and then see if we are - * catching the pragmas correctly. */ psv_head->index = INVALID_PRAGMA_SIMD_SLOT + 1; psv_head->types = local_simd_values.types; @@ -244,15 +293,15 @@ psv_head_insert (struct pragma_simd_values local_simd_values) for (ps_iter = psv_head; ps_iter->ptr_next != NULL; ps_iter = ps_iter->ptr_next) - { - ; - } + ; ps_iter->ptr_next = (struct pragma_simd_values *) - xmalloc (sizeof (struct pragma_simd_values)); - gcc_assert (ps_iter->ptr_next != NULL); - + xcalloc (1, sizeof (struct pragma_simd_values)); + + // FIXME: There are a bunch of fields not initialized here: + // i.e. vlength_OK, pvars_OK, linear_steps_size ps_iter->ptr_next->pragma_encountered = local_simd_values.pragma_encountered; + ps_iter->ptr_next->loc = local_simd_values.loc; ps_iter->ptr_next->index = ps_iter->index + 1; ps_iter->ptr_next->types = local_simd_values.types; ps_iter->ptr_next->vectorlength = local_simd_values.vectorlength; @@ -282,6 +331,7 @@ pragma_simd_assert_requested_p (int ps_index) if (ps_index == 0) return 0; + // FIXME: Why not use psv_find_node. for (ps_iter = psv_head; ps_iter; ps_iter = ps_iter->ptr_next) { if ((ps_iter->pragma_encountered == true) && (ps_iter->index == ps_index)) @@ -322,7 +372,8 @@ pragma_simd_acceptable_vlength_p (int ps_index, possible_vector_length = possible_vectorization_factor; vl_tree = build_int_cst (integer_type_node, possible_vector_length); - + + // FIXME: Why not use psv_find_node? for (ps_iter = psv_head; ps_iter != NULL; ps_iter = ps_iter->ptr_next) { if ((ps_iter->pragma_encountered == true) && (ps_iter->index == ps_index)) @@ -359,6 +410,7 @@ pragma_simd_vectorize_loop_p (int ps_index) if (ps_index <= INVALID_PRAGMA_SIMD_SLOT) return false; + // FIXME: Why not use psv_find_node? for (ps_iter = psv_head; ps_iter != NULL; ps_iter = ps_iter->ptr_next) if (ps_iter->index == ps_index) return ps_iter->pragma_encountered; @@ -564,6 +616,7 @@ check_off_reduction_var (gimple reduc_stmt, int pragma_simd_index) } + // FIXME: Why not use psv_find_node? for (ps_iter = psv_head; ps_iter != NULL; ps_iter = ps_iter->ptr_next) if (ps_iter->pragma_encountered && (ps_iter->index == pragma_simd_index)) break; diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/compile/cilkplus_keywords_c_compile.exp b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/compile/cilkplus_keywords_c_compile.exp new file mode 100644 index 0000000..e666e8f --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/compile/cilkplus_keywords_c_compile.exp @@ -0,0 +1,37 @@ +# Copyright (C) 2011-2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# Written by Balaji V. Iyer + +if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { + return +} + + +load_lib gcc-dg.exp + +dg-init +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O0" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O1" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O2" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O3" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O0 -g" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O1 -g" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O2 -g" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.c]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O3 -g" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/array_notation_tests/*.c]] " -O3 -ftree-vectorize -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/elem_fn_tests/*.c]] " -O3 -ftree-vectorize -fcilkplus" " " +dg-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/compile/compile.exp b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/compile/compile.exp deleted file mode 100644 index 6302f76..0000000 --- a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/compile/compile.exp +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (C) 2011-2013 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# . - -# Written by Balaji V. Iyer - -if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { - return -} - - -load_lib gcc-dg.exp - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O0" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O1" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O2" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O3" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O0 -g" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O1 -g" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O2 -g" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cilk_keywords_test/compile/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O3 -g" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/array_notation_tests/*.c]] " -O3 -ftree-vectorize -fcilkplus" " " - -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/elem_fn_tests/*.c]] " -O3 -ftree-vectorize -fcilkplus" " " - -dg-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/cilkplus_keywords_c_errors.exp b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/cilkplus_keywords_c_errors.exp new file mode 100644 index 0000000..23a1c0a --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/cilkplus_keywords_c_errors.exp @@ -0,0 +1,37 @@ +# Copyright (C) 2012-2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# Written by Balaji V. Iyer + +if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { + return +} + + +load_lib gcc-dg.exp + +set CILKPLUS_COMPILE_FLAGS "-ftree-vectorize -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus" + +dg-init +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O0" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O1" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O2" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O3" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O0 -g" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O1 -g" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O2 -g" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " $CILKPLUS_COMPILE_FLAGS -O3 -g" " " +dg-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/errors.exp b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/errors.exp deleted file mode 100644 index 39cf1df..0000000 --- a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/errors.exp +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2012-2013 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# . - -# Written by Balaji V. Iyer - -if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { - return -} - - -load_lib gcc-dg.exp - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O0" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O1" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O2" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O3" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O0 -g" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O1 -g" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O2 -g" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl -lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 -fcilkplus -O3 -g" " " -dg-finish - -dg-finish - diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/execute/cilkplus_keywords_c_execute.exp b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/execute/cilkplus_keywords_c_execute.exp new file mode 100644 index 0000000..c9f2f43 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/execute/cilkplus_keywords_c_execute.exp @@ -0,0 +1,71 @@ +# Copyright (C) 2012-2013 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# This file was written by Balaji V. Iyer +# Many thanks to the GCC C-torture contributors. + +if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { + return +} + +verbose "$tool $libdir" 1 + +set library_var [get_multilibs] +dg-init +set ld_library_path "${library_var}/libcilkrts/.libs" +set CILK_TORTURE_OPTIONS [list \ + { -O0 -fcilkplus -lcilkrts -std=c99} \ + { -O1 -fcilkplus -lcilkrts -std=c99} \ + { -O2 -fcilkplus -lcilkrts -std=c99} \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99} \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 } \ + { -O3 -g -fcilkplus -lcilkrts -std=c99} \ + { -Os -fcilkplus -lcilkrts -std=c99} \ + { -O0 -fcilkplus -lcilkrts -std=c99 -flto} \ + { -O1 -fcilkplus -lcilkrts -std=c99 -flto} \ + { -O2 -fcilkplus -lcilkrts -std=c99 -flto} \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99 -flto } \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 -flto} \ + { -O3 -g -fcilkplus -lcilkrts -std=c99 -flto} \ + { -Os -fcilkplus -lcilkrts -std=c99 -flto} ] + + +if $tracelevel then { + strace $tracelevel +} + +# load support procs +load_lib torture-options.exp +load_lib c-torture.exp + +torture-init +set-torture-options $CILK_TORTURE_OPTIONS {{}} $CILK_TORTURE_OPTIONS + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + c-torture-execute $src +} + +torture-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/execute/execute.exp b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/execute/execute.exp deleted file mode 100644 index c9f2f43..0000000 --- a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/execute/execute.exp +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright (C) 2012-2013 -# Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# . - -# This file was written by Balaji V. Iyer -# Many thanks to the GCC C-torture contributors. - -if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { - return -} - -verbose "$tool $libdir" 1 - -set library_var [get_multilibs] -dg-init -set ld_library_path "${library_var}/libcilkrts/.libs" -set CILK_TORTURE_OPTIONS [list \ - { -O0 -fcilkplus -lcilkrts -std=c99} \ - { -O1 -fcilkplus -lcilkrts -std=c99} \ - { -O2 -fcilkplus -lcilkrts -std=c99} \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99} \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 } \ - { -O3 -g -fcilkplus -lcilkrts -std=c99} \ - { -Os -fcilkplus -lcilkrts -std=c99} \ - { -O0 -fcilkplus -lcilkrts -std=c99 -flto} \ - { -O1 -fcilkplus -lcilkrts -std=c99 -flto} \ - { -O2 -fcilkplus -lcilkrts -std=c99 -flto} \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99 -flto } \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 -flto} \ - { -O3 -g -fcilkplus -lcilkrts -std=c99 -flto} \ - { -Os -fcilkplus -lcilkrts -std=c99 -flto} ] - - -if $tracelevel then { - strace $tracelevel -} - -# load support procs -load_lib torture-options.exp -load_lib c-torture.exp - -torture-init -set-torture-options $CILK_TORTURE_OPTIONS {{}} $CILK_TORTURE_OPTIONS - -# -# main test loop -# - -foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { - # If we're only testing specific files and this isn't one of them, skip it. - if ![runtest_file_p $runtests $src] then { - continue - } - - c-torture-execute $src -} - -torture-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/assert1.c b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/assert1.c new file mode 100644 index 0000000..e1e011d --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/assert1.c @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-O3" } + +struct stuff { + char asdf; + float f; +}; + +void add_floats(struct stuff *a, struct stuff *b, int n) +{ + int i; +#pragma simd assert + for (i=0; i. + +# Written by Balaji V. Iyer + + +load_lib gcc-dg.exp + +dg-init +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O0 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O1 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O2 -ftree-vectorize -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O3 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O0 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O1 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O2 -ftree-vectorize -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O3 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/array_notation_tests/errors/*.c]] " -O3 -ftree-vectorize -fcilkplus -g" " " +dg-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/compile.exp b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/compile.exp deleted file mode 100644 index 400a033..0000000 --- a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/compile.exp +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (C) 2012-2013 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# . - -# Written by Balaji V. Iyer - - -load_lib gcc-dg.exp - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O0 -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O1 -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O2 -ftree-vectorize -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -O3 -fcilkplus" " " -dg-finish - - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O0 -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O1 -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O2 -ftree-vectorize -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] " -g -O3 -fcilkplus" " " -dg-finish - -dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/array_notation_tests/errors/*.c]] " -O3 -ftree-vectorize -fcilkplus -g" " " -dg-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/addf.c b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/addf.c new file mode 100644 index 0000000..7559401 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/addf.c @@ -0,0 +1,24 @@ +float a[5]; +float b[5] = {1.0F, 2.0F, 3.0F, 4.0F, 5.0F }; +float c[5] = {2.0F, 2.0F, 2.0F, 2.0F, 2.0F }; +float result[5] = {3.0F, 4.0F, 5.0F, 6.0F, 7.0F }; + +void addf(float *a, float *b, float *c, int n) +{ + int i; +#pragma simd + for (i=0; i. + +# This file was written by Balaji V. Iyer +# Many thanks to the GCC C-torture contributors. + +verbose "$tool $libdir" 1 + +set library_var [get_multilibs] +#dg-init +set CILK_TORTURE_OPTIONS [list \ + { -O0 -fcilkplus -lcilkrts -std=c99} \ + { -O1 -fcilkplus -lcilkrts -std=c99} \ + { -O2 -fcilkplus -lcilkrts -std=c99} \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99} \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 } \ + { -O3 -g -fcilkplus -lcilkrts -std=c99} \ + { -Os -fcilkplus -lcilkrts -std=c99} \ + { -O0 -fcilkplus -lcilkrts -std=c99 -flto} \ + { -O1 -fcilkplus -lcilkrts -std=c99 -flto} \ + { -O2 -fcilkplus -lcilkrts -std=c99 -flto} \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99 -flto } \ + { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 -flto} \ + { -O3 -g -fcilkplus -lcilkrts -std=c99 -flto} \ + { -Os -fcilkplus -lcilkrts -std=c99 -flto} ] + + +if $tracelevel then { + strace $tracelevel +} + +# load support procs +load_lib torture-options.exp +load_lib c-torture.exp + +torture-init +set-torture-options $CILK_TORTURE_OPTIONS {{}} $CILK_TORTURE_OPTIONS + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + c-torture-execute $src +} + +torture-finish diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/execute.exp b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/execute.exp deleted file mode 100644 index 99c5bc0..0000000 --- a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/execute.exp +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (C) 2012-2013 -# Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# . - -# This file was written by Balaji V. Iyer -# Many thanks to the GCC C-torture contributors. - -verbose "$tool $libdir" 1 - -set library_var [get_multilibs] -dg-init -set CILK_TORTURE_OPTIONS [list \ - { -O0 -fcilkplus -lcilkrts -std=c99} \ - { -O1 -fcilkplus -lcilkrts -std=c99} \ - { -O2 -fcilkplus -lcilkrts -std=c99} \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99} \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 } \ - { -O3 -g -fcilkplus -lcilkrts -std=c99} \ - { -Os -fcilkplus -lcilkrts -std=c99} \ - { -O0 -fcilkplus -lcilkrts -std=c99 -flto} \ - { -O1 -fcilkplus -lcilkrts -std=c99 -flto} \ - { -O2 -fcilkplus -lcilkrts -std=c99 -flto} \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-loops -std=c99 -flto } \ - { -O3 -fcilkplus -lcilkrts -fomit-frame-pointer -funroll-all-loops -finline-functions -std=c99 -flto} \ - { -O3 -g -fcilkplus -lcilkrts -std=c99 -flto} \ - { -Os -fcilkplus -lcilkrts -std=c99 -flto} ] - - -if $tracelevel then { - strace $tracelevel -} - -# load support procs -load_lib torture-options.exp -load_lib c-torture.exp - -torture-init -set-torture-options $CILK_TORTURE_OPTIONS {{}} $CILK_TORTURE_OPTIONS - -# -# main test loop -# - -foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { - # If we're only testing specific files and this isn't one of them, skip it. - if ![runtest_file_p $runtests $src] then { - continue - } - - c-torture-execute $src -} - -torture-finish diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 8fffffb..03f3e05 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -130,65 +130,12 @@ vectorize_loops (void) vect_location = UNKNOWN_LOC; - FOR_EACH_LOOP (li, loop, 0) + if (flag_enable_cilk) { - if (flag_enable_cilk) - { - if ((!clause_resolved_p (P_SIMD_VECTORLENGTH, - loop->pragma_simd_index))) - { - if (pragma_simd_assert_requested_p (loop->pragma_simd_index)) - { - error ("Vectorlength not picked from the list." - " ASSERT REQUESTED"); - exit (ICE_EXIT_CODE); - } - else - { - warning (0, "Vectorlength not picked from list."); - } - } - if (!clause_resolved_p (P_SIMD_PRIVATE, loop->pragma_simd_index)) - { - if (pragma_simd_assert_requested_p (loop->pragma_simd_index)) - { - error ("Unable to make all variables private. " - "ASSERT REQUESTED"); - exit(ICE_EXIT_CODE); - } - else - { - warning (0, "Unable to make all variables private."); - } - } - if (!clause_resolved_p (P_SIMD_LINEAR, loop->pragma_simd_index)) - { - if (pragma_simd_assert_requested_p (loop->pragma_simd_index)) - { - error ("Unable to pick requested step-size. " - "ASSERT REQUESTED"); - exit(ICE_EXIT_CODE); - } - else - { - warning (0, "Unable to pick requested step-size."); - } - } - if (!clause_resolved_p (P_SIMD_REDUCTION, loop->pragma_simd_index)) - { - if (pragma_simd_assert_requested_p (loop->pragma_simd_index)) - { - error ("Unable to satisfy all reductions.\nASSERT REQUESTED"); - exit(ICE_EXIT_CODE); - } - else - { - warning (0, "Unable to satisfy all reductions...continuing"); - } - } - } + FOR_EACH_LOOP (li, loop, 0) + pragma_simd_verify_clauses (loop->pragma_simd_index); } - + statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops); if (dump_enabled_p () || (num_vectorized_loops > 0 && dump_enabled_p ())) diff --git a/gcc/tree.h b/gcc/tree.h index cf6a135..dd4de3e 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -65,12 +65,22 @@ struct reduction_values struct reduction_values *ptr_next; }; -/* Since we can have multiple pragma simd, this will hold the values of - each of the pragma simd and then as soon as it finds a for loop - it will transfer those values into the loop tree structure. */ +/* Since we can have multiple pragma simds, this holds the values of + each of the pragma simds as we are parsing them. An index into + this table gets propagated to the tree structure for LABEL_DECL's + (as for loops are being parsed), then to the gimple structure for + GIMPLE_LABEL's, then to the BB structure, and finally to the loop + structure. */ struct pragma_simd_values { int index; + + /* Location of the #pragma itself. Ideally, we should keep the + location for each clause so we can give more detailed + diagnostics, but this will work for now. */ + location_t loc; + + // FIXME: All these need to be commented. bool pragma_encountered; unsigned int types; tree vectorlength; @@ -93,6 +103,8 @@ struct pragma_simd_values struct pragma_simd_values *ptr_next; }; +// FIXME: This should not be globally visible. Instead we should have +// accessor functions, with a more meaningful name. extern struct pragma_simd_values *psv_head; @@ -3113,15 +3125,13 @@ struct GTY(()) tree_field_decl { #define EH_LANDING_PAD_NR(NODE) \ (LABEL_DECL_CHECK (NODE)->label_decl.eh_landing_pad_nr) - +/* In a LABEL_DECL, the index into the pragma simd table. */ #define PRAGMA_SIMD_INDEX(NODE) \ - (LABEL_DECL_CHECK(NODE)->label_decl.pragma_simd_index) + (LABEL_DECL_CHECK (NODE)->label_decl.pragma_simd_index) +/* As above, but for a LABEL_EXPR. */ #define LABEL_EXPR_PRAGMA_SIMD_INDEX(NODE) \ - (PRAGMA_SIMD_INDEX(TREE_OPERAND(LABEL_EXPR_CHECK(NODE), 0))) - - - + (PRAGMA_SIMD_INDEX (TREE_OPERAND (LABEL_EXPR_CHECK (NODE), 0))) /* In LABEL_DECL nodes, nonzero means that an error message about jumping into such a binding contour has been printed for this label. */ @@ -6623,14 +6633,9 @@ extern bool block_may_fallthru (const_tree); #define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK2 (NODE), 2) #define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK2 (NODE), 3) -/* Some cilk #defines */ -#define CILK_FOR_VAR(NODE) TREE_OPERAND (CILK_FOR_STMT_CHECK (NODE), 5) -#define CILK_FOR_INIT(NODE) TREE_OPERAND (CILK_FOR_STMT_CHECK (NODE), 0) -#define CILK_FOR_GRAIN(NODE) TREE_OPERAND (CILK_FOR_STMT_CHECK (NODE), 6) - -/* Here are the pragma simd specific files used by the parser and vectorizer - available in pragma_simd.c. */ +/* Cilk Plus supporting functions in pragma_simd.c. */ +extern void pragma_simd_verify_clauses (int); extern struct pragma_simd_values *psv_find_node (int psv_index); extern int psv_head_insert (struct pragma_simd_values local_simd_values); extern bool pragma_simd_acceptable_vlength_p (int ps_index, @@ -6651,6 +6656,10 @@ extern void set_OK_for_certain_clause (enum pragma_simd_kind clause_type, int pragma_simd_index); extern HOST_WIDE_INT find_linear_step_size (int pragma_simd_index, tree var); +#define CILK_FOR_VAR(NODE) TREE_OPERAND (CILK_FOR_STMT_CHECK (NODE), 5) +#define CILK_FOR_INIT(NODE) TREE_OPERAND (CILK_FOR_STMT_CHECK (NODE), 0) +#define CILK_FOR_GRAIN(NODE) TREE_OPERAND (CILK_FOR_STMT_CHECK (NODE), 6) + tree build_call_list (tree return_type, tree fn, tree arglist); bool is_elem_fn (tree); void elem_fn_create_fn (tree);