Triton Repository branch, master, updated. 52e103775e4a903e8d15bc3d8fcbe051a70203fa
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Triton Repository". The branch, master has been updated via 52e103775e4a903e8d15bc3d8fcbe051a70203fa (commit) via 34f9f7cec3ad7349f471eb79fea9a12a077defc8 (commit) via 60c3c9e926f637ed5f13c643dc96d11a12e0282c (commit) via 011c6f6a6a9fafa2916dff9b670a05a40b86eb68 (commit) from e8a8acae99f89ee131aa4d77a846b8512b58a4ec (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 52e103775e4a903e8d15bc3d8fcbe051a70203fa Author: Dries Kimpe <[email protected]> Date: Tue Jul 26 12:30:04 2011 -0700 By default, keep old opcache behaviour commit 34f9f7cec3ad7349f471eb79fea9a12a077defc8 Author: Dries Kimpe <[email protected]> Date: Tue Jul 26 12:27:49 2011 -0700 Modify opcache - Add mode where the opcache is not doing manual memory management - Simplify opcache API (remove unused functions) commit 60c3c9e926f637ed5f13c643dc96d11a12e0282c Author: Dries Kimpe <[email protected]> Date: Tue Jul 26 12:27:29 2011 -0700 Unused define commit 011c6f6a6a9fafa2916dff9b670a05a40b86eb68 Author: Dries Kimpe <[email protected]> Date: Tue Jul 26 12:26:14 2011 -0700 Introduce cache_id_t type There was a lot of confusion about what the cache_id field (in the op structure) was. Introduce typedef and fix where needed. ----------------------------------------------------------------------- Summary of changes: code/src/aesop/op.h | 6 ++- code/src/aesop/opcache.c | 52 +++++++++++++++++--- code/src/aesop/opcache.h | 39 +++++++++++++-- code/src/common/resources/aesocket/aesocket.c | 5 +- code/src/common/resources/timer/timer.c | 5 +- code/src/net/mpi/mpi.c | 4 +- .../prototype/file-resource/file-resource.c | 5 +- .../versioned-osd/prototype/tests/fake-resource.c | 5 +- 8 files changed, 97 insertions(+), 24 deletions(-) Diff of changes: diff --git a/code/src/aesop/op.h b/code/src/aesop/op.h index 850877a..b1f2cc3 100644 --- a/code/src/aesop/op.h +++ b/code/src/aesop/op.h @@ -5,6 +5,10 @@ #include "src/aesop/aesop.h" #include "src/aesop/ae-list.h" +#include <stdint.h> + +typedef uintptr_t cache_id_t; + typedef struct ae_op { void *callback; @@ -12,7 +16,7 @@ typedef struct ae_op void *user_ptr; ae_hints_t *hints; ae_context_t ctx; - int cache_id; + cache_id_t cache_id; ae_list_link_t link; } ae_op_t; diff --git a/code/src/aesop/opcache.c b/code/src/aesop/opcache.c index 3bfb2a3..7c64003 100644 --- a/code/src/aesop/opcache.c +++ b/code/src/aesop/opcache.c @@ -1,3 +1,5 @@ +/* Don't try to do manual memory management */ +// #define TRITON_OPCACHE_MALLOC #include <errno.h> #include "src/aesop/aesop.h" @@ -5,16 +7,18 @@ #include "src/common/triton-error.h" #define TRITON_OPCACHE_ARRAY_COUNT 32 -#define TRITON_OPCACHE_MAX_INDEX (0xFFFFFF) +/* UNUSED #define TRITON_OPCACHE_MAX_INDEX (0xFFFFFF) */ struct ae_opcache { +#ifndef TRITON_OPCACHE_MALLOC void *array[TRITON_OPCACHE_ARRAY_COUNT]; int array_count; int size; int count; triton_mutex_t mutex; ae_ops_t free_list; +#endif int typesize; int member_offset; }; @@ -27,6 +31,8 @@ triton_ret_t ae_opcache_init(int typesize, int member_offset, int init_size, ae_ { return TRITON_ERR_NOMEM; } + +#ifndef TRITON_OPCACHE_MALLOC c->size = init_size; c->array_count = 1; c->array[0] = malloc(typesize * init_size); @@ -35,15 +41,18 @@ triton_ret_t ae_opcache_init(int typesize, int member_offset, int init_size, ae_ free(c); return TRITON_ERR_NOMEM; } - c->typesize = typesize; - c->member_offset = member_offset; c->count = 0; - triton_mutex_init(&c->mutex, NULL); ae_ops_init(&(c->free_list)); + triton_mutex_init(&c->mutex, NULL); +#endif + + c->typesize = typesize; + c->member_offset = member_offset; *cache = c; return TRITON_SUCCESS; } +#ifndef TRITON_OPCACHE_MALLOC static triton_ret_t ae_opcache_double(ae_opcache_t cache) { int i; @@ -70,9 +79,11 @@ triton_ret_t ae_opcache_double_size(ae_opcache_t cache) triton_mutex_unlock(&cache->mutex); return ret; } +#endif void ae_opcache_destroy(ae_opcache_t cache) { +#ifndef TRITON_OPCACHE_MALLOC int i; triton_mutex_lock(&cache->mutex); for(i = 0; i < cache->array_count; ++i) @@ -80,16 +91,18 @@ void ae_opcache_destroy(ae_opcache_t cache) free(cache->array[i]); } triton_mutex_unlock(&cache->mutex); +#endif free(cache); return; } -int ae_opcache_size(ae_opcache_t cache) +#if 0 +static int ae_opcache_size(ae_opcache_t cache) { return cache->size; } -int ae_opcache_count(ae_opcache_t cache) +static int ae_opcache_count(ae_opcache_t cache) { int count; @@ -99,11 +112,19 @@ int ae_opcache_count(ae_opcache_t cache) return count; } +#endif struct ae_op *ae_opcache_get(ae_opcache_t cache) { - int aind, count; struct ae_op *op; +#ifdef TRITON_OPCACHE_MALLOC + op = (struct ae_op *) ( (char*) malloc (cache->typesize) + + cache->member_offset); + ae_op_clear(op); + assert (sizeof (op->cache_id) >= sizeof (op)); + op->cache_id = (uintptr_t) op; +#else + int aind, count; triton_mutex_lock(&cache->mutex); if(ae_ops_empty(&cache->free_list)) @@ -121,6 +142,9 @@ struct ae_op *ae_opcache_get(ae_opcache_t cache) (count * cache->typesize) + cache->member_offset); ae_op_clear(op); + + assert (sizeof(op->cache_id) >= 4); + op->cache_id = (aind << 25) | count; ++cache->count; } @@ -130,22 +154,33 @@ struct ae_op *ae_opcache_get(ae_opcache_t cache) } triton_mutex_unlock(&cache->mutex); assert(op); +#endif return op; } void ae_opcache_put(ae_opcache_t cache, struct ae_op *op) { +#ifdef TRITON_OPCACHE_MALLOC + free ((char*) op - cache->member_offset); +#else triton_mutex_lock(&cache->mutex); ae_ops_enqueue(op, &cache->free_list); triton_mutex_unlock(&cache->mutex); +#endif return; } -struct ae_op *ae_opcache_lookup(ae_opcache_t cache, int id) +struct ae_op * ae_opcache_lookup(ae_opcache_t cache, cache_id_t id) { +#ifdef TRITON_OPCACHE_MALLOC + return (struct ae_op *) id; +#else int aind, count; + /* the code below assumes we have 32 bits available */ + assert (sizeof (cache_id_t) >= 4); + /* we get the array index from the top 6 bits */ aind = (id >> 25); count = id & 0xFFFFFF; @@ -153,6 +188,7 @@ struct ae_op *ae_opcache_lookup(ae_opcache_t cache, int id) return (struct ae_op *)(((char *)cache->array[aind]) + (count * cache->typesize) + cache->member_offset); +#endif } /* diff --git a/code/src/aesop/opcache.h b/code/src/aesop/opcache.h index 47b4aa9..8d0a0a5 100644 --- a/code/src/aesop/opcache.h +++ b/code/src/aesop/opcache.h @@ -1,4 +1,3 @@ - #ifndef __OPCACHE_H__ #define __OPCACHE_H__ @@ -22,16 +21,46 @@ typedef struct ae_opcache *ae_opcache_t; ae_opcache_put(__opcache, __op); \ } while(0) -ae_ret_t ae_opcache_init(int typesize, int member_offset, int init_size, ae_opcache_t *cache); - -ae_ret_t ae_opcache_double_size(ae_opcache_t cache); +/** + * Create an opcache. + * init_size is a hint and may be ignored. + */ +ae_ret_t ae_opcache_init(int typesize, int member_offset, int init_size, + ae_opcache_t *cache); + +/** + * Destroy the given opcache. + * Note that all entries obtained from this cache are released and + * invalidated. + */ void ae_opcache_destroy(ae_opcache_t cache); +/** + * Obtain an ae_op entry. The entry will have a valid + * op->cache_id + */ struct ae_op *ae_opcache_get(ae_opcache_t cache); + +/** + * Return ae_op entry to the cache + */ void ae_opcache_put(ae_opcache_t cache, struct ae_op *op); + +/** + * Given the cache id, return the ae_op * associated with it + */ +struct ae_op *ae_opcache_lookup(ae_opcache_t cache, cache_id_t id); + + +/* (Dries) Disabled these functions: They're not used at this time, + * and expose information we cannot guarantee to always have. + */ +#if 0 +ae_ret_t ae_opcache_double_size(ae_opcache_t cache); + /** * Size of the opcache array. This is the total size of the cache. As * more in-use ops are pulled from the cache (ae_opcache_get), the cache @@ -46,8 +75,8 @@ int ae_opcache_size(ae_opcache_t cache); * in the cache without needing to double the size. */ int ae_opcache_count(ae_opcache_t cache); +#endif -struct ae_op *ae_opcache_lookup(ae_opcache_t cache, int id); #endif diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c index f7fe093..f0f677c 100644 --- a/code/src/common/resources/aesocket/aesocket.c +++ b/code/src/common/resources/aesocket/aesocket.c @@ -292,7 +292,8 @@ static triton_ret_t triton_aesocket_cancel( ae_op_id_t op_id) { #ifdef __AESOP_LIBEV - int cache_id, resource_id; + cache_id_t cache_id; + int resource_id; struct ae_op *op; struct aesocket_op *socket_op; ae_context_t ctx; @@ -304,7 +305,7 @@ static triton_ret_t triton_aesocket_cancel( cache_id = ae_id_lookup(op_id, &resource_id); assert(resource_id == triton_aesocket_resource_id); - op = ae_opcache_lookup(aesocket_opcache, (int) cache_id); + op = ae_opcache_lookup(aesocket_opcache, cache_id); socket_op = ae_op_entry(op, struct aesocket_op, op); ctx = op->ctx; diff --git a/code/src/common/resources/timer/timer.c b/code/src/common/resources/timer/timer.c index 05ec0e5..574edb4 100644 --- a/code/src/common/resources/timer/timer.c +++ b/code/src/common/resources/timer/timer.c @@ -167,7 +167,8 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i struct itimerspec tspec; struct itimerspec old_tspec; #endif - int cache_id, resource_id; + cache_id_t cache_id; + int resource_id; struct ae_op *op; struct timer_op *top; ae_context_t ctx; @@ -179,7 +180,7 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i cache_id = ae_id_lookup(op_id, &resource_id); assert(resource_id == triton_timer_resource_id); - op = ae_opcache_lookup(timer_opcache, (int)cache_id); + op = ae_opcache_lookup(timer_opcache, cache_id); /* should still be in an op list */ if(!ae_ops_exists(&timer_oplist, &op->link)) diff --git a/code/src/net/mpi/mpi.c b/code/src/net/mpi/mpi.c index b7c1229..8db4316 100644 --- a/code/src/net/mpi/mpi.c +++ b/code/src/net/mpi/mpi.c @@ -597,7 +597,7 @@ static triton_ret_t triton_mpi_poll(ae_context_t ctx) static triton_ret_t triton_mpi_cancel(ae_context_t ctx, ae_op_id_t op_id) { - uint64_t cache_id; + cache_id_t cache_id; int resource_id, ret; struct ae_op *op; struct mpi_op *mpi_op; @@ -610,7 +610,7 @@ static triton_ret_t triton_mpi_cancel(ae_context_t ctx, ae_op_id_t op_id) cache_id = ae_id_lookup(op_id, &resource_id); assert(resource_id == mpi_resource_id); triton_mutex_lock(&mpi_ctx->oplist_mutex); - op = ae_opcache_lookup(mpi_ctx->opcache, (int)cache_id); + op = ae_opcache_lookup(mpi_ctx->opcache, cache_id); if(!ae_ops_exists(&mpi_ctx->posted_oplist, &op->link) && !ae_ops_exists(&mpi_ctx->inflight_oplist, &op->link)) { diff --git a/code/src/versioned-osd/prototype/file-resource/file-resource.c b/code/src/versioned-osd/prototype/file-resource/file-resource.c index 8995de2..9bd15a2 100644 --- a/code/src/versioned-osd/prototype/file-resource/file-resource.c +++ b/code/src/versioned-osd/prototype/file-resource/file-resource.c @@ -295,7 +295,8 @@ static triton_ret_t file_poll(ae_context_t context) */ static triton_ret_t file_cancel(ae_context_t triton_ctx, ae_op_id_t op_id) { - int cache_id, resource_id; + cache_id_t cache_id; + int resource_id; triton_mutex_lock(&file_mutex); struct ae_op *op; struct file_op *f_op; @@ -303,7 +304,7 @@ static triton_ret_t file_cancel(ae_context_t triton_ctx, ae_op_id_t op_id) cache_id = ae_id_lookup(op_id, &resource_id); assert(resource_id == triton_file_resource_id); - op = ae_opcache_lookup(file_opcache, (int)cache_id); + op = ae_opcache_lookup(file_opcache, cache_id); f_op = ae_op_entry(op, struct file_op, op); #if 0 ae_ops_del(op); diff --git a/code/src/versioned-osd/prototype/tests/fake-resource.c b/code/src/versioned-osd/prototype/tests/fake-resource.c index 9c87889..b3aefae 100644 --- a/code/src/versioned-osd/prototype/tests/fake-resource.c +++ b/code/src/versioned-osd/prototype/tests/fake-resource.c @@ -118,7 +118,8 @@ static triton_ret_t fake_poll_thread_per_op(ae_context_t context) */ static triton_ret_t fake_cancel(ae_context_t triton_ctx, ae_op_id_t op_id) { - int cache_id, resource_id; + cache_id_t cache_id; + int resource_id; triton_mutex_lock(&fake_mutex); struct ae_op *op; struct fake_op *b_op; @@ -126,7 +127,7 @@ static triton_ret_t fake_cancel(ae_context_t triton_ctx, ae_op_id_t op_id) cache_id = ae_id_lookup(op_id, &resource_id); assert(resource_id == triton_fake_resource_id); - op = ae_opcache_lookup(fake_opcache, (int)cache_id); + op = ae_opcache_lookup(fake_opcache, cache_id); b_op = ae_op_entry(op, struct fake_op, op); #if 0 ae_ops_del(op); hooks/post-receive -- Triton Repository
participants (1)
-
noreply@mcs.anl.gov