[Beignet] [PATCH] improve multithread calling of llvm
Zhigang Gong
zhigang.gong at linux.intel.com
Wed Nov 6 22:41:08 PST 2013
This patch seems introduce a regression. If you run all the utest, it may trigger
the following error:
pure virtual method called
terminate called without an active exception
then segfault. I'm using clang/llvm 3.3.
On Wed, Nov 06, 2013 at 08:09:43AM +0000, Yang, Rong R wrote:
> LGTM, thanks.
>
> -----Original Message-----
> From: beignet-bounces at lists.freedesktop.org [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Homer Hsing
> Sent: Tuesday, November 05, 2013 1:28 PM
> To: beignet at lists.freedesktop.org
> Subject: [Beignet] [PATCH] improve multithread calling of llvm
>
> call llvm multithread function instead of using a semaphore.
> also exit llvm multithread mode at the end of life.
>
> Signed-off-by: Homer Hsing <homer.xing at intel.com>
> ---
> backend/src/backend/gen_program.cpp | 7 -------
> backend/src/backend/gen_program.h | 2 --
> backend/src/backend/program.cpp | 11 ++++++++---
> 3 files changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
> index 781152d..40ab176 100644
> --- a/backend/src/backend/gen_program.cpp
> +++ b/backend/src/backend/gen_program.cpp
> @@ -159,10 +159,3 @@ void genSetupCallBacks(void)
> gbe_program_new_from_binary = gbe::genProgramNewFromBinary;
> gbe_program_new_from_llvm = gbe::genProgramNewFromLLVM; }
> -
> -sem_t llvm_semaphore;
> -
> -void genSetupLLVMSemaphore(void)
> -{
> - sem_init(&llvm_semaphore, 0, 1);
> -}
> diff --git a/backend/src/backend/gen_program.h b/backend/src/backend/gen_program.h
> index a498a5d..8d37a70 100644
> --- a/backend/src/backend/gen_program.h
> +++ b/backend/src/backend/gen_program.h
> @@ -33,8 +33,6 @@
>
> /*! This will make the compiler output Gen ISA code */ extern void genSetupCallBacks(void); -extern sem_t llvm_semaphore; -extern void genSetupLLVMSemaphore(void);
>
> #endif /* __GBE_GEN_PROGRAM_H__ */
>
> diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp index 937f95b..281b0b8 100644
> --- a/backend/src/backend/program.cpp
> +++ b/backend/src/backend/program.cpp
> @@ -32,6 +32,8 @@
> #include "ir/unit.hpp"
> #include "llvm/llvm_to_gen.hpp"
> #include "llvm/Config/config.h"
> +#include "llvm/Support/Threading.h"
> +#include "llvm/Support/ManagedStatic.h"
> #include <cstring>
> #include <algorithm>
> #include <fstream>
> @@ -557,9 +559,7 @@ namespace gbe {
>
> // Create an action and make the compiler instance carry it out
> llvm::OwningPtr<clang::CodeGenAction> Act(new clang::EmitLLVMOnlyAction());
> - sem_wait(&llvm_semaphore);
> auto retVal = Clang.ExecuteAction(*Act);
> - sem_post(&llvm_semaphore);
> if (!retVal)
> return;
>
> @@ -854,7 +854,12 @@ namespace gbe
> gbe_get_image_base_index = gbe::getImageBaseIndex;
> gbe_set_image_base_index = gbe::setImageBaseIndex;
> genSetupCallBacks();
> - genSetupLLVMSemaphore();
> + llvm::llvm_start_multithreaded();
> + }
> +
> + ~CallBackInitializer() {
> + llvm::llvm_stop_multithreaded();
> + llvm::llvm_shutdown();
> }
> };
>
> --
> 1.8.3.2
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list