Commit 529fa3cc authored by Cianciosa, Mark's avatar Cianciosa, Mark
Browse files

Move location of autorelease pools to main.

parent 4a6b2180
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ static base solution(const base t) {
///  @param[in] argv Array of commandline arguments.
//------------------------------------------------------------------------------
int main(int argc, const char * argv[]) {
    START_GPU

    //typedef std::complex<double> base;
    //typedef double base;
    typedef float base;
@@ -146,4 +148,6 @@ int main(int argc, const char * argv[]) {

    std::cout << std::endl << "Timing:" << std::endl;
    total.stop();

    END_GPU
}
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,14 @@
#define GPU_CONTEXT gpu::hip_context
#endif

#ifdef USE_METAL
#define START_GPU @autoreleasepool {
#define END_GPU }
#else
#define START_GPU
#define END_GPU
#endif

namespace jit {
//------------------------------------------------------------------------------
///  @brief Tests if the backend can be jit'ed.
+53 −57
Original line number Diff line number Diff line
@@ -71,7 +71,6 @@ namespace gpu {
                             graph::output_nodes<BACKEND> outputs,
                             const size_t num_rays,
                             const bool add_reduction=false) {
            @autoreleasepool {
            NSError *error;
            library = [device newLibraryWithSource:[NSString stringWithCString:kernel_source.c_str()
                                                                      encoding:NSUTF8StringEncoding]
@@ -122,7 +121,6 @@ namespace gpu {
            std::cout << "  Number of groups   : " << thread_groups << std::endl;
            std::cout << "  Total problem size : " << threads_per_group*thread_groups << std::endl;
        }
        }

//------------------------------------------------------------------------------
///  @brief Create a max compute pipeline.
@@ -163,7 +161,6 @@ namespace gpu {
///  the job. This method is asyncronus.
//------------------------------------------------------------------------------
        void run() {
            @autoreleasepool {
            command_buffer = [queue commandBuffer];
            id<MTLComputeCommandEncoder> encoder = [command_buffer computeCommandEncoderWithDispatchType:MTLDispatchTypeSerial];

@@ -178,7 +175,6 @@ namespace gpu {

            [command_buffer commit];
        }
        }

//------------------------------------------------------------------------------
///  @brief Compute the max reduction.
+2 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ template<typename BACKEND> void run_tests(const typename BACKEND::base tolarance
///  @param[in] argv Array of commandline arguments.
//------------------------------------------------------------------------------
int main(int argc, const char * argv[]) {
    START_GPU
#ifdef USE_REDUCE
#ifdef USE_CUDA
    run_tests<backend::cpu<float>> (3.2E-14);
@@ -126,4 +127,5 @@ int main(int argc, const char * argv[]) {
    run_tests<backend::cpu<std::complex<float>>> (2.0E-14);
#endif
    run_tests<backend::cpu<std::complex<double>>> (1.0E-30);
    END_GPU
}
+2 −0
Original line number Diff line number Diff line
@@ -397,8 +397,10 @@ template<typename BASE> void run_tests() {
///  @param[in] argv Array of commandline arguments.
//------------------------------------------------------------------------------
int main(int argc, const char * argv[]) {
    START_GPU
    run_tests<float> ();
    run_tests<double> ();
    run_tests<std::complex<float>> ();
    run_tests<std::complex<double>> ();
    END_GPU
}
Loading