Skip to content

Commit f8d5f56

Browse files
committed
GPU (Linux): remove possible overhead
1 parent 4d1c629 commit f8d5f56

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/common/io/io.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,25 @@ static inline bool ffPathExists(const char* path, FFPathType pathType)
101101

102102
#else
103103

104-
struct stat fileStat;
105-
if(stat(path, &fileStat) != 0)
106-
return false;
104+
if (pathType == FF_PATHTYPE_ANY)
105+
{
106+
// Zero overhead
107+
return access(path, F_OK) == 0;
108+
}
109+
else
110+
{
111+
struct stat fileStat;
112+
if(stat(path, &fileStat) != 0)
113+
return false;
107114

108-
unsigned int mode = fileStat.st_mode & S_IFMT;
115+
unsigned int mode = fileStat.st_mode & S_IFMT;
109116

110-
if(pathType & FF_PATHTYPE_FILE && mode != S_IFDIR)
111-
return true;
117+
if(pathType & FF_PATHTYPE_FILE && mode != S_IFDIR)
118+
return true;
112119

113-
if(pathType & FF_PATHTYPE_DIRECTORY && mode == S_IFDIR)
114-
return true;
120+
if(pathType & FF_PATHTYPE_DIRECTORY && mode == S_IFDIR)
121+
return true;
122+
}
115123

116124
#endif
117125

src/detection/gpu/gpu_linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu,
7878

7979
const uint32_t hwmonLen = pciDir->length;
8080
ffStrbufAppendS(pciDir, "in1_input"); // Northbridge voltage in millivolts (APUs only)
81-
if (ffPathExists(pciDir->chars, FF_PATHTYPE_FILE))
81+
if (ffPathExists(pciDir->chars, FF_PATHTYPE_ANY))
8282
gpu->type = FF_GPU_TYPE_INTEGRATED;
8383
else
8484
gpu->type = FF_GPU_TYPE_DISCRETE;

0 commit comments

Comments
 (0)