Skip to content

Commit

Permalink
nvcc working directory is moved to $PGDATA/.pgstrom_fatbin_build_XXXXXX
Browse files Browse the repository at this point in the history
issue #838, and #743.

This commit also changed exit code when GPU code build was failed, not
to restart GPU-service infinitely.
  • Loading branch information
kaigai committed Oct 17, 2024
1 parent a5cd194 commit dc101ba
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/gpu_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ __rebuild_gpu_fatbin_file(const char *fatbin_dir,
int count;
int status;

strcpy(workdir, "/tmp/.pgstrom_fatbin_build_XXXXXX");
strcpy(workdir, ".pgstrom_fatbin_build_XXXXXX");
if (!mkdtemp(workdir))
elog(ERROR, "unable to create work directory for fatbin rebuild");

Expand Down Expand Up @@ -866,6 +866,13 @@ __rebuild_gpu_fatbin_file(const char *fatbin_dir,
status = system(cmd.data);
if (status != 0)
elog(ERROR, "failed on shell command: %s", cmd.data);

/* cleanup working directory */
resetStringInfo(&cmd);
appendStringInfo(&cmd, "rm -rf '%s'", workdir);
status = system(cmd.data);
if (status != 0)
elog(ERROR, "failed on shell command: %s", cmd.data);
}

static void
Expand All @@ -883,8 +890,33 @@ gpuservSetupFatbin(void)
if (!__validate_gpu_fatbin_file(fatbin_dir,
fatbin_file))
{
__rebuild_gpu_fatbin_file(fatbin_dir,
fatbin_file);
MemoryContext curctx = CurrentMemoryContext;

PG_TRY();
{
__rebuild_gpu_fatbin_file(fatbin_dir,
fatbin_file);
}
PG_FINALLY();
{
MemoryContext oldcxt = MemoryContextSwitchTo(curctx);
ErrorData *edata = CopyErrorData();

if (edata->elevel >= ERROR)
{
elog(LOG, "[%s:%d] GPU code build error: %s",
edata->filename,
edata->lineno,
edata->message);
/*
* We shall not restart again, until source code
* problems are fixed.
*/
proc_exit(0);
}
MemoryContextSwitchTo(oldcxt);
}
PG_END_TRY();
}
}
path = alloca(strlen(fatbin_dir) +
Expand Down

0 comments on commit dc101ba

Please sign in to comment.