pthread mutex coexistence

pthread mutex coexistence

newport_j的头像

Can Cilk coexist with pthread code? I am referring to some legacy code that I have that that is full of mutex code?

I do not want to remove all of the mutex code that would be horrendous, but it seems to be having an effect whenI compile.

Newport_j

4 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Brandon Hewitt (Intel)的头像

It should. What effects are you seeing exactly?

Brandon Hewitt Technical Consulting Engineer Tools Knowledge Base: "http://software.intel.com/en-us/articles/tools" Software Product Support info: "http://www.intel.com/software/support"
newport_j的头像

This is the output that i get when I use cilk++ to complie my c source code. Please note that it compiled before using gcc, but now I get the output below.

In file included from /home/james/Desktop/cilk/bin/../lib/gcc/i686-pc-linux-gnu/4.2.4/../../../../include/c++/4.2.4/backward/complex.h:31,

from WEGtest.cilk:14:

/home/james/Desktop/cilk/bin/../lib/gcc/i686-pc-linux-gnu/4.2.4/../../../../include/c++/4.2.4/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.

In file included from WEGtest.cilk:23:

WAFmathBase.h:111: error: expected identifier before false

WAFmathBase.h:111: error: expected `}' before false

WAFmathBase.h:111: error: expected unqualified-id before false

WAFmathBase.h:111: error: expected declaration before } token

The source codefor WEgtest.cilk question is

WEGtest.cilk is

/*WEG test code

Created 2-4-04

updated 4-15-04

Phred*/

/*for range independent dottom depth on bottom targets to start,

and constant target depth, Phred*/

#include

#include

#include

#include

#include

#include

#include

#include

#include "thread.h"

#include "WAFmutex.h"

#include "SIMdefines.h"

#include "envstructdefs.h"

#include "WAFmathBase.h"

#include "WEGStrDefs.h"

#include "WEGFunDefs.h"

#include "WEGtest.h"

The complaint is for the line WAFmathbase.h. The source for WAFmathbase.h is;

#ifndef _WAFMATHBASE_H
#define _WAFMATHBASE_H
/*! \file WAFmathBase.h
\brief Include file for Base math stuff
\author Phred
*/

/*!\addtogroup LIB LIB*/
/*!@{*/
/*!\addtogroup WAFmath WAF math group*/
/*!@{*/
/*!\addtogroup Base Base math library*/
/*!@{*/

/*#define PI M_PI*/
/*#define TWOPI (2.0*M_PI)*/
/*#define HLFPI 1.5707963267948966192*/
/*#define PIO2 (M_PI/2.0)*/
#define SQRTPI (1.77245385090551511374)
#define SRT2PI 2.5066282746310005024

#define ONEDEG 1.7453292519943295769E-2
#define RAD ONEDEG
#define RADNDEG 57.295779513
#define DEG_TO_RAD (M_PI/180.0)
#define RAD_TO_DEG (1.0/DEG_TO_RAD)

#define SRTHLF 0.707106781186547524

#define SQRT2 (1.41421356237309504880)
#define ONE_OVR_SQRT2 (1.0/SQRT2)

#define LN10 2.302585092994045684

#define GAM23 1.354117939426400416
#define GAM13 2.678938534707747633

#define AIo (pow(3.0,(-2.0/3.0))/GAM23)
#define BIo (sqrt(3.0)*AIo)
#define dAIo (-pow(3.0,(-1.0/3.0))/GAM13)
#define dBIo (-sqrt(3.0)*dAIo)

#define SMALL (1.0e-10)
#define MINDOT SMALL

#define ONEMEG (0x100000)
#define ONEK (0x400)

#define GRAVITY (32.174)
#define KM 1000.0

#define KNOTS 0.5144

#define YDS_TO_FT (3.0)
#define FT_TO_YDS (1.0/YDS_TO_FT)
#define KTS_TO_FPS (1.68782)
#define FPS_TO_KTS (1.0/KTS_TO_FPS)
#define M_TO_FT (3.28084)
#define FT_TO_M (1.0/M_TO_FT)
#define YD_TO_M (0.9144)
#define M_TO_YD (1.0/YD_TO_M)
#define KTS_TO_MPS (0.5144)
#define MPS_TO_KTS (1.0/KTS_TO_MPS)
#define FT_PER_NMILE (6076.11549 )
#define METERS_PER_FT (.3048)
#define FT_PER_METER (1.0/METERS_PER_FT)

#define CMY M_TO_YD
#define CYM YD_TO_M
#define CRD RAD_TO_DEG
#define CDR DEG_TO_RAD

#define deg_to_rad(arg) (CDR*(arg)) /* Convert degrees to radians */
#define rad_to_deg(arg) (CRD*(arg)) /* Convert radians to degrees */
#define m_to_yds(arg) (CMY*(arg)) /* Convert meters to yards */
#define yds_to_m(arg) (CYM*(arg)) /* Convert yards to meters */

#define THRUST_RATIO (1.0)

#define FALSE 0
#define TRUE (!FALSE)

#define SIGN(x,y) ((y) < 0?-fabs(x):fabs(x))

#define amax(arg1,arg2) ((arg1) >= (arg2) ? (arg1) : (arg2))
#define amin(arg1,arg2) ((arg1) <= (arg2) ? (arg1) : (arg2))
#define square(arg) ((arg)*(arg))
#define cube(arg) ((arg)*(arg)*(arg))
#define sign(arg1,arg2) ((arg2) >= 0.0 ? fabs(arg1) : -fabs(arg1))
#define sinc(arg) ((arg) == 0.0 ? 1.0 : sin(arg) / (arg))

/*
Check arguments that should be 1.0 or -1.0 but differ due to numerical
precision and cause acos and asin function to return nan.
*/

#define CHECK_ARG_P1(arg) (((arg) > 1.0) && ((arg) < 1.000001)) ? 1.0 : (arg)
#define CHECK_ARG_M1(arg) (((arg) < -1.0) && ((arg) > -1.000001)) ? -1.0 : (arg)
#define CHECK_ARG_PM1(arg) (CHECK_ARG_P1(CHECK_ARG_M1(arg)))
#define ACOS(arg) (acos(CHECK_ARG_PM1(arg)))
#define ASIN(arg) (asin(CHECK_ARG_PM1(arg)))

#define dBtoNp log(10.0)/20.0

/*!\brief Logical enum*/
typedef enum logical {false,true} LOGICAL;

int Ratint(double xa[], double ya[], int n, double x, double *y, double *dy);

double Trapzd(double (*func)(double), double a, double b, int n);

double Romberg(double (*func)(double), double a, double b);

/*!@}*/
/*!@}*/
/*!@}*/
#endif

The line is question (line 111) is now shown separately:

typedef enum logical {false,true} LOGICAL;

I am not sure what is causng the errors, but I am getting them as you can see in the output.

Please remeber that if i take cilk_man and make it main and use gcc instead og cilk++, this compiles. What is the problem?

Newport_j

avidday的头像

When you compile C code with cilk++, it needs to conform to the C++ syntax and grammar. true and false are reserved words in C++, but not in C. That is where the error is coming from. Nothing to do with cilk or pthreads from what I can see.

登陆并发表评论。