Commit 1a240acd authored by cianciosa's avatar cianciosa
Browse files

Fix bug where current cpu kernel library could be deleted by fork what until...

Fix bug where current cpu kernel library could be deleted by fork what until the file is deleted before ending the destuctor.
parent 643ec38b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -113,10 +113,17 @@ namespace gpu {
            dlclose(lib_handle);

            if (!library_name.empty()) {
                if (fork() == 0) {
//  A new instance of the class can be created before the library is deleted.
//  Wait for the fork to finish before the destructor exits. This could cause a
//  problem where the new library gets deleted before the context tries to load
//  it.
                auto pid = fork();
                if (pid == 0) {
                    execlp("rm", "rm", library_name.c_str(), NULL);
                    exit(0);
                }
                int error = 0;
                waitpid(pid, &error, 0);
            }
        }

+3 −2
Original line number Diff line number Diff line
@@ -88,8 +88,9 @@ namespace dispersion {
        virtual graph::shared_leaf<T, SAFE_MATH>
        Z(graph::shared_leaf<T, SAFE_MATH> zeta) {
            auto i = graph::i<T, SAFE_MATH> ();
            return graph::none<T, SAFE_MATH> ()*graph::sqrt(graph::pi<T, SAFE_MATH> ())/graph::exp(zeta*zeta) *
                   (graph::erfi(zeta) - i);
            auto none = graph::none<T, SAFE_MATH> ();
            auto nsqpi = none*graph::sqrt(graph::pi<T, SAFE_MATH> ());
            return nsqpi*graph::exp(none*zeta*zeta)*(graph::erfi(zeta) - i);
        }
    };