#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>
#include <unistd.h>
Go to the source code of this file.
|
#define | MAX_COMM_NUM 1000 |
|
#define | ABC_PRT(a, t) (printf("%s = ", (a)), printf("%7.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))) |
|
#define ABC_PRT |
( |
|
a, |
|
|
|
t |
|
) |
| (printf("%s = ", (a)), printf("%7.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))) |
#define MAX_COMM_NUM 1000 |
CFile****************************************************************
FileName [starter.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Wrapper for calling ABC.]
Synopsis [A demo program illustrating parallel execution of ABC.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - October 22, 2009.]
Revision [
- Id:
- starter.c,v 1.00 2009/10/22 00:00:00 alanmi Exp
]
Definition at line 35 of file starter.c.
void* Abc_RunThread |
( |
void * |
Command | ) |
|
Function*************************************************************
Synopsis [This procedures executes one call to system().]
Description []
SideEffects []
SeeAlso []
Definition at line 60 of file starter.c.
63 if (
system( (
char *)Command ) )
66 fprintf( stderr,
"The following command has returned non-zero exit status:\n" );
67 fprintf( stderr,
"\"%s\"\n", (
char *)Command );
68 fprintf( stderr,
"Sorry for the inconvenience.\n" );
static int nThreadsRunning
char* Abc_UtilStrsav |
( |
char * |
s | ) |
|
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
GLOBAL VARIABLES ///.
Function*************************************************************
Synopsis [Takes file with commands to be executed and the number of CPUs.]
Description []
SideEffects []
SeeAlso []
Definition at line 97 of file starter.c.
99 FILE * pFile, * pOutput = stdout;
102 int i, nCPUs = 0, nLines = 0,
Counter;
103 clock_t clk = clock();
107 { fprintf( stderr,
"Wrong number of command line arguments.\n" );
goto usage; }
110 nCPUs = atoi( argv[1] );
112 { fprintf( pOutput,
"Cannot read an integer represting the number of CPUs.\n" );
goto usage; }
115 pFile = fopen( argv[2],
"r" );
117 { fprintf( pOutput,
"Input file \"%s\" cannot be opened.\n", argv[2] );
goto usage; }
124 if ( Buffer[0] ==
'\n' || Buffer[0] ==
'\r' || Buffer[0] ==
'\t' ||
125 Buffer[0] ==
' ' || Buffer[0] ==
'#')
130 if ( Buffer[
strlen(Buffer)-1] ==
'\n' )
131 Buffer[
strlen(Buffer)-1] = 0;
132 if ( Buffer[
strlen(Buffer)-1] ==
'\r' )
133 Buffer[
strlen(Buffer)-1] = 0;
149 printf(
"Calling: %s\n", (
char *)Buffer );
155 assert(pthread_create( &ThreadIds[nLines], NULL,
Abc_RunThread, (
void *)pBufferCopy ) == 0);
157 { fprintf( pOutput,
"Cannot execute more than %d commands from file \"%s\".\n", nLines, argv[2] );
break; }
174 printf(
"Finished processing commands in file \"%s\". ", argv[2] );
175 ABC_PRT(
"Total time", clock() - clk );
180 for ( i =
strlen(argv[0]) - 1; i > 0; i-- )
181 if ( argv[0][i-1] ==
'\\' || argv[0][i-1] ==
'/' )
184 fprintf( pOutput,
"usage: %s <num> <file>\n", argv[0]+i );
185 fprintf( pOutput,
" executes command listed in <file> in parallel on <num> CPUs\n" );
186 fprintf( pOutput,
"\n" );
static int nThreadsRunning
void * Abc_RunThread(void *Command)
char * Abc_UtilStrsav(char *s)
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER |