MCPcopy Create free account
hub / github.com/pydata/numexpr / prepareSerial

Function prepareSerial

numexpr3/interpreter.cpp:106–139  ·  view source on GitHub ↗

This is the equivalent of prepareThreads but for serial mode, where the original self and iter aren't copied.

Source from the content-addressed store, hash-verified

104// This is the equivalent of prepareThreads but for serial mode, where the original
105// self and iter aren't copied.
106int
107prepareSerial( NumExprObject* self, NpyIter *iter, int *pc_error, char **errorMessage ) {
108 int I = 0, R = 0;
109 npy_intp memOffset = 0, taskFactor, numBlocks;
110
111 // Setup error tracking
112 gs.ret_code = 0;
113 gs.pc_error = pc_error;
114 gs.errorMessage = errorMessage;
115
116 // printf( "prepareSerial()\n");
117
118 NpyIter_GetIterIndexRange(iter, &gs.start, &gs.vlen);
119
120 taskFactor = TASKS_PER_THREAD*BLOCK_SIZE1*gs.n_thread;
121 numBlocks = (gs.vlen - gs.start + taskFactor - 1) /
122 taskFactor;
123 gs.task_size = numBlocks * BLOCK_SIZE1; // Note this is much bigger than BLOCK_SIZE1
124
125 if( BLOCK_SIZE1 * self->total_temp_itemsize > gs.tempSize ) {
126 numexpr_set_tempsize( BLOCK_SIZE1 * self->total_temp_itemsize );
127 // printf("Engorged: gs.tempSize = %d, gs.tempArena = %p\n", gs.tempSize, gs.tempArena );
128 }
129 // Setup temporory memory pointers
130 for( R=0; R < self->n_reg; R++ ) {
131 if( self->registers[R].kind != KIND_TEMP ) continue;
132
133 // printf( "reg#%d has kind %d and itemsize %d\n", R, self->registers[R].kind, (int)self->registers[R].itemsize );
134 self->registers[R].mem = gs.tempArena + memOffset;
135 // printf( " thread #0, reg #%d, points to %p\n", R, self->registers[R].mem );
136 memOffset += BLOCK_SIZE1 * self->registers[R].itemsize;
137 }
138 return 0;
139}
140
141// This function prepares the pointers towards the temporary memory block, and
142// the NumExprObjects used by threads.

Callers 1

run_interpreterFunction · 0.85

Calls 1

numexpr_set_tempsizeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…