Changeset 2284 for trunk/test_more


Ignore:
Timestamp:
Feb 11, 2012 11:21:31 AM (8 years ago)
Author:
bradbell
Message:

Add the base_require.cpp example.

base_alloc.cpp: change to memory_leak add_static specifications.
memory_leak.hpp: have calling routines specify amount of static memory.
base_alloc.hpp: add some missing requirements.
omp_alloc.cpp: allow for static memory to be inuse.
thread_alloc.cpp: allow for static memory to be inuse.
base_member.omh: add some missing requirements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/base_alloc.cpp

    r2283 r2284  
    1515bool base_alloc_test(void)
    1616{       bool ok = true;
     17        using CppAD::thread_alloc;
    1718        typedef CppAD::AD<base_alloc> my_ad;
     19
     20        // check the amount of memory inuse by this thread (thread zero)
     21        size_t thread = thread_alloc::thread_num();
     22        ok &= thread == 0;
     23        size_t inuse_before = thread_alloc::inuse(thread);
    1824
    1925        // set static memory correspoding to isnan
    2026        CppAD::isnan( base_alloc(0.) );
    2127        CppAD::isnan( my_ad(0.) );
    22         bool set_static = true;
    23         CppAD::memory_leak(set_static);
     28
     29        // now determine if we need to inform memory_leak of this memory
     30        // (or if it had been previously allocated)
     31        size_t inuse_after = thread_alloc::inuse(thread);
     32        if( inuse_after > inuse_before )
     33                CppAD::memory_leak( inuse_after - inuse_before );
    2434       
    25 
    2635        // y = x^2
    2736        CppAD::vector<my_ad>   a_x, a_y;
Note: See TracChangeset for help on using the changeset viewer.