Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TMPDIR variable (fixes #1) #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include "logging.h"
#include "string.h"

int unsafe_val=0;
FILE *unsafe_fptr;
Expand Down Expand Up @@ -83,8 +84,13 @@ void armpl_logging_leave(armpl_logging_struct *logger)

if (firsttime==1)
{
char fname[32];
sprintf(fname, "/tmp/armpllog_%.5d.apl", armpl_get_value_int());
const char* tmpdir = getenv("TMPDIR");
if (!tmpdir)
{
tmpdir = "/tmp";
}
char *fname = calloc(strlen(tmpdir)+strlen("/armpllog_NNNNN.apl")+1,sizeof(char));
sprintf(fname, "%s/armpllog_%.5d.apl", tmpdir, armpl_get_value_int());

fptr = armpl_open_logging_file(fname);
}
Expand Down
9 changes: 7 additions & 2 deletions src/summary.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ void armpl_summary_exit()
armpl_lnkdlst_t *thisEntry = listHead;
armpl_lnkdlst_t *nextEntry = listHead;
FILE *fptr;
char fname[64];
static int firsttime=0;

/* Generate a "unique" filename for the output */
sprintf(fname, "/tmp/armplsummary_%.5d.apl", armpl_get_value_int());
const char* tmpdir = getenv("TMPDIR");
if (!tmpdir)
{
tmpdir = "/tmp";
}
char *fname = calloc(strlen(tmpdir)+strlen("/armplsummary_NNNNN.apl")+1,sizeof(char));
sprintf(fname, "%s/armplsummary_%.5d.apl", tmpdir, armpl_get_value_int());
fptr = fopen(fname, "w");

while (NULL != listEntry)
Expand Down
6 changes: 3 additions & 3 deletions tools/process-blas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ BLAS1="rotg_ rotmg_ rot_ rotm_ swap_ scal_ copy_ axpy_ dot_ dotu_ dotc_ nrm2_ as
BLAS2="gemv_ gbmv_ hemv_ hbmv_ hpmv_ symv_ sbmv_ spmv_ trmv_ tbmv_ tpmv_ trsv_ tbsv_ tpsv_ ger_ geru_ gerc_ her_ hpr_ her2_ hpr2_ syr_ spr_ syr2_ spr2_"
BLAS3="gemm_ symm_ hemm_ syrk_ herk_ syr2k_ her2k_ trmm_ trsm_"


TMPFILE=/tmp/.inp-$USER
OUTFILE=/tmp/armpl.blas
: "${TMPDIR:=/tmp}"
TMPFILE=${TMPDIR}/.inp-$USER
OUTFILE=${TMPDIR}/armpl.blas

cat $* > $TMPFILE
rm -f $OUTFILE
Expand Down
10 changes: 8 additions & 2 deletions tools/process-dgemm.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,14 @@ int main(int argc, char** argv)
}

/* Open file for output */
char *outFname = calloc(strlen("/tmp/armpl.")+strlen(funcNames[funcNameID])+1,sizeof(char));
strcat(outFname,"/tmp/armpl.");
const char* tmpdir = getenv("TMPDIR");
if (!tmpdir)
{
tmpdir = "/tmp";
}
char *outFname = calloc(strlen(tmpdir)+strlen("/armpl.")+strlen(funcNames[funcNameID])+1,sizeof(char));
strcat(outFname,tmpdir);
strcat(outFname,"/armpl.");
strcat(outFname,funcNames[funcNameID]);
fptr = fopen(outFname, "w");
if (fptr == NULL) {
Expand Down
3 changes: 2 additions & 1 deletion tools/process-dgemm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ then
echo " $ gcc -o Process-dgemm process-dgemm.c"
fi

TMPFILE=/tmp/.inp-$USER
: "${TMPDIR:=/tmp}"
TMPFILE=${TMPDIR}/.inp-$USER

rm -f $TMPFILE
for file in $*
Expand Down
3 changes: 2 additions & 1 deletion tools/process_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ def process_components():
#####

if (len(blasNames[0])+len(blasNames[1])+len(blasNames[2])>0) :
fname = '/tmp/armpl.blas'
tmpdir = os.getenv('TMPDIR','/tmp')
fname = tmpdir + '/armpl.blas'
outputfile = open(fname, 'w')

types="sdcz"
Expand Down