PadicoTM

Documentation

« back to PM2 home.
psp.c
Go to the documentation of this file.
1/*
2 * Padico -- a High Performance Parallel and Distributed Computing Environment
3 * Copyright (c) 2002-2025 INRIA and the University of Rennes 1
4 * Alexandre DENIS <Alexandre.Denis@inria.fr>
5 * Christian PEREZ <Christian.Perez@inria.fr>
6 *
7 * The software has been registered at the Agency for the Protection of
8 * Programs (APP) under the number IDDN.FR.001.260013.000.S.P.2002.000.10000.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
30#include <Padico/Puk.h>
31#include <Padico/PM2.h>
32#include <Padico/PadicoTM.h>
33#include <Padico/Module.h>
34#include <Padico/Topology.h>
35
36#include "PSP.h"
37
38static int padico_psp_module_init(void);
39
41
42
43/* ********************************************************** */
44
45static int padico_psp_module_init(void)
46{
47 padico_out(30, "module_init()\n");
48
49 puk_iface_register("PadicoSimplePackets");
50
51 return 0;
52}
53
54/* ********************************************************** */
55
57{
58 pmarcel_spin_init(&d->lock, 0);
60 d->cache = NULL;
61}
62
64 padico_psp_handler_t handler, void*key,
65 uint32_t tag, size_t h_size)
66{
67 pmarcel_spin_lock(&d->lock);
69 if(!slot)
70 {
71 slot = padico_malloc(sizeof(struct padico_psp_slot_s));
72 *slot = (struct padico_psp_slot_s){ .handler = handler, .key = key, .tag = tag, .h_size = h_size, .ref_count = 1 };
74 }
75 else
76 {
77 assert(slot->handler == handler && slot->key == key);
78 slot->ref_count++;
79 }
80 pmarcel_spin_unlock(&d->lock);
81 return slot;
82}
83
85{
86 pmarcel_spin_lock(&d->lock);
87 slot->ref_count--;
88 if(slot->ref_count <= 0)
90 pmarcel_spin_unlock(&d->lock);
91}
92
94{
95 pmarcel_spin_lock(&d->lock);
96 padico_psp_slot_t slot = (d->cache && (d->cache->tag == tag)) ? d->cache : NULL;
97 while(!slot)
98 {
99 slot = padico_psp_slot_hashtable_lookup(&d->table, tag);
100 if(!slot)
101 {
102 pmarcel_spin_unlock(&d->lock);
103 sched_yield();
104 pmarcel_spin_lock(&d->lock);
105 }
106 }
107 d->cache = slot;
108 pmarcel_spin_unlock(&d->lock);
109 return slot;
110}
assert(slab_size > 0)
const const struct ns_rule_bucket_s * key
Padico Simple Packets API.
return NULL
Definition Shm.h:88
static const int tag
Definition bench_MPI.c:13
static int done
Definition console-mod.c:49
padico_psp_slot_t padico_psp_slot_insert(struct padico_psp_directory_s *d, padico_psp_handler_t handler, void *key, uint32_t tag, size_t h_size)
Definition psp.c:63
void padico_psp_directory_init(struct padico_psp_directory_s *d)
Definition psp.c:56
padico_psp_slot_hashtable_remove(h, *key)
padico_psp_slot_t padico_psp_slot_lookup(struct padico_psp_directory_s *d, uint32_t tag)
Definition psp.c:93
void padico_psp_slot_remove(struct padico_psp_directory_s *d, padico_psp_slot_t slot)
Definition psp.c:84
void(* padico_psp_handler_t)(const void *header, padico_topo_node_t from, void *key, padico_psp_pump_t pump, void *token)
A callback for PSP.
Definition PSP.h:103
static int padico_psp_module_init(void)
Definition psp.c:45
PSP slot directory used for multiplexing.
Definition PSP.h:234
a PSP slot, i.e.
Definition PSP.h:210
void * key
Definition PSP.h:212
size_t h_size
Definition PSP.h:214
padico_psp_handler_t handler
Definition PSP.h:211
uint32_t tag
Definition PSP.h:213