BRL-CAD
Loading...
Searching...
No Matches
resource.h
Go to the documentation of this file.
1/* R E S O U R C E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-2025 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup rt_resource
21 * @brief
22 * Per-CPU statistics and resources.
23 */
24/** @{ */
25/** @file resource.h */
26
27#ifndef RT_RESOURCE_H
28#define RT_RESOURCE_H
29
30#include "common.h"
31#include "vmath.h"
32#include "bu/list.h"
33#include "bu/ptbl.h"
34#include "rt/defines.h"
35#include "rt/global.h" // for rt_uniresource
36#include "rt/tree.h"
37#include "rt/directory.h"
38
40
41/**
42 * One of these structures is needed per thread of execution, usually
43 * with calling applications creating an array with at least MAX_PSW
44 * elements. To prevent excessive competition for free structures,
45 * memory is now allocated on a per-processor basis. The application
46 * structure a_resource element specifies the resource structure to be
47 * used; if uniprocessing, a null a_resource pointer results in using
48 * the internal global structure (&rt_uniresource), making initial
49 * application development simpler.
50 *
51 * Note that if multiple models are being used, the partition and bitv
52 * structures (which are variable length) will require there to be
53 * ncpus * nmodels resource structures, the selection of which will be
54 * the responsibility of the application.
55 *
56 * Applications are responsible for calling rt_init_resource() on each
57 * resource structure before letting LIBRT use them.
58 *
59 * Per-processor statistics are initially collected in here, and then
60 * posted to rt_i by rt_add_res_stats().
61 */
62struct resource {
63 uint32_t re_magic; /**< @brief Magic number */
64 int re_cpu; /**< @brief processor number, for ID */
65 struct bu_list re_seg; /**< @brief Head of segment freelist */
66 struct bu_ptbl re_seg_blocks; /**< @brief Table of malloc'ed blocks of segs */
70 struct bu_list re_parthead; /**< @brief Head of freelist */
74 struct bu_list re_solid_bitv; /**< @brief head of freelist */
75 struct bu_list re_region_ptbl; /**< @brief head of freelist */
76 struct bu_list re_nmgfree; /**< @brief head of NMG hitmiss freelist */
77 union tree ** re_boolstack; /**< @brief Stack for rt_booleval() */
78 long re_boolslen; /**< @brief # elements in re_boolstack[] */
79 float * re_randptr; /**< @brief ptr into random number table */
80 /* Statistics. Only for examination by rt_add_res_stats() */
81 long re_nshootray; /**< @brief Calls to rt_shootray() */
82 long re_nmiss_model; /**< @brief Rays pruned by model RPP */
83 /* Solid nshots = shot_hit + shot_miss */
84 long re_shots; /**< @brief # calls to ft_shot() */
85 long re_shot_hit; /**< @brief ft_shot() returned a miss */
86 long re_shot_miss; /**< @brief ft_shot() returned a hit */
87 /* Optimizations. Rays not shot at solids */
88 long re_prune_solrpp;/**< @brief shot missed solid RPP, ft_shot skipped */
89 long re_ndup; /**< @brief ft_shot() calls skipped for already-ft_shot() solids */
90 long re_nempty_cells; /**< @brief number of empty spatial partitioning cells passed through */
91 /* Data for accelerating "pieces" of solids */
92 struct rt_piecestate *re_pieces; /**< @brief array [rti_nsolids_with_pieces] */
93 long re_piece_ndup; /**< @brief ft_piece_shot() calls skipped for already-ft_shot() solids */
94 long re_piece_shots; /**< @brief # calls to ft_piece_shot() */
95 long re_piece_shot_hit; /**< @brief ft_piece_shot() returned a miss */
96 long re_piece_shot_miss; /**< @brief ft_piece_shot() returned a hit */
97 struct bu_ptbl re_pieces_pending; /**< @brief pieces with an odd hit pending */
98 /* Per-processor cache of tree unions, to accelerate "tops" and treewalk */
99 union tree * re_tree_hd; /**< @brief Head of free trees */
104 struct bu_ptbl re_directory_blocks; /**< @brief Table of malloc'ed blocks */
105};
106
107#define RESOURCE_NULL ((struct resource *)0)
108#define RT_CK_RESOURCE(_p) BU_CKMAG(_p, RESOURCE_MAGIC, "struct resource")
109#define RT_RESOURCE_INIT_ZERO { RESOURCE_MAGIC, 0, BU_LIST_INIT_ZERO, BU_PTBL_INIT_ZERO, 0, 0, 0, BU_LIST_INIT_ZERO, 0, 0, 0, BU_LIST_INIT_ZERO, BU_LIST_INIT_ZERO, BU_LIST_INIT_ZERO, NULL, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0, BU_PTBL_INIT_ZERO, NULL, 0, 0, 0, NULL, BU_PTBL_INIT_ZERO }
110
111/**
112 * Definition of global parallel-processing semaphores.
113 *
114 * res_syscall is now BU_SEM_SYSCALL
115 */
116RT_EXPORT extern int RT_SEM_WORKER;
117RT_EXPORT extern int RT_SEM_MODEL;
118RT_EXPORT extern int RT_SEM_RESULTS;
119RT_EXPORT extern int RT_SEM_TREE0;
120RT_EXPORT extern int RT_SEM_TREE1;
121RT_EXPORT extern int RT_SEM_TREE2;
122RT_EXPORT extern int RT_SEM_TREE3;
123
124
126
127#endif /* RT_RESOURCE_H */
128/** @} */
129/*
130 * Local Variables:
131 * tab-width: 8
132 * mode: C
133 * indent-tabs-mode: t
134 * c-file-style: "stroustrup"
135 * End:
136 * ex: shiftwidth=4 tabstop=8
137 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
int RT_SEM_TREE3
int RT_SEM_TREE1
int RT_SEM_RESULTS
int RT_SEM_TREE0
int RT_SEM_MODEL
int RT_SEM_WORKER
int RT_SEM_TREE2
Definition ptbl.h:53
long re_seglen
Definition resource.h:67
long re_tree_free
Definition resource.h:102
long re_partget
Definition resource.h:72
struct bu_ptbl re_pieces_pending
pieces with an odd hit pending
Definition resource.h:97
long re_segfree
Definition resource.h:69
long re_shot_hit
ft_shot() returned a miss
Definition resource.h:85
long re_partfree
Definition resource.h:73
union tree ** re_boolstack
Stack for rt_booleval()
Definition resource.h:77
long re_tree_malloc
Definition resource.h:101
long re_piece_shots
# calls to ft_piece_shot()
Definition resource.h:94
long re_shots
# calls to ft_shot()
Definition resource.h:84
long re_nempty_cells
number of empty spatial partitioning cells passed through
Definition resource.h:90
long re_tree_get
Definition resource.h:100
struct bu_list re_parthead
Head of freelist.
Definition resource.h:70
struct bu_list re_nmgfree
head of NMG hitmiss freelist
Definition resource.h:76
long re_ndup
ft_shot() calls skipped for already-ft_shot() solids
Definition resource.h:89
struct bu_list re_solid_bitv
head of freelist
Definition resource.h:74
long re_shot_miss
ft_shot() returned a hit
Definition resource.h:86
union tree * re_tree_hd
Head of free trees.
Definition resource.h:99
struct directory * re_directory_hd
Definition resource.h:103
int re_cpu
processor number, for ID
Definition resource.h:64
struct bu_list re_seg
Head of segment freelist.
Definition resource.h:65
long re_boolslen
# elements in re_boolstack[]
Definition resource.h:78
long re_piece_shot_miss
ft_piece_shot() returned a hit
Definition resource.h:96
long re_prune_solrpp
shot missed solid RPP, ft_shot skipped
Definition resource.h:88
long re_segget
Definition resource.h:68
struct rt_piecestate * re_pieces
array [rti_nsolids_with_pieces]
Definition resource.h:92
long re_partlen
Definition resource.h:71
uint32_t re_magic
Magic number.
Definition resource.h:63
struct bu_list re_region_ptbl
head of freelist
Definition resource.h:75
long re_nshootray
Calls to rt_shootray()
Definition resource.h:81
struct bu_ptbl re_seg_blocks
Table of malloc'ed blocks of segs.
Definition resource.h:66
float * re_randptr
ptr into random number table
Definition resource.h:79
long re_piece_shot_hit
ft_piece_shot() returned a miss
Definition resource.h:95
long re_piece_ndup
ft_piece_shot() calls skipped for already-ft_shot() solids
Definition resource.h:93
long re_nmiss_model
Rays pruned by model RPP.
Definition resource.h:82
struct bu_ptbl re_directory_blocks
Table of malloc'ed blocks.
Definition resource.h:104
Definition tree.h:169
fundamental vector, matrix, quaternion math macros