Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
17 changes: 15 additions & 2 deletions projects/hipfft/shared/concurrency.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,7 +19,9 @@
// THE SOFTWARE.

#pragma once

#ifdef _OPENMP
#include <omp.h>
Comment thread
evetsso marked this conversation as resolved.
#endif
#include <thread>

#ifndef _WIN32
Expand All @@ -35,7 +37,18 @@ static unsigned int rocfft_concurrency()
#ifndef _WIN32
cpu_set_t cpuset;
if(sched_getaffinity(0, sizeof(cpuset), &cpuset) == 0)
{
#ifdef _OPENMP
return std::min(CPU_COUNT(&cpuset), omp_get_max_threads());
#else
return CPU_COUNT(&cpuset);
#endif
}
#endif

#ifdef _OPENMP
return std::min<unsigned int>(std::thread::hardware_concurrency(), omp_get_max_threads());
#else
return std::thread::hardware_concurrency();
#endif
}
6 changes: 6 additions & 0 deletions projects/rocfft/library/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ include( GenerateExportHeader )

find_package (Python3 3.6 COMPONENTS Interpreter REQUIRED)

find_package(OpenMP)

add_subdirectory( device )

#
Expand Down Expand Up @@ -445,6 +447,10 @@ foreach( target rocfft rocfft_offline_tuner rocfft_solmap_convert rocfft_aot_hel
continue()
endif()

if(OpenMP_FOUND)
target_link_libraries( ${target} PRIVATE OpenMP::OpenMP_CXX )
endif()

# RTC uses dladdr to find the RTC helper program
if( NOT WIN32 )
target_link_libraries( ${target} PUBLIC -ldl pthread )
Expand Down
17 changes: 15 additions & 2 deletions projects/rocfft/shared/concurrency.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,7 +19,9 @@
// THE SOFTWARE.

#pragma once

#ifdef _OPENMP
#include <omp.h>
#endif
#include <thread>

#ifndef _WIN32
Expand All @@ -35,7 +37,18 @@ static unsigned int rocfft_concurrency()
#ifndef _WIN32
cpu_set_t cpuset;
if(sched_getaffinity(0, sizeof(cpuset), &cpuset) == 0)
{
#ifdef _OPENMP
return std::min(CPU_COUNT(&cpuset), omp_get_max_threads());
#else
return CPU_COUNT(&cpuset);
#endif
}
#endif

#ifdef _OPENMP
return std::min<unsigned int>(std::thread::hardware_concurrency(), omp_get_max_threads());
#else
return std::thread::hardware_concurrency();
#endif
}
Loading