From owner-freebsd-threads@FreeBSD.ORG Thu Apr 2 11:16:11 2009 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28DE5106564A for ; Thu, 2 Apr 2009 11:16:11 +0000 (UTC) (envelope-from fdeliege@gmail.com) Received: from mail-ew0-f171.google.com (mail-ew0-f171.google.com [209.85.219.171]) by mx1.freebsd.org (Postfix) with ESMTP id 874CC8FC14 for ; Thu, 2 Apr 2009 11:16:10 +0000 (UTC) (envelope-from fdeliege@gmail.com) Received: by ewy19 with SMTP id 19so452149ewy.43 for ; Thu, 02 Apr 2009 04:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=TRHNXB4mo7b1LBOl/cPzj7dFMFr3b/V0WdkJ4tkpeqI=; b=TSRx8SIRTlpdl5pqaLiEcp51jOZTcHdWip4vI6EgZsdTJ6iX99hJbZSMyVNoEGH2ly lIRYN8EjI9BF4YvNltqhexJYVX2ElTO22R3rDqRRo9jeK9RwJlJcCAg2RYJVO/e+vdPV nckuri00XaV8GcYRwmTgRWE6DKMcwEgp7tPUA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=CZFZ8GFFYuuGOINwqEooeTW9aaO5Nc1f2s82PSq93f1w0pFtSO2SkrCQ+NsznYkkjh d7kfJi7peaRVrRkp1/KDASL4JRy/kh7UF0Z2fAUjvxFjUGXwwTpYC++LVPz1hKJ5RXM0 hSyjNituHHYp7DFoxa2T8StxW/u+lVj0C8kGs= MIME-Version: 1.0 Received: by 10.210.16.10 with SMTP id 10mr6792948ebp.35.1238669156536; Thu, 02 Apr 2009 03:45:56 -0700 (PDT) Date: Thu, 2 Apr 2009 12:45:56 +0200 Message-ID: <92c2d900904020345x1541daefy85705fa049b54d8e@mail.gmail.com> From: =?ISO-8859-1?Q?Fran=E7ois_Deli=E8ge?= To: freebsd-threads@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: SPI openmp parallel critical X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2009 11:16:11 -0000 Hi list, I am writing a C user defined function that is loading values obtained from an SPI table and that has to perform some operation on each of these values. The values are binary and have a variable size. Since CPU is a bottleneck and since I have multiple cores, I would like the operations to be performed in parallel. Everything goes fine if I define as a critical segment the part where I get the data from tuptable. However, if I remove the critical section I get this error: ERROR: lock 53 is not held I don't always get the error, but it always crashes if I start to have a few values in the SPI table. I would like to eliminate that critical section. Any advice ? I guess someone else already ran in this kind of problem. :-) SPI_connect(); ret = SPI_execute(command, 1, 0); proc = SPI_processed; #pragma omp parallel for shared(proc, SPI_tuptable ) private( mydata, isnull) for (j = 0; j < proc; j++) { // returns datum from the first element #pragma omp critical // would like to eliminate this { mydata = (mydatatype *)PG_DETOAST_DATUM(SPI_getbinval(SPI_tuptable->vals[j], SPI_tuptable->tupdesc, 1, &isnull)); } ... // do something with mydata } SPI_finish(); Cheers, Francois