hexsha
stringlengths 40
40
| repo
stringlengths 5
105
| path
stringlengths 3
173
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
438
| return_type
stringlengths 1
106
⌀ | original_string
stringlengths 21
40.7k
| original_docstring
stringlengths 18
13.4k
| docstring
stringlengths 11
3.24k
| docstring_tokens
sequence | code
stringlengths 14
20.4k
| code_tokens
sequence | short_docstring
stringlengths 0
4.36k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1ba3cd0022fa5e8cb25a230cbbf1980eb0dd362f | y11en/BranchMonitoringProject | BranchMonitor.PMI/src/checks/cpu/cpuid.c | [
"MIT"
] | C | check_has_bts | int | int check_has_bts()
{
INT64 msr;
debug("Check BTS support");
/* IA32_MISC_MSR - 416 */
msr=__readmsr(MSR_MISC);
/* MSR[11]=1 */
if(CHECK_BIT(msr,BTS_BIT_OFFSET)==BIT_ENABLED)
{
return CPU_HAS_NO_BTS;
}
return NO_ERROR;
} | /* Check if processor has BTS capabilities */ | Check if processor has BTS capabilities | [
"Check",
"if",
"processor",
"has",
"BTS",
"capabilities"
] | int check_has_bts()
{
INT64 msr;
debug("Check BTS support");
msr=__readmsr(MSR_MISC);
if(CHECK_BIT(msr,BTS_BIT_OFFSET)==BIT_ENABLED)
{
return CPU_HAS_NO_BTS;
}
return NO_ERROR;
} | [
"int",
"check_has_bts",
"(",
")",
"{",
"INT64",
"msr",
";",
"debug",
"(",
"\"",
"\"",
")",
";",
"msr",
"=",
"__readmsr",
"(",
"MSR_MISC",
")",
";",
"if",
"(",
"CHECK_BIT",
"(",
"msr",
",",
"BTS_BIT_OFFSET",
")",
"==",
"BIT_ENABLED",
")",
"{",
"return",
"CPU_HAS_NO_BTS",
";",
"}",
"return",
"NO_ERROR",
";",
"}"
] | Check if processor has BTS capabilities | [
"Check",
"if",
"processor",
"has",
"BTS",
"capabilities"
] | [
"/* IA32_MISC_MSR - 416 */",
"/* MSR[11]=1 */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d221903efd2dcee5f98cb1f3254b2a805e91f484 | oamldev/msnake_oaml | src/snake.c | [
"MIT"
] | C | snake_part_is_on | WINDOW | WINDOW *snake_part_is_on(SNAKE *snake, int posy, int posx) {
int i;
int cury, curx; // position of the current snake part we are iterating
// iterate each part
for(i = 0; i < snake->length; i++) {
// get the position of the current part
getbegyx(snake->parts[i], cury, curx);
// compare the position
if(cury == posy && curx == posx) {
// return the current part
return snake->parts[i];
}
}
return NULL;
} | // check if a part of the snake is on the given spot
// returns a WINDOW * if one is found, NULL if not | check if a part of the snake is on the given spot
returns a WINDOW * if one is found, NULL if not | [
"check",
"if",
"a",
"part",
"of",
"the",
"snake",
"is",
"on",
"the",
"given",
"spot",
"returns",
"a",
"WINDOW",
"*",
"if",
"one",
"is",
"found",
"NULL",
"if",
"not"
] | WINDOW *snake_part_is_on(SNAKE *snake, int posy, int posx) {
int i;
int cury, curx;
for(i = 0; i < snake->length; i++) {
getbegyx(snake->parts[i], cury, curx);
if(cury == posy && curx == posx) {
return snake->parts[i];
}
}
return NULL;
} | [
"WINDOW",
"*",
"snake_part_is_on",
"(",
"SNAKE",
"*",
"snake",
",",
"int",
"posy",
",",
"int",
"posx",
")",
"{",
"int",
"i",
";",
"int",
"cury",
",",
"curx",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"snake",
"->",
"length",
";",
"i",
"++",
")",
"{",
"getbegyx",
"(",
"snake",
"->",
"parts",
"[",
"i",
"]",
",",
"cury",
",",
"curx",
")",
";",
"if",
"(",
"cury",
"==",
"posy",
"&&",
"curx",
"==",
"posx",
")",
"{",
"return",
"snake",
"->",
"parts",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
] | check if a part of the snake is on the given spot
returns a WINDOW * if one is found, NULL if not | [
"check",
"if",
"a",
"part",
"of",
"the",
"snake",
"is",
"on",
"the",
"given",
"spot",
"returns",
"a",
"WINDOW",
"*",
"if",
"one",
"is",
"found",
"NULL",
"if",
"not"
] | [
"// position of the current snake part we are iterating",
"// iterate each part",
"// get the position of the current part",
"// compare the position",
"// return the current part"
] | [
{
"param": "snake",
"type": "SNAKE"
},
{
"param": "posy",
"type": "int"
},
{
"param": "posx",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "snake",
"type": "SNAKE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "posy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "posx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d221903efd2dcee5f98cb1f3254b2a805e91f484 | oamldev/msnake_oaml | src/snake.c | [
"MIT"
] | C | grow_snake | void | void grow_snake(SNAKE *snake, int posy, int posx) {
// a window containing a single char of a snake
WINDOW *win;
// increase the length of the snake
snake->length++;
// allocate memory for the new part
if(snake->length == 0) {
// initialize the array with malloc if it is the first part
snake->parts = malloc(sizeof(WINDOW*) * snake->length);
} else {
// increase the amount of allocated memory
snake->parts = realloc(snake->parts, sizeof(WINDOW*) * snake->length);
}
// create a new window
snake->parts[snake->length - 1] = win = newwin(1, 1, posy, posx);
// print the character on the window
wattron(win, COLOR_PAIR(2));
wprintw(win, "%c", 'O');
// display the part
wrefresh(win);
return;
} | // increase the length of the name by one | increase the length of the name by one | [
"increase",
"the",
"length",
"of",
"the",
"name",
"by",
"one"
] | void grow_snake(SNAKE *snake, int posy, int posx) {
WINDOW *win;
snake->length++;
if(snake->length == 0) {
snake->parts = malloc(sizeof(WINDOW*) * snake->length);
} else {
snake->parts = realloc(snake->parts, sizeof(WINDOW*) * snake->length);
}
snake->parts[snake->length - 1] = win = newwin(1, 1, posy, posx);
wattron(win, COLOR_PAIR(2));
wprintw(win, "%c", 'O');
wrefresh(win);
return;
} | [
"void",
"grow_snake",
"(",
"SNAKE",
"*",
"snake",
",",
"int",
"posy",
",",
"int",
"posx",
")",
"{",
"WINDOW",
"*",
"win",
";",
"snake",
"->",
"length",
"++",
";",
"if",
"(",
"snake",
"->",
"length",
"==",
"0",
")",
"{",
"snake",
"->",
"parts",
"=",
"malloc",
"(",
"sizeof",
"(",
"WINDOW",
"*",
")",
"*",
"snake",
"->",
"length",
")",
";",
"}",
"else",
"{",
"snake",
"->",
"parts",
"=",
"realloc",
"(",
"snake",
"->",
"parts",
",",
"sizeof",
"(",
"WINDOW",
"*",
")",
"*",
"snake",
"->",
"length",
")",
";",
"}",
"snake",
"->",
"parts",
"[",
"snake",
"->",
"length",
"-",
"1",
"]",
"=",
"win",
"=",
"newwin",
"(",
"1",
",",
"1",
",",
"posy",
",",
"posx",
")",
";",
"wattron",
"(",
"win",
",",
"COLOR_PAIR",
"(",
"2",
")",
")",
";",
"wprintw",
"(",
"win",
",",
"\"",
"\"",
",",
"'",
"'",
")",
";",
"wrefresh",
"(",
"win",
")",
";",
"return",
";",
"}"
] | increase the length of the name by one | [
"increase",
"the",
"length",
"of",
"the",
"name",
"by",
"one"
] | [
"// a window containing a single char of a snake",
"// increase the length of the snake",
"// allocate memory for the new part",
"// initialize the array with malloc if it is the first part",
"// increase the amount of allocated memory",
"// create a new window",
"// print the character on the window",
"// display the part"
] | [
{
"param": "snake",
"type": "SNAKE"
},
{
"param": "posy",
"type": "int"
},
{
"param": "posx",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "snake",
"type": "SNAKE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "posy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "posx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d221903efd2dcee5f98cb1f3254b2a805e91f484 | oamldev/msnake_oaml | src/snake.c | [
"MIT"
] | C | kill_snake | void | void kill_snake(SNAKE *snake) {
int i;
// delete each created window of the snake
for(i = 0; i < snake->length; i++) {
delwin(snake->parts[i]);
}
// free the resources allocated for the window pointers
free(snake->parts);
return;
} | // free the allocated memory for the snake | free the allocated memory for the snake | [
"free",
"the",
"allocated",
"memory",
"for",
"the",
"snake"
] | void kill_snake(SNAKE *snake) {
int i;
for(i = 0; i < snake->length; i++) {
delwin(snake->parts[i]);
}
free(snake->parts);
return;
} | [
"void",
"kill_snake",
"(",
"SNAKE",
"*",
"snake",
")",
"{",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"snake",
"->",
"length",
";",
"i",
"++",
")",
"{",
"delwin",
"(",
"snake",
"->",
"parts",
"[",
"i",
"]",
")",
";",
"}",
"free",
"(",
"snake",
"->",
"parts",
")",
";",
"return",
";",
"}"
] | free the allocated memory for the snake | [
"free",
"the",
"allocated",
"memory",
"for",
"the",
"snake"
] | [
"// delete each created window of the snake",
"// free the resources allocated for the window pointers"
] | [
{
"param": "snake",
"type": "SNAKE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "snake",
"type": "SNAKE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
943e721e766abb9e36374a2515ca3211d37fd189 | oamldev/msnake_oaml | src/time-helpers.c | [
"MIT"
] | C | timeval_diff | nan | long long timeval_diff(struct timespec* tv1, struct timespec* tv2) {
long long diff = 0;
// calculate the diffrence of the nanoseconds
long nano = (tv2->tv_nsec - tv1->tv_nsec);
int add = 0;
// some calculations if the nanoseconds of struct 1 were bigger
if(nano < 0) {
nano = 1000000000 + nano;
add = 1;
}
diff = nano;
// add the seconds
diff += (tv2->tv_sec - tv1->tv_sec - add) * 1000000000;
return diff;
} | // calculate the difference between two timespec structs | calculate the difference between two timespec structs | [
"calculate",
"the",
"difference",
"between",
"two",
"timespec",
"structs"
] | long long timeval_diff(struct timespec* tv1, struct timespec* tv2) {
long long diff = 0;
long nano = (tv2->tv_nsec - tv1->tv_nsec);
int add = 0;
if(nano < 0) {
nano = 1000000000 + nano;
add = 1;
}
diff = nano;
diff += (tv2->tv_sec - tv1->tv_sec - add) * 1000000000;
return diff;
} | [
"long",
"long",
"timeval_diff",
"(",
"struct",
"timespec",
"*",
"tv1",
",",
"struct",
"timespec",
"*",
"tv2",
")",
"{",
"long",
"long",
"diff",
"=",
"0",
";",
"long",
"nano",
"=",
"(",
"tv2",
"->",
"tv_nsec",
"-",
"tv1",
"->",
"tv_nsec",
")",
";",
"int",
"add",
"=",
"0",
";",
"if",
"(",
"nano",
"<",
"0",
")",
"{",
"nano",
"=",
"1000000000",
"+",
"nano",
";",
"add",
"=",
"1",
";",
"}",
"diff",
"=",
"nano",
";",
"diff",
"+=",
"(",
"tv2",
"->",
"tv_sec",
"-",
"tv1",
"->",
"tv_sec",
"-",
"add",
")",
"*",
"1000000000",
";",
"return",
"diff",
";",
"}"
] | calculate the difference between two timespec structs | [
"calculate",
"the",
"difference",
"between",
"two",
"timespec",
"structs"
] | [
"// calculate the diffrence of the nanoseconds",
"// some calculations if the nanoseconds of struct 1 were bigger",
"// add the seconds"
] | [
{
"param": "tv1",
"type": "struct timespec"
},
{
"param": "tv2",
"type": "struct timespec"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tv1",
"type": "struct timespec",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tv2",
"type": "struct timespec",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | drawArray | void | void drawArray(int arr, int drawMode) {
int row, col, value;
attron(COLOR_PAIR(drawMode));
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++) {
if(arr == ARRAY_MOUSEMAZE)
value = getMouseMaze(row, col);
else if(arr == ARRAY_FLOODMAZE)
value = getFloodMaze(row, col);
else if(arr == ARRAY_ACTUALMAZE)
value = actualMaze[row][col];
mvprintw(MAZE_START_ROW + row * 2 + 1, MAZE_START_COL + col * 3 + 1,
"%2x", value);
}
attroff(COLOR_PAIR(drawMode));
} | /******************************************************************************
Routine Name: drawArray
File: sim.c
Description: Draws specified maze using drawMode color pair onto the screen.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
arr array containing maze
drawMode color pair to use when drawing maze
******************************************************************************/ | Routine Name: drawArray
File: sim.c
Draws specified maze using drawMode color pair onto the screen.
Parameter Descriptions:
name description
arr array containing maze
drawMode color pair to use when drawing maze | [
"Routine",
"Name",
":",
"drawArray",
"File",
":",
"sim",
".",
"c",
"Draws",
"specified",
"maze",
"using",
"drawMode",
"color",
"pair",
"onto",
"the",
"screen",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"arr",
"array",
"containing",
"maze",
"drawMode",
"color",
"pair",
"to",
"use",
"when",
"drawing",
"maze"
] | void drawArray(int arr, int drawMode) {
int row, col, value;
attron(COLOR_PAIR(drawMode));
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++) {
if(arr == ARRAY_MOUSEMAZE)
value = getMouseMaze(row, col);
else if(arr == ARRAY_FLOODMAZE)
value = getFloodMaze(row, col);
else if(arr == ARRAY_ACTUALMAZE)
value = actualMaze[row][col];
mvprintw(MAZE_START_ROW + row * 2 + 1, MAZE_START_COL + col * 3 + 1,
"%2x", value);
}
attroff(COLOR_PAIR(drawMode));
} | [
"void",
"drawArray",
"(",
"int",
"arr",
",",
"int",
"drawMode",
")",
"{",
"int",
"row",
",",
"col",
",",
"value",
";",
"attron",
"(",
"COLOR_PAIR",
"(",
"drawMode",
")",
")",
";",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"MAZE_WIDTH",
";",
"row",
"++",
")",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"{",
"if",
"(",
"arr",
"==",
"ARRAY_MOUSEMAZE",
")",
"value",
"=",
"getMouseMaze",
"(",
"row",
",",
"col",
")",
";",
"else",
"if",
"(",
"arr",
"==",
"ARRAY_FLOODMAZE",
")",
"value",
"=",
"getFloodMaze",
"(",
"row",
",",
"col",
")",
";",
"else",
"if",
"(",
"arr",
"==",
"ARRAY_ACTUALMAZE",
")",
"value",
"=",
"actualMaze",
"[",
"row",
"]",
"[",
"col",
"]",
";",
"mvprintw",
"(",
"MAZE_START_ROW",
"+",
"row",
"*",
"2",
"+",
"1",
",",
"MAZE_START_COL",
"+",
"col",
"*",
"3",
"+",
"1",
",",
"\"",
"\"",
",",
"value",
")",
";",
"}",
"attroff",
"(",
"COLOR_PAIR",
"(",
"drawMode",
")",
")",
";",
"}"
] | Routine Name: drawArray
File: sim.c | [
"Routine",
"Name",
":",
"drawArray",
"File",
":",
"sim",
".",
"c"
] | [] | [
{
"param": "arr",
"type": "int"
},
{
"param": "drawMode",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arr",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "drawMode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | runMouse | void | void runMouse(int mouseMode, int drawMode) {
int curRow, curCol;
curRow = getMouseRow();
curCol = getMouseCol();
if(mouseMode == SPEED) {
buildSpeedPath(8, 8);
speedRun(8, 8);
return;
}
else if(mouseMode == MAPPING)
mapMaze(8, 8, STEP);
else if(mouseMode == OPTIMIZING)
mapMaze(15, 0, STEP);
drawTileWalls(curCol, curRow, getMouseMaze(curRow, curCol), drawMode);
drawMouse(curRow, curCol);
} | /******************************************************************************
Routine Name: runMouse
File: sim.c
Description: Interface used to call mouse functions.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
mouseMode mode mouse is in
drawMode color pair to color tile walls that were just updated
******************************************************************************/ | Routine Name: runMouse
File: sim.c
Interface used to call mouse functions.
Parameter Descriptions:
name description
mouseMode mode mouse is in
drawMode color pair to color tile walls that were just updated | [
"Routine",
"Name",
":",
"runMouse",
"File",
":",
"sim",
".",
"c",
"Interface",
"used",
"to",
"call",
"mouse",
"functions",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"mouseMode",
"mode",
"mouse",
"is",
"in",
"drawMode",
"color",
"pair",
"to",
"color",
"tile",
"walls",
"that",
"were",
"just",
"updated"
] | void runMouse(int mouseMode, int drawMode) {
int curRow, curCol;
curRow = getMouseRow();
curCol = getMouseCol();
if(mouseMode == SPEED) {
buildSpeedPath(8, 8);
speedRun(8, 8);
return;
}
else if(mouseMode == MAPPING)
mapMaze(8, 8, STEP);
else if(mouseMode == OPTIMIZING)
mapMaze(15, 0, STEP);
drawTileWalls(curCol, curRow, getMouseMaze(curRow, curCol), drawMode);
drawMouse(curRow, curCol);
} | [
"void",
"runMouse",
"(",
"int",
"mouseMode",
",",
"int",
"drawMode",
")",
"{",
"int",
"curRow",
",",
"curCol",
";",
"curRow",
"=",
"getMouseRow",
"(",
")",
";",
"curCol",
"=",
"getMouseCol",
"(",
")",
";",
"if",
"(",
"mouseMode",
"==",
"SPEED",
")",
"{",
"buildSpeedPath",
"(",
"8",
",",
"8",
")",
";",
"speedRun",
"(",
"8",
",",
"8",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"mouseMode",
"==",
"MAPPING",
")",
"mapMaze",
"(",
"8",
",",
"8",
",",
"STEP",
")",
";",
"else",
"if",
"(",
"mouseMode",
"==",
"OPTIMIZING",
")",
"mapMaze",
"(",
"15",
",",
"0",
",",
"STEP",
")",
";",
"drawTileWalls",
"(",
"curCol",
",",
"curRow",
",",
"getMouseMaze",
"(",
"curRow",
",",
"curCol",
")",
",",
"drawMode",
")",
";",
"drawMouse",
"(",
"curRow",
",",
"curCol",
")",
";",
"}"
] | Routine Name: runMouse
File: sim.c | [
"Routine",
"Name",
":",
"runMouse",
"File",
":",
"sim",
".",
"c"
] | [] | [
{
"param": "mouseMode",
"type": "int"
},
{
"param": "drawMode",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mouseMode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "drawMode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | drawMouse | void | void drawMouse(int mouseRow, int mouseCol) {
int row, col;
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++)
mvaddch(MAZE_START_ROW + row * 2 + 1, MAZE_START_COL + col * 3 + 1, ' ');
mvaddch(MAZE_START_ROW + mouseRow * 2 + 1, MAZE_START_COL + mouseCol * 3 + 1,
ACS_DIAMOND);
} | /******************************************************************************
Routine Name: drawMouse
File: sim.c
Description: Draws mouse marker on maze
Parameter Descriptions:
name description
------------------ -----------------------------------------------
mouseRow row of mouse
mouseCol col of mouse
******************************************************************************/ | Routine Name: drawMouse
File: sim.c
Draws mouse marker on maze
Parameter Descriptions:
name description
mouseRow row of mouse
mouseCol col of mouse | [
"Routine",
"Name",
":",
"drawMouse",
"File",
":",
"sim",
".",
"c",
"Draws",
"mouse",
"marker",
"on",
"maze",
"Parameter",
"Descriptions",
":",
"name",
"description",
"mouseRow",
"row",
"of",
"mouse",
"mouseCol",
"col",
"of",
"mouse"
] | void drawMouse(int mouseRow, int mouseCol) {
int row, col;
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++)
mvaddch(MAZE_START_ROW + row * 2 + 1, MAZE_START_COL + col * 3 + 1, ' ');
mvaddch(MAZE_START_ROW + mouseRow * 2 + 1, MAZE_START_COL + mouseCol * 3 + 1,
ACS_DIAMOND);
} | [
"void",
"drawMouse",
"(",
"int",
"mouseRow",
",",
"int",
"mouseCol",
")",
"{",
"int",
"row",
",",
"col",
";",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"MAZE_WIDTH",
";",
"row",
"++",
")",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"mvaddch",
"(",
"MAZE_START_ROW",
"+",
"row",
"*",
"2",
"+",
"1",
",",
"MAZE_START_COL",
"+",
"col",
"*",
"3",
"+",
"1",
",",
"'",
"'",
")",
";",
"mvaddch",
"(",
"MAZE_START_ROW",
"+",
"mouseRow",
"*",
"2",
"+",
"1",
",",
"MAZE_START_COL",
"+",
"mouseCol",
"*",
"3",
"+",
"1",
",",
"ACS_DIAMOND",
")",
";",
"}"
] | Routine Name: drawMouse
File: sim.c | [
"Routine",
"Name",
":",
"drawMouse",
"File",
":",
"sim",
".",
"c"
] | [] | [
{
"param": "mouseRow",
"type": "int"
},
{
"param": "mouseCol",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mouseRow",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mouseCol",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | printMenu | void | void printMenu(int mode) {
int row, col, i;
row = MAZE_START_ROW;
col = MAZE_START_COL + MAZE_WIDTH * 3 + 3;
attron(COLOR_PAIR(mode));
//Print menu box
mvaddch(row, col, ACS_ULCORNER);
for(i = 0; i < MENU_WIDTH - 2; i++) {
addch(ACS_HLINE);
}
addch(ACS_URCORNER);
for(i = row + 1; i < MENU_HEIGHT; i++) {
mvaddch(i, col, ACS_VLINE);
mvaddch(i, col + MENU_WIDTH - 1, ACS_VLINE);
}
mvaddch(row + MENU_HEIGHT - 1, col, ACS_LLCORNER);
for(i = 0; i < MENU_WIDTH - 2; i++) {
addch(ACS_HLINE);
}
addch(ACS_LRCORNER);
//Print menu
mvprintw(row + 1, col + 1, "l Load maze");
mvprintw(row + 2, col + 1, "d Draw empty maze");
mvprintw(row + 3, col + 1, "a Disp array");
mvprintw(row + 4, col + 1, "i Init mouse");
mvprintw(row + 5, col + 1, "r Run mouse step");
mvprintw(row + 6, col + 1, "f Disp floodMaze");
mvprintw(row + 7, col + 1, "m Disp mouseMaze");
mvprintw(row + 8, col + 1, "c Clear maze");
attroff(COLOR_PAIR(mode));
} | /******************************************************************************
Routine Name: printMenu
File: sim.c
Description: Displays status bar to side of maze
Parameter Descriptions:
name description
------------------ -----------------------------------------------
mode color pair used to draw menu
******************************************************************************/ | Routine Name: printMenu
File: sim.c
Displays status bar to side of maze
Parameter Descriptions:
name description
mode color pair used to draw menu | [
"Routine",
"Name",
":",
"printMenu",
"File",
":",
"sim",
".",
"c",
"Displays",
"status",
"bar",
"to",
"side",
"of",
"maze",
"Parameter",
"Descriptions",
":",
"name",
"description",
"mode",
"color",
"pair",
"used",
"to",
"draw",
"menu"
] | void printMenu(int mode) {
int row, col, i;
row = MAZE_START_ROW;
col = MAZE_START_COL + MAZE_WIDTH * 3 + 3;
attron(COLOR_PAIR(mode));
mvaddch(row, col, ACS_ULCORNER);
for(i = 0; i < MENU_WIDTH - 2; i++) {
addch(ACS_HLINE);
}
addch(ACS_URCORNER);
for(i = row + 1; i < MENU_HEIGHT; i++) {
mvaddch(i, col, ACS_VLINE);
mvaddch(i, col + MENU_WIDTH - 1, ACS_VLINE);
}
mvaddch(row + MENU_HEIGHT - 1, col, ACS_LLCORNER);
for(i = 0; i < MENU_WIDTH - 2; i++) {
addch(ACS_HLINE);
}
addch(ACS_LRCORNER);
mvprintw(row + 1, col + 1, "l Load maze");
mvprintw(row + 2, col + 1, "d Draw empty maze");
mvprintw(row + 3, col + 1, "a Disp array");
mvprintw(row + 4, col + 1, "i Init mouse");
mvprintw(row + 5, col + 1, "r Run mouse step");
mvprintw(row + 6, col + 1, "f Disp floodMaze");
mvprintw(row + 7, col + 1, "m Disp mouseMaze");
mvprintw(row + 8, col + 1, "c Clear maze");
attroff(COLOR_PAIR(mode));
} | [
"void",
"printMenu",
"(",
"int",
"mode",
")",
"{",
"int",
"row",
",",
"col",
",",
"i",
";",
"row",
"=",
"MAZE_START_ROW",
";",
"col",
"=",
"MAZE_START_COL",
"+",
"MAZE_WIDTH",
"*",
"3",
"+",
"3",
";",
"attron",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"mvaddch",
"(",
"row",
",",
"col",
",",
"ACS_ULCORNER",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MENU_WIDTH",
"-",
"2",
";",
"i",
"++",
")",
"{",
"addch",
"(",
"ACS_HLINE",
")",
";",
"}",
"addch",
"(",
"ACS_URCORNER",
")",
";",
"for",
"(",
"i",
"=",
"row",
"+",
"1",
";",
"i",
"<",
"MENU_HEIGHT",
";",
"i",
"++",
")",
"{",
"mvaddch",
"(",
"i",
",",
"col",
",",
"ACS_VLINE",
")",
";",
"mvaddch",
"(",
"i",
",",
"col",
"+",
"MENU_WIDTH",
"-",
"1",
",",
"ACS_VLINE",
")",
";",
"}",
"mvaddch",
"(",
"row",
"+",
"MENU_HEIGHT",
"-",
"1",
",",
"col",
",",
"ACS_LLCORNER",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MENU_WIDTH",
"-",
"2",
";",
"i",
"++",
")",
"{",
"addch",
"(",
"ACS_HLINE",
")",
";",
"}",
"addch",
"(",
"ACS_LRCORNER",
")",
";",
"mvprintw",
"(",
"row",
"+",
"1",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"mvprintw",
"(",
"row",
"+",
"2",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"mvprintw",
"(",
"row",
"+",
"3",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"mvprintw",
"(",
"row",
"+",
"4",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"mvprintw",
"(",
"row",
"+",
"5",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"mvprintw",
"(",
"row",
"+",
"6",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"mvprintw",
"(",
"row",
"+",
"7",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"mvprintw",
"(",
"row",
"+",
"8",
",",
"col",
"+",
"1",
",",
"\"",
"\"",
")",
";",
"attroff",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"}"
] | Routine Name: printMenu
File: sim.c | [
"Routine",
"Name",
":",
"printMenu",
"File",
":",
"sim",
".",
"c"
] | [
"//Print menu box",
"//Print menu"
] | [
{
"param": "mode",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | printMaze | void | void printMaze(int maze[MAZE_WIDTH][MAZE_WIDTH], int mode) {
int row, col;
attron(COLOR_PAIR(mode));
for(row = 0; row < MAZE_WIDTH; row++) {
move(row, 0);
for(col = 0; col < MAZE_WIDTH; col++)
printw("%x ", maze[row][col]);
}
attroff(COLOR_PAIR(mode));
} | /******************************************************************************
Routine Name: printMaze
File: sim.c
Description: Prints maze to screen using color pair specified.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
maze maze in array form to print
mode color pair to use
******************************************************************************/ | Routine Name: printMaze
File: sim.c
Prints maze to screen using color pair specified.
Parameter Descriptions:
name description
maze maze in array form to print
mode color pair to use | [
"Routine",
"Name",
":",
"printMaze",
"File",
":",
"sim",
".",
"c",
"Prints",
"maze",
"to",
"screen",
"using",
"color",
"pair",
"specified",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"maze",
"maze",
"in",
"array",
"form",
"to",
"print",
"mode",
"color",
"pair",
"to",
"use"
] | void printMaze(int maze[MAZE_WIDTH][MAZE_WIDTH], int mode) {
int row, col;
attron(COLOR_PAIR(mode));
for(row = 0; row < MAZE_WIDTH; row++) {
move(row, 0);
for(col = 0; col < MAZE_WIDTH; col++)
printw("%x ", maze[row][col]);
}
attroff(COLOR_PAIR(mode));
} | [
"void",
"printMaze",
"(",
"int",
"maze",
"[",
"MAZE_WIDTH",
"]",
"[",
"MAZE_WIDTH",
"]",
",",
"int",
"mode",
")",
"{",
"int",
"row",
",",
"col",
";",
"attron",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"MAZE_WIDTH",
";",
"row",
"++",
")",
"{",
"move",
"(",
"row",
",",
"0",
")",
";",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"printw",
"(",
"\"",
"\"",
",",
"maze",
"[",
"row",
"]",
"[",
"col",
"]",
")",
";",
"}",
"attroff",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"}"
] | Routine Name: printMaze
File: sim.c | [
"Routine",
"Name",
":",
"printMaze",
"File",
":",
"sim",
".",
"c"
] | [] | [
{
"param": "maze",
"type": "int"
},
{
"param": "mode",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "maze",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | drawTileWalls | void | void drawTileWalls(int xTile, int yTile, int walls, int mode) {
int xDraw, yDraw;
xDraw = MAZE_START_COL + xTile * 3 + 1;
yDraw = MAZE_START_ROW + yTile * 2 + 1;
attron(COLOR_PAIR(mode));
if((walls & LEFT_WALL) == LEFT_WALL) {
mvaddch(yDraw, xDraw - 1, ACS_VLINE);
}
if((walls & RIGHT_WALL) == RIGHT_WALL) {
mvaddch(yDraw, xDraw + 2, ACS_VLINE);
}
if((walls & UPPER_WALL) == UPPER_WALL) {
mvaddch(yDraw - 1, xDraw, ACS_HLINE);
addch(ACS_HLINE);
}
if((walls & LOWER_WALL) == LOWER_WALL) {
mvaddch(yDraw + 1, xDraw, ACS_HLINE);
addch(ACS_HLINE);
}
attroff(COLOR_PAIR(mode));
} | /******************************************************************************
Routine Name: drawTileWalls
File: sim.c
Description: Draws walls of specified color for tile at given coordinates
Parameter Descriptions:
name description
------------------ -----------------------------------------------
xTile x location of tile
yTile y location of tile
walls wall information
mode color pair to use
******************************************************************************/ | Routine Name: drawTileWalls
File: sim.c
Draws walls of specified color for tile at given coordinates
Parameter Descriptions:
name description
xTile x location of tile
yTile y location of tile
walls wall information
mode color pair to use | [
"Routine",
"Name",
":",
"drawTileWalls",
"File",
":",
"sim",
".",
"c",
"Draws",
"walls",
"of",
"specified",
"color",
"for",
"tile",
"at",
"given",
"coordinates",
"Parameter",
"Descriptions",
":",
"name",
"description",
"xTile",
"x",
"location",
"of",
"tile",
"yTile",
"y",
"location",
"of",
"tile",
"walls",
"wall",
"information",
"mode",
"color",
"pair",
"to",
"use"
] | void drawTileWalls(int xTile, int yTile, int walls, int mode) {
int xDraw, yDraw;
xDraw = MAZE_START_COL + xTile * 3 + 1;
yDraw = MAZE_START_ROW + yTile * 2 + 1;
attron(COLOR_PAIR(mode));
if((walls & LEFT_WALL) == LEFT_WALL) {
mvaddch(yDraw, xDraw - 1, ACS_VLINE);
}
if((walls & RIGHT_WALL) == RIGHT_WALL) {
mvaddch(yDraw, xDraw + 2, ACS_VLINE);
}
if((walls & UPPER_WALL) == UPPER_WALL) {
mvaddch(yDraw - 1, xDraw, ACS_HLINE);
addch(ACS_HLINE);
}
if((walls & LOWER_WALL) == LOWER_WALL) {
mvaddch(yDraw + 1, xDraw, ACS_HLINE);
addch(ACS_HLINE);
}
attroff(COLOR_PAIR(mode));
} | [
"void",
"drawTileWalls",
"(",
"int",
"xTile",
",",
"int",
"yTile",
",",
"int",
"walls",
",",
"int",
"mode",
")",
"{",
"int",
"xDraw",
",",
"yDraw",
";",
"xDraw",
"=",
"MAZE_START_COL",
"+",
"xTile",
"*",
"3",
"+",
"1",
";",
"yDraw",
"=",
"MAZE_START_ROW",
"+",
"yTile",
"*",
"2",
"+",
"1",
";",
"attron",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"if",
"(",
"(",
"walls",
"&",
"LEFT_WALL",
")",
"==",
"LEFT_WALL",
")",
"{",
"mvaddch",
"(",
"yDraw",
",",
"xDraw",
"-",
"1",
",",
"ACS_VLINE",
")",
";",
"}",
"if",
"(",
"(",
"walls",
"&",
"RIGHT_WALL",
")",
"==",
"RIGHT_WALL",
")",
"{",
"mvaddch",
"(",
"yDraw",
",",
"xDraw",
"+",
"2",
",",
"ACS_VLINE",
")",
";",
"}",
"if",
"(",
"(",
"walls",
"&",
"UPPER_WALL",
")",
"==",
"UPPER_WALL",
")",
"{",
"mvaddch",
"(",
"yDraw",
"-",
"1",
",",
"xDraw",
",",
"ACS_HLINE",
")",
";",
"addch",
"(",
"ACS_HLINE",
")",
";",
"}",
"if",
"(",
"(",
"walls",
"&",
"LOWER_WALL",
")",
"==",
"LOWER_WALL",
")",
"{",
"mvaddch",
"(",
"yDraw",
"+",
"1",
",",
"xDraw",
",",
"ACS_HLINE",
")",
";",
"addch",
"(",
"ACS_HLINE",
")",
";",
"}",
"attroff",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"}"
] | Routine Name: drawTileWalls
File: sim.c | [
"Routine",
"Name",
":",
"drawTileWalls",
"File",
":",
"sim",
".",
"c"
] | [] | [
{
"param": "xTile",
"type": "int"
},
{
"param": "yTile",
"type": "int"
},
{
"param": "walls",
"type": "int"
},
{
"param": "mode",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xTile",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "yTile",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "walls",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | drawMaze | void | void drawMaze(int type, int mode) {
int row, col;
attron(COLOR_PAIR(mode));
if(type == FULL) {
for(row = MAZE_START_ROW; row <= MAZE_START_ROW + MAZE_WIDTH * 2; row++) {
//move cursor to beginning of row
move(row, MAZE_START_COL);
if(row % 2 == 0)
for(col = 0; col < MAZE_WIDTH + 1; col++)
mvaddch(row, MAZE_START_COL + col * 3, ACS_VLINE);
else {
addch(ACS_BULLET);
for(col = 0; col < MAZE_WIDTH; col++) {
addch(ACS_HLINE);
addch(ACS_HLINE);
addch(ACS_BULLET);
}
}
}
}
else if(type == EMPTY) {
row = MAZE_START_ROW;
col = MAZE_START_COL;
for(row = MAZE_START_ROW; row <= MAZE_START_ROW + MAZE_WIDTH * 2; row++) {
if(row == MAZE_START_ROW || row == MAZE_START_ROW + MAZE_WIDTH * 2) {
move(row, MAZE_START_COL);
addch(ACS_BULLET);
for(col = 0; col < MAZE_WIDTH; col++) {
addch(ACS_HLINE);
addch(ACS_HLINE);
addch(ACS_BULLET);
}
}
else if(row % 2 == 0) {
mvaddch(row, MAZE_START_COL, ACS_VLINE);
mvaddch(row, MAZE_START_COL + MAZE_WIDTH * 3, ACS_VLINE);
}
else {
for(col = 0; col <= MAZE_WIDTH; col++) {
mvaddch(row, MAZE_START_COL + col * 3, ACS_BULLET);
}
}
}
}
attroff(COLOR_PAIR(mode));
} | /******************************************************************************
Routine Name: drawMaze
File: sim.c
Description: Draws either full or empty maze
Parameter Descriptions:
name description
------------------ -----------------------------------------------
type full or empty
mode color pair to use
******************************************************************************/ | Routine Name: drawMaze
File: sim.c
Draws either full or empty maze
Parameter Descriptions:
name description
type full or empty
mode color pair to use | [
"Routine",
"Name",
":",
"drawMaze",
"File",
":",
"sim",
".",
"c",
"Draws",
"either",
"full",
"or",
"empty",
"maze",
"Parameter",
"Descriptions",
":",
"name",
"description",
"type",
"full",
"or",
"empty",
"mode",
"color",
"pair",
"to",
"use"
] | void drawMaze(int type, int mode) {
int row, col;
attron(COLOR_PAIR(mode));
if(type == FULL) {
for(row = MAZE_START_ROW; row <= MAZE_START_ROW + MAZE_WIDTH * 2; row++) {
move(row, MAZE_START_COL);
if(row % 2 == 0)
for(col = 0; col < MAZE_WIDTH + 1; col++)
mvaddch(row, MAZE_START_COL + col * 3, ACS_VLINE);
else {
addch(ACS_BULLET);
for(col = 0; col < MAZE_WIDTH; col++) {
addch(ACS_HLINE);
addch(ACS_HLINE);
addch(ACS_BULLET);
}
}
}
}
else if(type == EMPTY) {
row = MAZE_START_ROW;
col = MAZE_START_COL;
for(row = MAZE_START_ROW; row <= MAZE_START_ROW + MAZE_WIDTH * 2; row++) {
if(row == MAZE_START_ROW || row == MAZE_START_ROW + MAZE_WIDTH * 2) {
move(row, MAZE_START_COL);
addch(ACS_BULLET);
for(col = 0; col < MAZE_WIDTH; col++) {
addch(ACS_HLINE);
addch(ACS_HLINE);
addch(ACS_BULLET);
}
}
else if(row % 2 == 0) {
mvaddch(row, MAZE_START_COL, ACS_VLINE);
mvaddch(row, MAZE_START_COL + MAZE_WIDTH * 3, ACS_VLINE);
}
else {
for(col = 0; col <= MAZE_WIDTH; col++) {
mvaddch(row, MAZE_START_COL + col * 3, ACS_BULLET);
}
}
}
}
attroff(COLOR_PAIR(mode));
} | [
"void",
"drawMaze",
"(",
"int",
"type",
",",
"int",
"mode",
")",
"{",
"int",
"row",
",",
"col",
";",
"attron",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"if",
"(",
"type",
"==",
"FULL",
")",
"{",
"for",
"(",
"row",
"=",
"MAZE_START_ROW",
";",
"row",
"<=",
"MAZE_START_ROW",
"+",
"MAZE_WIDTH",
"*",
"2",
";",
"row",
"++",
")",
"{",
"move",
"(",
"row",
",",
"MAZE_START_COL",
")",
";",
"if",
"(",
"row",
"%",
"2",
"==",
"0",
")",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
"+",
"1",
";",
"col",
"++",
")",
"mvaddch",
"(",
"row",
",",
"MAZE_START_COL",
"+",
"col",
"*",
"3",
",",
"ACS_VLINE",
")",
";",
"else",
"{",
"addch",
"(",
"ACS_BULLET",
")",
";",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"{",
"addch",
"(",
"ACS_HLINE",
")",
";",
"addch",
"(",
"ACS_HLINE",
")",
";",
"addch",
"(",
"ACS_BULLET",
")",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"type",
"==",
"EMPTY",
")",
"{",
"row",
"=",
"MAZE_START_ROW",
";",
"col",
"=",
"MAZE_START_COL",
";",
"for",
"(",
"row",
"=",
"MAZE_START_ROW",
";",
"row",
"<=",
"MAZE_START_ROW",
"+",
"MAZE_WIDTH",
"*",
"2",
";",
"row",
"++",
")",
"{",
"if",
"(",
"row",
"==",
"MAZE_START_ROW",
"||",
"row",
"==",
"MAZE_START_ROW",
"+",
"MAZE_WIDTH",
"*",
"2",
")",
"{",
"move",
"(",
"row",
",",
"MAZE_START_COL",
")",
";",
"addch",
"(",
"ACS_BULLET",
")",
";",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"{",
"addch",
"(",
"ACS_HLINE",
")",
";",
"addch",
"(",
"ACS_HLINE",
")",
";",
"addch",
"(",
"ACS_BULLET",
")",
";",
"}",
"}",
"else",
"if",
"(",
"row",
"%",
"2",
"==",
"0",
")",
"{",
"mvaddch",
"(",
"row",
",",
"MAZE_START_COL",
",",
"ACS_VLINE",
")",
";",
"mvaddch",
"(",
"row",
",",
"MAZE_START_COL",
"+",
"MAZE_WIDTH",
"*",
"3",
",",
"ACS_VLINE",
")",
";",
"}",
"else",
"{",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<=",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"{",
"mvaddch",
"(",
"row",
",",
"MAZE_START_COL",
"+",
"col",
"*",
"3",
",",
"ACS_BULLET",
")",
";",
"}",
"}",
"}",
"}",
"attroff",
"(",
"COLOR_PAIR",
"(",
"mode",
")",
")",
";",
"}"
] | Routine Name: drawMaze
File: sim.c | [
"Routine",
"Name",
":",
"drawMaze",
"File",
":",
"sim",
".",
"c"
] | [
"//move cursor to beginning of row"
] | [
{
"param": "type",
"type": "int"
},
{
"param": "mode",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "type",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af245106515024bee80915f8f8f5a12673f7a67c | ThisChessPlayer/Micromouse | sim.c | [
"MIT"
] | C | initMaze | void | void initMaze(int maze[MAZE_WIDTH][MAZE_WIDTH], char * mazeStr) {
FILE * mazeFile;
int row, col, wall;
mazeFile = fopen(mazeStr, "r+");
for(row = 0; row < MAZE_WIDTH; row++) {
for(col = 0; col < MAZE_WIDTH; col++) {
fscanf(mazeFile, "%d", &wall);
maze[row][col] = wall;
}
}
fclose(mazeFile);
} | /******************************************************************************
Routine Name: initMaze
File: sim.c
Description: Initializes maze with file containing wall information
Parameter Descriptions:
name description
------------------ -----------------------------------------------
maze array to fill
mazeStr file containing wall info
******************************************************************************/ | Routine Name: initMaze
File: sim.c
Initializes maze with file containing wall information
Parameter Descriptions:
name description
maze array to fill
mazeStr file containing wall info | [
"Routine",
"Name",
":",
"initMaze",
"File",
":",
"sim",
".",
"c",
"Initializes",
"maze",
"with",
"file",
"containing",
"wall",
"information",
"Parameter",
"Descriptions",
":",
"name",
"description",
"maze",
"array",
"to",
"fill",
"mazeStr",
"file",
"containing",
"wall",
"info"
] | void initMaze(int maze[MAZE_WIDTH][MAZE_WIDTH], char * mazeStr) {
FILE * mazeFile;
int row, col, wall;
mazeFile = fopen(mazeStr, "r+");
for(row = 0; row < MAZE_WIDTH; row++) {
for(col = 0; col < MAZE_WIDTH; col++) {
fscanf(mazeFile, "%d", &wall);
maze[row][col] = wall;
}
}
fclose(mazeFile);
} | [
"void",
"initMaze",
"(",
"int",
"maze",
"[",
"MAZE_WIDTH",
"]",
"[",
"MAZE_WIDTH",
"]",
",",
"char",
"*",
"mazeStr",
")",
"{",
"FILE",
"*",
"mazeFile",
";",
"int",
"row",
",",
"col",
",",
"wall",
";",
"mazeFile",
"=",
"fopen",
"(",
"mazeStr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"MAZE_WIDTH",
";",
"row",
"++",
")",
"{",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"{",
"fscanf",
"(",
"mazeFile",
",",
"\"",
"\"",
",",
"&",
"wall",
")",
";",
"maze",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"wall",
";",
"}",
"}",
"fclose",
"(",
"mazeFile",
")",
";",
"}"
] | Routine Name: initMaze
File: sim.c | [
"Routine",
"Name",
":",
"initMaze",
"File",
":",
"sim",
".",
"c"
] | [] | [
{
"param": "maze",
"type": "int"
},
{
"param": "mazeStr",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "maze",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mazeStr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | initMouse | void | void initMouse(int startRow, int startCol) {
int row, col;
curRow = startRow;
curCol = startCol;
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++) {
mouseMaze[row][col] = 0;
floodMaze[row][col] = MAZE_WIDTH * MAZE_WIDTH - 1;
}
queueTop = 0;
} | /******************************************************************************
Routine Name: initMouse
File: mouse.c
Description: Initializes mouse with the starting location
Parameter Descriptions:
name description
------------------ -----------------------------------------------
startRow mouse start row
startCol mouse start column
******************************************************************************/ | Routine Name: initMouse
File: mouse.c
Initializes mouse with the starting location
Parameter Descriptions:
name description
startRow mouse start row
startCol mouse start column | [
"Routine",
"Name",
":",
"initMouse",
"File",
":",
"mouse",
".",
"c",
"Initializes",
"mouse",
"with",
"the",
"starting",
"location",
"Parameter",
"Descriptions",
":",
"name",
"description",
"startRow",
"mouse",
"start",
"row",
"startCol",
"mouse",
"start",
"column"
] | void initMouse(int startRow, int startCol) {
int row, col;
curRow = startRow;
curCol = startCol;
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++) {
mouseMaze[row][col] = 0;
floodMaze[row][col] = MAZE_WIDTH * MAZE_WIDTH - 1;
}
queueTop = 0;
} | [
"void",
"initMouse",
"(",
"int",
"startRow",
",",
"int",
"startCol",
")",
"{",
"int",
"row",
",",
"col",
";",
"curRow",
"=",
"startRow",
";",
"curCol",
"=",
"startCol",
";",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"MAZE_WIDTH",
";",
"row",
"++",
")",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"{",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"0",
";",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"MAZE_WIDTH",
"*",
"MAZE_WIDTH",
"-",
"1",
";",
"}",
"queueTop",
"=",
"0",
";",
"}"
] | Routine Name: initMouse
File: mouse.c | [
"Routine",
"Name",
":",
"initMouse",
"File",
":",
"mouse",
".",
"c"
] | [] | [
{
"param": "startRow",
"type": "int"
},
{
"param": "startCol",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "startRow",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "startCol",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | mapMaze | void | void mapMaze(int targetRow, int targetCol, int mode) {
int curLoc;
//read wall info
//floodfill
//move
int atDest;
destRow = targetRow;
destCol = targetCol;
floodFill(0, targetRow, targetCol);
do{
curLoc = mouseMaze[curRow][curCol];
scanWalls(curRow, curCol);
//if(curLoc != mouseMaze[curRow][curCol]) {
//updateFlood(curRow, curCol);
//floodFromQueue();
validateFlood(curRow, curCol);
//}
mouseMove(FLOOD, 0, 0);
//closeBoxes();
if(mode == STEP)
return;
atDest = atLoc(targetRow, targetCol);
}while(atDest == 0);
} | /******************************************************************************
Routine Name: mapMaze
File: mouse.c
Description: Traverse through maze until at target location.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
targetRow target location row
targetCol target location column
mode if step, only takes one step
******************************************************************************/ | Routine Name: mapMaze
File: mouse.c
Traverse through maze until at target location.
Parameter Descriptions:
name description
targetRow target location row
targetCol target location column
mode if step, only takes one step | [
"Routine",
"Name",
":",
"mapMaze",
"File",
":",
"mouse",
".",
"c",
"Traverse",
"through",
"maze",
"until",
"at",
"target",
"location",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"targetRow",
"target",
"location",
"row",
"targetCol",
"target",
"location",
"column",
"mode",
"if",
"step",
"only",
"takes",
"one",
"step"
] | void mapMaze(int targetRow, int targetCol, int mode) {
int curLoc;
int atDest;
destRow = targetRow;
destCol = targetCol;
floodFill(0, targetRow, targetCol);
do{
curLoc = mouseMaze[curRow][curCol];
scanWalls(curRow, curCol);
validateFlood(curRow, curCol);
mouseMove(FLOOD, 0, 0);
if(mode == STEP)
return;
atDest = atLoc(targetRow, targetCol);
}while(atDest == 0);
} | [
"void",
"mapMaze",
"(",
"int",
"targetRow",
",",
"int",
"targetCol",
",",
"int",
"mode",
")",
"{",
"int",
"curLoc",
";",
"int",
"atDest",
";",
"destRow",
"=",
"targetRow",
";",
"destCol",
"=",
"targetCol",
";",
"floodFill",
"(",
"0",
",",
"targetRow",
",",
"targetCol",
")",
";",
"do",
"{",
"curLoc",
"=",
"mouseMaze",
"[",
"curRow",
"]",
"[",
"curCol",
"]",
";",
"scanWalls",
"(",
"curRow",
",",
"curCol",
")",
";",
"validateFlood",
"(",
"curRow",
",",
"curCol",
")",
";",
"mouseMove",
"(",
"FLOOD",
",",
"0",
",",
"0",
")",
";",
"if",
"(",
"mode",
"==",
"STEP",
")",
"return",
";",
"atDest",
"=",
"atLoc",
"(",
"targetRow",
",",
"targetCol",
")",
";",
"}",
"while",
"(",
"atDest",
"==",
"0",
")",
";",
"}"
] | Routine Name: mapMaze
File: mouse.c | [
"Routine",
"Name",
":",
"mapMaze",
"File",
":",
"mouse",
".",
"c"
] | [
"//read wall info",
"//floodfill",
"//move",
"//if(curLoc != mouseMaze[curRow][curCol]) {",
"//updateFlood(curRow, curCol);",
"//floodFromQueue();",
"//}",
"//closeBoxes();"
] | [
{
"param": "targetRow",
"type": "int"
},
{
"param": "targetCol",
"type": "int"
},
{
"param": "mode",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "targetRow",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "targetCol",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | atLoc | int | int atLoc(int row, int col) {
if(curRow == row && curCol == col)
return 1;
return 0;
} | /******************************************************************************
Routine Name: atLoc
File: mouse.c
Description: Returns 1 (true) if mouse is at location specified
Parameter Descriptions:
name description
------------------ -----------------------------------------------
row target location row
col target location column
******************************************************************************/ | Routine Name: atLoc
File: mouse.c
Returns 1 (true) if mouse is at location specified
Parameter Descriptions:
name description
row target location row
col target location column | [
"Routine",
"Name",
":",
"atLoc",
"File",
":",
"mouse",
".",
"c",
"Returns",
"1",
"(",
"true",
")",
"if",
"mouse",
"is",
"at",
"location",
"specified",
"Parameter",
"Descriptions",
":",
"name",
"description",
"row",
"target",
"location",
"row",
"col",
"target",
"location",
"column"
] | int atLoc(int row, int col) {
if(curRow == row && curCol == col)
return 1;
return 0;
} | [
"int",
"atLoc",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"if",
"(",
"curRow",
"==",
"row",
"&&",
"curCol",
"==",
"col",
")",
"return",
"1",
";",
"return",
"0",
";",
"}"
] | Routine Name: atLoc
File: mouse.c | [
"Routine",
"Name",
":",
"atLoc",
"File",
":",
"mouse",
".",
"c"
] | [] | [
{
"param": "row",
"type": "int"
},
{
"param": "col",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | scanWalls | void | void scanWalls(int row, int col) {
int actualWall;
actualWall = getActualMaze(row, col);
if(actualWall & LEFT_WALL && (mouseMaze[row][col] & LEFT_WALL) == 0) {
mouseMaze[row][col] |= LEFT_WALL;
if(col > 0)
mouseMaze[row][col - 1] |= RIGHT_WALL;
}
if(actualWall & RIGHT_WALL && (mouseMaze[row][col] & RIGHT_WALL) == 0) {
mouseMaze[row][col] |= RIGHT_WALL;
if(col < MAZE_WIDTH - 1)
mouseMaze[row][col + 1] |= LEFT_WALL;
}
if(actualWall & UPPER_WALL && (mouseMaze[row][col] & UPPER_WALL) == 0) {
mouseMaze[row][col] |= UPPER_WALL;
if(row > 0)
mouseMaze[row - 1][col] |= LOWER_WALL;
}
if(actualWall & LOWER_WALL && (mouseMaze[row][col] & LOWER_WALL) == 0) {
mouseMaze[row][col] |= LOWER_WALL;
if(row < MAZE_WIDTH - 1)
mouseMaze[row + 1][col] |= UPPER_WALL;
}
} | /******************************************************************************
Routine Name: scanWalls
File: mouse.c
Description: References actual maze for wall information, and updates mouse's
memory with appropriate walls.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
row row of tile to update
col column of tile to update
******************************************************************************/ | Routine Name: scanWalls
File: mouse.c
References actual maze for wall information, and updates mouse's
memory with appropriate walls.
Parameter Descriptions:
name description
row row of tile to update
col column of tile to update | [
"Routine",
"Name",
":",
"scanWalls",
"File",
":",
"mouse",
".",
"c",
"References",
"actual",
"maze",
"for",
"wall",
"information",
"and",
"updates",
"mouse",
"'",
"s",
"memory",
"with",
"appropriate",
"walls",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"row",
"row",
"of",
"tile",
"to",
"update",
"col",
"column",
"of",
"tile",
"to",
"update"
] | void scanWalls(int row, int col) {
int actualWall;
actualWall = getActualMaze(row, col);
if(actualWall & LEFT_WALL && (mouseMaze[row][col] & LEFT_WALL) == 0) {
mouseMaze[row][col] |= LEFT_WALL;
if(col > 0)
mouseMaze[row][col - 1] |= RIGHT_WALL;
}
if(actualWall & RIGHT_WALL && (mouseMaze[row][col] & RIGHT_WALL) == 0) {
mouseMaze[row][col] |= RIGHT_WALL;
if(col < MAZE_WIDTH - 1)
mouseMaze[row][col + 1] |= LEFT_WALL;
}
if(actualWall & UPPER_WALL && (mouseMaze[row][col] & UPPER_WALL) == 0) {
mouseMaze[row][col] |= UPPER_WALL;
if(row > 0)
mouseMaze[row - 1][col] |= LOWER_WALL;
}
if(actualWall & LOWER_WALL && (mouseMaze[row][col] & LOWER_WALL) == 0) {
mouseMaze[row][col] |= LOWER_WALL;
if(row < MAZE_WIDTH - 1)
mouseMaze[row + 1][col] |= UPPER_WALL;
}
} | [
"void",
"scanWalls",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"int",
"actualWall",
";",
"actualWall",
"=",
"getActualMaze",
"(",
"row",
",",
"col",
")",
";",
"if",
"(",
"actualWall",
"&",
"LEFT_WALL",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LEFT_WALL",
")",
"==",
"0",
")",
"{",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"LEFT_WALL",
";",
"if",
"(",
"col",
">",
"0",
")",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
"|=",
"RIGHT_WALL",
";",
"}",
"if",
"(",
"actualWall",
"&",
"RIGHT_WALL",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"RIGHT_WALL",
")",
"==",
"0",
")",
"{",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"RIGHT_WALL",
";",
"if",
"(",
"col",
"<",
"MAZE_WIDTH",
"-",
"1",
")",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
"|=",
"LEFT_WALL",
";",
"}",
"if",
"(",
"actualWall",
"&",
"UPPER_WALL",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"UPPER_WALL",
")",
"==",
"0",
")",
"{",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"UPPER_WALL",
";",
"if",
"(",
"row",
">",
"0",
")",
"mouseMaze",
"[",
"row",
"-",
"1",
"]",
"[",
"col",
"]",
"|=",
"LOWER_WALL",
";",
"}",
"if",
"(",
"actualWall",
"&",
"LOWER_WALL",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LOWER_WALL",
")",
"==",
"0",
")",
"{",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"LOWER_WALL",
";",
"if",
"(",
"row",
"<",
"MAZE_WIDTH",
"-",
"1",
")",
"mouseMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
"|=",
"UPPER_WALL",
";",
"}",
"}"
] | Routine Name: scanWalls
File: mouse.c | [
"Routine",
"Name",
":",
"scanWalls",
"File",
":",
"mouse",
".",
"c"
] | [] | [
{
"param": "row",
"type": "int"
},
{
"param": "col",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | updateFlood | void | void updateFlood(int row, int col) {
int lower, higher, nonNeighbor;
//search for lower neighbors that this tile depends on
lower = findLowerNeighbor(row, col);
//found at least 1 lower neighbor
if(lower != 0) {
//add self to flood queue
floodQueue[queueTop][0] = row;
floodQueue[queueTop][1] = col;
queueTop++;
}
else {
//find all higher flood value neighbors
higher = lower ^ (mouseMaze[row][col] & WALLS);
//reset current tile flood
floodMaze[row][col] = MAZE_WIDTH * MAZE_WIDTH - 1;
//for each higher flood neighbor, recursively update flooding
if((higher & LEFT) != LEFT)
updateFlood(row, col - 1);
if((higher & UP) != UP)
updateFlood(row - 1, col);
if((higher & RIGHT) != RIGHT)
updateFlood(row, col + 1);
if((higher & DOWN) != DOWN)
updateFlood(row + 1, col);
/*
if((lower & LEFT) != LEFT)
updateFlood(row, col - 1);
if((lower & UP) != UP)
updateFlood(row - 1, col);
if((lower & RIGHT) != RIGHT)
updateFlood(row, col + 1);
if((lower & DOWN) != DOWN)
updateFlood(row + 1, col);
*/
/*
nonNeighbor = (lower | higher) ^ WALLS;
if(nonNeighbor != 0) {
}
*/
}
//update non-neighbor tiles that depended on this tile
/*
if() {
if(floodMaze[row - 1][col] > floodMaze[row][col])
updateFlood(row - 1, col);
if(floodMaze[row + 1][col] > floodMaze[row][col])
updateFlood(row + 1, col);
if(floodMaze[row][col - 1] > floodMaze[row][col])
updateFlood(row, col - 1);
if(floodMaze[row][col + 1] > floodMaze[row][col])
updateFlood(row, col + 1);
}
*/
} | /******************************************************************************
Routine Name: updateFlood
File: mouse.c
Description: Updates floodfill maze starting from specified tile
Parameter Descriptions:
name description
------------------ -----------------------------------------------
row row of tile to start from
col column of tile to start from
******************************************************************************/ | Routine Name: updateFlood
File: mouse.c
Updates floodfill maze starting from specified tile
Parameter Descriptions:
name description
row row of tile to start from
col column of tile to start from | [
"Routine",
"Name",
":",
"updateFlood",
"File",
":",
"mouse",
".",
"c",
"Updates",
"floodfill",
"maze",
"starting",
"from",
"specified",
"tile",
"Parameter",
"Descriptions",
":",
"name",
"description",
"row",
"row",
"of",
"tile",
"to",
"start",
"from",
"col",
"column",
"of",
"tile",
"to",
"start",
"from"
] | void updateFlood(int row, int col) {
int lower, higher, nonNeighbor;
lower = findLowerNeighbor(row, col);
if(lower != 0) {
floodQueue[queueTop][0] = row;
floodQueue[queueTop][1] = col;
queueTop++;
}
else {
higher = lower ^ (mouseMaze[row][col] & WALLS);
floodMaze[row][col] = MAZE_WIDTH * MAZE_WIDTH - 1;
if((higher & LEFT) != LEFT)
updateFlood(row, col - 1);
if((higher & UP) != UP)
updateFlood(row - 1, col);
if((higher & RIGHT) != RIGHT)
updateFlood(row, col + 1);
if((higher & DOWN) != DOWN)
updateFlood(row + 1, col);
}
} | [
"void",
"updateFlood",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"int",
"lower",
",",
"higher",
",",
"nonNeighbor",
";",
"lower",
"=",
"findLowerNeighbor",
"(",
"row",
",",
"col",
")",
";",
"if",
"(",
"lower",
"!=",
"0",
")",
"{",
"floodQueue",
"[",
"queueTop",
"]",
"[",
"0",
"]",
"=",
"row",
";",
"floodQueue",
"[",
"queueTop",
"]",
"[",
"1",
"]",
"=",
"col",
";",
"queueTop",
"++",
";",
"}",
"else",
"{",
"higher",
"=",
"lower",
"^",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"WALLS",
")",
";",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"MAZE_WIDTH",
"*",
"MAZE_WIDTH",
"-",
"1",
";",
"if",
"(",
"(",
"higher",
"&",
"LEFT",
")",
"!=",
"LEFT",
")",
"updateFlood",
"(",
"row",
",",
"col",
"-",
"1",
")",
";",
"if",
"(",
"(",
"higher",
"&",
"UP",
")",
"!=",
"UP",
")",
"updateFlood",
"(",
"row",
"-",
"1",
",",
"col",
")",
";",
"if",
"(",
"(",
"higher",
"&",
"RIGHT",
")",
"!=",
"RIGHT",
")",
"updateFlood",
"(",
"row",
",",
"col",
"+",
"1",
")",
";",
"if",
"(",
"(",
"higher",
"&",
"DOWN",
")",
"!=",
"DOWN",
")",
"updateFlood",
"(",
"row",
"+",
"1",
",",
"col",
")",
";",
"}",
"}"
] | Routine Name: updateFlood
File: mouse.c | [
"Routine",
"Name",
":",
"updateFlood",
"File",
":",
"mouse",
".",
"c"
] | [
"//search for lower neighbors that this tile depends on",
"//found at least 1 lower neighbor",
"//add self to flood queue",
"//find all higher flood value neighbors",
"//reset current tile flood",
"//for each higher flood neighbor, recursively update flooding",
"/*\n if((lower & LEFT) != LEFT)\n updateFlood(row, col - 1);\n if((lower & UP) != UP)\n updateFlood(row - 1, col);\n if((lower & RIGHT) != RIGHT)\n updateFlood(row, col + 1);\n if((lower & DOWN) != DOWN)\n updateFlood(row + 1, col);\n */",
"/*\n nonNeighbor = (lower | higher) ^ WALLS;\n \n if(nonNeighbor != 0) {\n \n }\n */",
"//update non-neighbor tiles that depended on this tile",
"/*\n if() {\n if(floodMaze[row - 1][col] > floodMaze[row][col])\n updateFlood(row - 1, col);\n if(floodMaze[row + 1][col] > floodMaze[row][col])\n updateFlood(row + 1, col);\n if(floodMaze[row][col - 1] > floodMaze[row][col])\n updateFlood(row, col - 1);\n if(floodMaze[row][col + 1] > floodMaze[row][col])\n updateFlood(row, col + 1);\n }\n */"
] | [
{
"param": "row",
"type": "int"
},
{
"param": "col",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | floodFromQueue | void | void floodFromQueue() {
//for each value in array, flood from location
int i;
for(i = 0; i < queueTop; i++) {
floodFill(floodMaze[floodQueue[i][0]][floodQueue[i][1]], floodQueue[i][0], floodQueue[i][1]);
}
queueTop = 0;
} | /******************************************************************************
Routine Name: floodFromQueue
File: mouse.c
Description: Starts a floodfill update from each value in floodQueue
******************************************************************************/ | Routine Name: floodFromQueue
File: mouse.c
Starts a floodfill update from each value in floodQueue | [
"Routine",
"Name",
":",
"floodFromQueue",
"File",
":",
"mouse",
".",
"c",
"Starts",
"a",
"floodfill",
"update",
"from",
"each",
"value",
"in",
"floodQueue"
] | void floodFromQueue() {
int i;
for(i = 0; i < queueTop; i++) {
floodFill(floodMaze[floodQueue[i][0]][floodQueue[i][1]], floodQueue[i][0], floodQueue[i][1]);
}
queueTop = 0;
} | [
"void",
"floodFromQueue",
"(",
")",
"{",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"queueTop",
";",
"i",
"++",
")",
"{",
"floodFill",
"(",
"floodMaze",
"[",
"floodQueue",
"[",
"i",
"]",
"[",
"0",
"]",
"]",
"[",
"floodQueue",
"[",
"i",
"]",
"[",
"1",
"]",
"]",
",",
"floodQueue",
"[",
"i",
"]",
"[",
"0",
"]",
",",
"floodQueue",
"[",
"i",
"]",
"[",
"1",
"]",
")",
";",
"}",
"queueTop",
"=",
"0",
";",
"}"
] | Routine Name: floodFromQueue
File: mouse.c | [
"Routine",
"Name",
":",
"floodFromQueue",
"File",
":",
"mouse",
".",
"c"
] | [
"//for each value in array, flood from location"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | validateFlood | void | void validateFlood(int row, int col) {
int lower, lowest;
if(row == destRow && col == destCol)
return;
//find all neighbors with lower values
lower = findLowerNeighbor(row, col);
/*
if((lower & UP) == UP && floodMaze[row - 1][col] == num - 1)
return;
if((lower & DOWN) == DOWN && floodMaze[row + 1][col] == num - 1)
return;
if((lower & LEFT) == LEFT && floodMaze[row][col - 1] == num - 1)
return;
if((lower & RIGHT) == RIGHT && floodMaze[row][col + 1] == num - 1)
return;
*/
//determine lowest flood value of neighbors
lowest = 255;
if(row > 0 && (mouseMaze[row][col] & UPPER_WALL) != UPPER_WALL)
lowest = floodMaze[row - 1][col];
if(row < MAZE_WIDTH - 1 && (mouseMaze[row][col] & LOWER_WALL) != LOWER_WALL && floodMaze[row + 1][col] < lowest)
lowest = floodMaze[row + 1][col];
if(col > 0 && (mouseMaze[row][col] & LEFT_WALL) != LEFT_WALL && floodMaze[row][col - 1] < lowest)
lowest = floodMaze[row][col - 1];
if(col < MAZE_WIDTH - 1 && (mouseMaze[row][col] & RIGHT_WALL) != RIGHT_WALL && floodMaze[row][col + 1] < lowest)
lowest = floodMaze[row][col + 1];
//if value is valid, do nothing
if(floodMaze[row][col] == lowest + 1)
return;
//otherwise, make value valid
floodMaze[row][col] = lowest + 1;
if(row > 0)
validateFlood(row - 1, col);
if(row < MAZE_WIDTH - 1)
validateFlood(row + 1, col);
if(col > 0)
validateFlood(row, col - 1);
if(col < MAZE_WIDTH - 1)
validateFlood(row, col + 1);
/*
if(row > 0 && (mouseMaze[row][col] & UPPER_WALL) != UPPER_WALL)
validateFlood(row - 1, col);
if(row < MAZE_WIDTH - 1 && (mouseMaze[row][col] & LOWER_WALL) != LOWER_WALL)
validateFlood(row + 1, col);
if(col > 0 && (mouseMaze[row][col] & LEFT_WALL) != LEFT_WALL)
validateFlood(row, col - 1);
if(col < MAZE_WIDTH - 1 && (mouseMaze[row][col] & RIGHT_WALL) != RIGHT_WALL)
validateFlood(row, col + 1);
*/
} | /******************************************************************************
Routine Name: validateFlood
File: mouse.c
Description: Ensures that the flood at a particular tile is valid. If not, it
validates the tile and validates its neighbors.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
row row of tile to validate
col column of tile to validate
******************************************************************************/ | Routine Name: validateFlood
File: mouse.c
Ensures that the flood at a particular tile is valid. If not, it
validates the tile and validates its neighbors.
Parameter Descriptions:
name description
row row of tile to validate
col column of tile to validate | [
"Routine",
"Name",
":",
"validateFlood",
"File",
":",
"mouse",
".",
"c",
"Ensures",
"that",
"the",
"flood",
"at",
"a",
"particular",
"tile",
"is",
"valid",
".",
"If",
"not",
"it",
"validates",
"the",
"tile",
"and",
"validates",
"its",
"neighbors",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"row",
"row",
"of",
"tile",
"to",
"validate",
"col",
"column",
"of",
"tile",
"to",
"validate"
] | void validateFlood(int row, int col) {
int lower, lowest;
if(row == destRow && col == destCol)
return;
lower = findLowerNeighbor(row, col);
lowest = 255;
if(row > 0 && (mouseMaze[row][col] & UPPER_WALL) != UPPER_WALL)
lowest = floodMaze[row - 1][col];
if(row < MAZE_WIDTH - 1 && (mouseMaze[row][col] & LOWER_WALL) != LOWER_WALL && floodMaze[row + 1][col] < lowest)
lowest = floodMaze[row + 1][col];
if(col > 0 && (mouseMaze[row][col] & LEFT_WALL) != LEFT_WALL && floodMaze[row][col - 1] < lowest)
lowest = floodMaze[row][col - 1];
if(col < MAZE_WIDTH - 1 && (mouseMaze[row][col] & RIGHT_WALL) != RIGHT_WALL && floodMaze[row][col + 1] < lowest)
lowest = floodMaze[row][col + 1];
if(floodMaze[row][col] == lowest + 1)
return;
floodMaze[row][col] = lowest + 1;
if(row > 0)
validateFlood(row - 1, col);
if(row < MAZE_WIDTH - 1)
validateFlood(row + 1, col);
if(col > 0)
validateFlood(row, col - 1);
if(col < MAZE_WIDTH - 1)
validateFlood(row, col + 1);
} | [
"void",
"validateFlood",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"int",
"lower",
",",
"lowest",
";",
"if",
"(",
"row",
"==",
"destRow",
"&&",
"col",
"==",
"destCol",
")",
"return",
";",
"lower",
"=",
"findLowerNeighbor",
"(",
"row",
",",
"col",
")",
";",
"lowest",
"=",
"255",
";",
"if",
"(",
"row",
">",
"0",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"UPPER_WALL",
")",
"!=",
"UPPER_WALL",
")",
"lowest",
"=",
"floodMaze",
"[",
"row",
"-",
"1",
"]",
"[",
"col",
"]",
";",
"if",
"(",
"row",
"<",
"MAZE_WIDTH",
"-",
"1",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LOWER_WALL",
")",
"!=",
"LOWER_WALL",
"&&",
"floodMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
"<",
"lowest",
")",
"lowest",
"=",
"floodMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
";",
"if",
"(",
"col",
">",
"0",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LEFT_WALL",
")",
"!=",
"LEFT_WALL",
"&&",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
"<",
"lowest",
")",
"lowest",
"=",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
";",
"if",
"(",
"col",
"<",
"MAZE_WIDTH",
"-",
"1",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"RIGHT_WALL",
")",
"!=",
"RIGHT_WALL",
"&&",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
"<",
"lowest",
")",
"lowest",
"=",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
";",
"if",
"(",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"==",
"lowest",
"+",
"1",
")",
"return",
";",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"lowest",
"+",
"1",
";",
"if",
"(",
"row",
">",
"0",
")",
"validateFlood",
"(",
"row",
"-",
"1",
",",
"col",
")",
";",
"if",
"(",
"row",
"<",
"MAZE_WIDTH",
"-",
"1",
")",
"validateFlood",
"(",
"row",
"+",
"1",
",",
"col",
")",
";",
"if",
"(",
"col",
">",
"0",
")",
"validateFlood",
"(",
"row",
",",
"col",
"-",
"1",
")",
";",
"if",
"(",
"col",
"<",
"MAZE_WIDTH",
"-",
"1",
")",
"validateFlood",
"(",
"row",
",",
"col",
"+",
"1",
")",
";",
"}"
] | Routine Name: validateFlood
File: mouse.c | [
"Routine",
"Name",
":",
"validateFlood",
"File",
":",
"mouse",
".",
"c"
] | [
"//find all neighbors with lower values",
"/*\n if((lower & UP) == UP && floodMaze[row - 1][col] == num - 1)\n return;\n if((lower & DOWN) == DOWN && floodMaze[row + 1][col] == num - 1)\n return;\n if((lower & LEFT) == LEFT && floodMaze[row][col - 1] == num - 1)\n return;\n if((lower & RIGHT) == RIGHT && floodMaze[row][col + 1] == num - 1)\n return;\n */",
"//determine lowest flood value of neighbors",
"//if value is valid, do nothing",
"//otherwise, make value valid",
"/*\n if(row > 0 && (mouseMaze[row][col] & UPPER_WALL) != UPPER_WALL)\n validateFlood(row - 1, col);\n if(row < MAZE_WIDTH - 1 && (mouseMaze[row][col] & LOWER_WALL) != LOWER_WALL)\n validateFlood(row + 1, col);\n if(col > 0 && (mouseMaze[row][col] & LEFT_WALL) != LEFT_WALL)\n validateFlood(row, col - 1);\n if(col < MAZE_WIDTH - 1 && (mouseMaze[row][col] & RIGHT_WALL) != RIGHT_WALL)\n validateFlood(row, col + 1);\n */"
] | [
{
"param": "row",
"type": "int"
},
{
"param": "col",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | floodFill | void | void floodFill(int num, int row, int col) {
floodMaze[row][col] = num;
if(row > 0 && floodMaze[row - 1][col] > num && (mouseMaze[row][col] & UPPER_WALL) == 0)
floodFill(num + 1, row - 1, col);
if(row < MAZE_WIDTH - 1 && floodMaze[row + 1][col] > num && (mouseMaze[row][col] & LOWER_WALL) == 0)
floodFill(num + 1, row + 1, col);
if(col > 0 && floodMaze[row][col - 1] > num && (mouseMaze[row][col] & LEFT_WALL) == 0)
floodFill(num + 1, row, col - 1);
if(col < MAZE_WIDTH - 1 && floodMaze[row][col + 1] > num && (mouseMaze[row][col] & RIGHT_WALL) == 0)
floodFill(num + 1, row, col + 1);
} | /******************************************************************************
Routine Name: floodFill
File: mouse.c
Description: Full floodfill starting from specified location with flood num.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
num num to start flood at
row row of tile to begin at
col column of tile to begin at
******************************************************************************/ | Routine Name: floodFill
File: mouse.c
Full floodfill starting from specified location with flood num.
Parameter Descriptions:
name description
num num to start flood at
row row of tile to begin at
col column of tile to begin at | [
"Routine",
"Name",
":",
"floodFill",
"File",
":",
"mouse",
".",
"c",
"Full",
"floodfill",
"starting",
"from",
"specified",
"location",
"with",
"flood",
"num",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"num",
"num",
"to",
"start",
"flood",
"at",
"row",
"row",
"of",
"tile",
"to",
"begin",
"at",
"col",
"column",
"of",
"tile",
"to",
"begin",
"at"
] | void floodFill(int num, int row, int col) {
floodMaze[row][col] = num;
if(row > 0 && floodMaze[row - 1][col] > num && (mouseMaze[row][col] & UPPER_WALL) == 0)
floodFill(num + 1, row - 1, col);
if(row < MAZE_WIDTH - 1 && floodMaze[row + 1][col] > num && (mouseMaze[row][col] & LOWER_WALL) == 0)
floodFill(num + 1, row + 1, col);
if(col > 0 && floodMaze[row][col - 1] > num && (mouseMaze[row][col] & LEFT_WALL) == 0)
floodFill(num + 1, row, col - 1);
if(col < MAZE_WIDTH - 1 && floodMaze[row][col + 1] > num && (mouseMaze[row][col] & RIGHT_WALL) == 0)
floodFill(num + 1, row, col + 1);
} | [
"void",
"floodFill",
"(",
"int",
"num",
",",
"int",
"row",
",",
"int",
"col",
")",
"{",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"num",
";",
"if",
"(",
"row",
">",
"0",
"&&",
"floodMaze",
"[",
"row",
"-",
"1",
"]",
"[",
"col",
"]",
">",
"num",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"UPPER_WALL",
")",
"==",
"0",
")",
"floodFill",
"(",
"num",
"+",
"1",
",",
"row",
"-",
"1",
",",
"col",
")",
";",
"if",
"(",
"row",
"<",
"MAZE_WIDTH",
"-",
"1",
"&&",
"floodMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
">",
"num",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LOWER_WALL",
")",
"==",
"0",
")",
"floodFill",
"(",
"num",
"+",
"1",
",",
"row",
"+",
"1",
",",
"col",
")",
";",
"if",
"(",
"col",
">",
"0",
"&&",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
">",
"num",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LEFT_WALL",
")",
"==",
"0",
")",
"floodFill",
"(",
"num",
"+",
"1",
",",
"row",
",",
"col",
"-",
"1",
")",
";",
"if",
"(",
"col",
"<",
"MAZE_WIDTH",
"-",
"1",
"&&",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
">",
"num",
"&&",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"RIGHT_WALL",
")",
"==",
"0",
")",
"floodFill",
"(",
"num",
"+",
"1",
",",
"row",
",",
"col",
"+",
"1",
")",
";",
"}"
] | Routine Name: floodFill
File: mouse.c | [
"Routine",
"Name",
":",
"floodFill",
"File",
":",
"mouse",
".",
"c"
] | [] | [
{
"param": "num",
"type": "int"
},
{
"param": "row",
"type": "int"
},
{
"param": "col",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "num",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "row",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | closeBoxes | void | void closeBoxes() {
int row, col;
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++)
//check if 1 bit is set to 0
if(((mouseMaze[row][col] ^ WALLS) & ((mouseMaze[row][col] ^ WALLS) - 1)) == 0)
if((row == curRow && col == curCol) == 0) {
switch(mouseMaze[row][col] ^ WALLS) {
case LEFT_WALL:
mouseMaze[row][col] |= LEFT_WALL;
mouseMaze[row][col - 1] |= RIGHT_WALL;
break;
case UPPER_WALL:
mouseMaze[row][col] |= UPPER_WALL;
mouseMaze[row - 1][col] |= LOWER_WALL;
break;
case RIGHT_WALL:
mouseMaze[row][col] |= RIGHT_WALL;
mouseMaze[row][col + 1] |= LEFT_WALL;
break;
case LOWER_WALL:
mouseMaze[row][col] |= LOWER_WALL;
mouseMaze[row + 1][col] |= UPPER_WALL;
break;
}
//mouseMaze[row][col] = WALLS;
drawTileWalls(col, row, mouseMaze[row][col], YELLOW);
}
} | //TODO maybe integrate this into main algorithm
/******************************************************************************
Routine Name: closeBoxes
File: mouse.c
Description: Boxes dead ends off to reduce computational intensity of
flooding.
******************************************************************************/ |
Boxes dead ends off to reduce computational intensity of
flooding. | [
"Boxes",
"dead",
"ends",
"off",
"to",
"reduce",
"computational",
"intensity",
"of",
"flooding",
"."
] | void closeBoxes() {
int row, col;
for(row = 0; row < MAZE_WIDTH; row++)
for(col = 0; col < MAZE_WIDTH; col++)
if(((mouseMaze[row][col] ^ WALLS) & ((mouseMaze[row][col] ^ WALLS) - 1)) == 0)
if((row == curRow && col == curCol) == 0) {
switch(mouseMaze[row][col] ^ WALLS) {
case LEFT_WALL:
mouseMaze[row][col] |= LEFT_WALL;
mouseMaze[row][col - 1] |= RIGHT_WALL;
break;
case UPPER_WALL:
mouseMaze[row][col] |= UPPER_WALL;
mouseMaze[row - 1][col] |= LOWER_WALL;
break;
case RIGHT_WALL:
mouseMaze[row][col] |= RIGHT_WALL;
mouseMaze[row][col + 1] |= LEFT_WALL;
break;
case LOWER_WALL:
mouseMaze[row][col] |= LOWER_WALL;
mouseMaze[row + 1][col] |= UPPER_WALL;
break;
}
drawTileWalls(col, row, mouseMaze[row][col], YELLOW);
}
} | [
"void",
"closeBoxes",
"(",
")",
"{",
"int",
"row",
",",
"col",
";",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"MAZE_WIDTH",
";",
"row",
"++",
")",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"MAZE_WIDTH",
";",
"col",
"++",
")",
"if",
"(",
"(",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"^",
"WALLS",
")",
"&",
"(",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"^",
"WALLS",
")",
"-",
"1",
")",
")",
"==",
"0",
")",
"if",
"(",
"(",
"row",
"==",
"curRow",
"&&",
"col",
"==",
"curCol",
")",
"==",
"0",
")",
"{",
"switch",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"^",
"WALLS",
")",
"{",
"case",
"LEFT_WALL",
":",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"LEFT_WALL",
";",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
"|=",
"RIGHT_WALL",
";",
"break",
";",
"case",
"UPPER_WALL",
":",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"UPPER_WALL",
";",
"mouseMaze",
"[",
"row",
"-",
"1",
"]",
"[",
"col",
"]",
"|=",
"LOWER_WALL",
";",
"break",
";",
"case",
"RIGHT_WALL",
":",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"RIGHT_WALL",
";",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
"|=",
"LEFT_WALL",
";",
"break",
";",
"case",
"LOWER_WALL",
":",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"|=",
"LOWER_WALL",
";",
"mouseMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
"|=",
"UPPER_WALL",
";",
"break",
";",
"}",
"drawTileWalls",
"(",
"col",
",",
"row",
",",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
",",
"YELLOW",
")",
";",
"}",
"}"
] | TODO maybe integrate this into main algorithm
Routine Name: closeBoxes
File: mouse.c | [
"TODO",
"maybe",
"integrate",
"this",
"into",
"main",
"algorithm",
"Routine",
"Name",
":",
"closeBoxes",
"File",
":",
"mouse",
".",
"c"
] | [
"//check if 1 bit is set to 0",
"//mouseMaze[row][col] = WALLS;"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | mouseMove | void | void mouseMove(int mode, int row, int col) {
int lowest;
int dir;
if(mode == FLOOD) {
dir = findLowerNeighbor(curRow, curCol);
if((dir & LEFT) == LEFT)
curCol--;
else if((dir & UP) == UP)
curRow--;
else if((dir & RIGHT) == RIGHT)
curCol++;
else if((dir & DOWN) == DOWN)
curRow++;
mvprintw(30, 50, "%x", dir);
}
else if(mode == MANUAL) {
curRow = row;
curCol = col;
}
} | /******************************************************************************
Routine Name: mouseMove
File: mouse.c
Description: Moves mouse based on specified mode. Can also force mouse to
jump to specific location in maze.
Parameter Descriptions:
name description
------------------ -----------------------------------------------
mode if FLOOD, use floodfill maze to move in best direction.
if MANUAL, jump to location
row row of tile to jump to (MANUAL mode only)
col column of tile to jump to (MANUAL mode only)
******************************************************************************/ | Routine Name: mouseMove
File: mouse.c
Moves mouse based on specified mode. Can also force mouse to
jump to specific location in maze.
Parameter Descriptions:
name description
mode if FLOOD, use floodfill maze to move in best direction.
if MANUAL, jump to location
row row of tile to jump to (MANUAL mode only)
col column of tile to jump to (MANUAL mode only) | [
"Routine",
"Name",
":",
"mouseMove",
"File",
":",
"mouse",
".",
"c",
"Moves",
"mouse",
"based",
"on",
"specified",
"mode",
".",
"Can",
"also",
"force",
"mouse",
"to",
"jump",
"to",
"specific",
"location",
"in",
"maze",
".",
"Parameter",
"Descriptions",
":",
"name",
"description",
"mode",
"if",
"FLOOD",
"use",
"floodfill",
"maze",
"to",
"move",
"in",
"best",
"direction",
".",
"if",
"MANUAL",
"jump",
"to",
"location",
"row",
"row",
"of",
"tile",
"to",
"jump",
"to",
"(",
"MANUAL",
"mode",
"only",
")",
"col",
"column",
"of",
"tile",
"to",
"jump",
"to",
"(",
"MANUAL",
"mode",
"only",
")"
] | void mouseMove(int mode, int row, int col) {
int lowest;
int dir;
if(mode == FLOOD) {
dir = findLowerNeighbor(curRow, curCol);
if((dir & LEFT) == LEFT)
curCol--;
else if((dir & UP) == UP)
curRow--;
else if((dir & RIGHT) == RIGHT)
curCol++;
else if((dir & DOWN) == DOWN)
curRow++;
mvprintw(30, 50, "%x", dir);
}
else if(mode == MANUAL) {
curRow = row;
curCol = col;
}
} | [
"void",
"mouseMove",
"(",
"int",
"mode",
",",
"int",
"row",
",",
"int",
"col",
")",
"{",
"int",
"lowest",
";",
"int",
"dir",
";",
"if",
"(",
"mode",
"==",
"FLOOD",
")",
"{",
"dir",
"=",
"findLowerNeighbor",
"(",
"curRow",
",",
"curCol",
")",
";",
"if",
"(",
"(",
"dir",
"&",
"LEFT",
")",
"==",
"LEFT",
")",
"curCol",
"--",
";",
"else",
"if",
"(",
"(",
"dir",
"&",
"UP",
")",
"==",
"UP",
")",
"curRow",
"--",
";",
"else",
"if",
"(",
"(",
"dir",
"&",
"RIGHT",
")",
"==",
"RIGHT",
")",
"curCol",
"++",
";",
"else",
"if",
"(",
"(",
"dir",
"&",
"DOWN",
")",
"==",
"DOWN",
")",
"curRow",
"++",
";",
"mvprintw",
"(",
"30",
",",
"50",
",",
"\"",
"\"",
",",
"dir",
")",
";",
"}",
"else",
"if",
"(",
"mode",
"==",
"MANUAL",
")",
"{",
"curRow",
"=",
"row",
";",
"curCol",
"=",
"col",
";",
"}",
"}"
] | Routine Name: mouseMove
File: mouse.c | [
"Routine",
"Name",
":",
"mouseMove",
"File",
":",
"mouse",
".",
"c"
] | [] | [
{
"param": "mode",
"type": "int"
},
{
"param": "row",
"type": "int"
},
{
"param": "col",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "row",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b20f47cfae584427a0648e3aed33f3665148cf9c | ThisChessPlayer/Micromouse | mouse.c | [
"MIT"
] | C | findLowerNeighbor | int | int findLowerNeighbor(int row, int col) {
/*
* lowest - smallest found flood
* result - lowest directions
*/
int lowest, result;
result = 0;
//lowest = MAZE_WIDTH * MAZE_WIDTH - 1;
lowest = floodMaze[row][col];
/* 1. Check if adjacent tile is neighbor (accessible by mouse)
* 2. If neighboring, see if flood value is lower or equal to current lowest
* 3. Update lowest and lowest tile bits accordingly
*/
//Check upper neighbor
if((mouseMaze[row][col] & UPPER_WALL) != UPPER_WALL) {
if(floodMaze[row - 1][col] < lowest) {
lowest = floodMaze[row - 1][col];
result = UP;
}
else if(floodMaze[row - 1][col] == lowest)
result |= UP;
}
//Check lower neighbor
if((mouseMaze[row][col] & LOWER_WALL) != LOWER_WALL) {
if(floodMaze[row + 1][col] < lowest) {
lowest = floodMaze[row + 1][col];
result = DOWN;
}
else if(floodMaze[row + 1][col] == lowest)
result |= DOWN;
}
//Check left neighbor
if((mouseMaze[row][col] & LEFT_WALL) != LEFT_WALL) {
if(floodMaze[row][col - 1] < lowest) {
lowest = floodMaze[row][col - 1];
result = LEFT;
}
else if(floodMaze[row][col - 1] == lowest)
result |= LEFT;
}
//Check right neighbor
if((mouseMaze[row][col] & RIGHT_WALL) != RIGHT_WALL) {
if(floodMaze[row][col + 1] < lowest) {
lowest = floodMaze[row][col + 1];
result = RIGHT;
}
else if(floodMaze[row][col + 1] == lowest)
result |= RIGHT;
}
return result;
} | /******************************************************************************
Routine Name: findLowerNeighbor
File: mouse.c
Description: Find lowest neighbor's direction if one exists. Can return
multiple neighbors' directions if they tie for lowest
Parameter Descriptions:
name description
------------------ -----------------------------------------------
row row of tile to check neighbors of
col column of tile to check neighbors of
******************************************************************************/ | Routine Name: findLowerNeighbor
File: mouse.c
Find lowest neighbor's direction if one exists. Can return
multiple neighbors' directions if they tie for lowest
Parameter Descriptions:
name description
row row of tile to check neighbors of
col column of tile to check neighbors of | [
"Routine",
"Name",
":",
"findLowerNeighbor",
"File",
":",
"mouse",
".",
"c",
"Find",
"lowest",
"neighbor",
"'",
"s",
"direction",
"if",
"one",
"exists",
".",
"Can",
"return",
"multiple",
"neighbors",
"'",
"directions",
"if",
"they",
"tie",
"for",
"lowest",
"Parameter",
"Descriptions",
":",
"name",
"description",
"row",
"row",
"of",
"tile",
"to",
"check",
"neighbors",
"of",
"col",
"column",
"of",
"tile",
"to",
"check",
"neighbors",
"of"
] | int findLowerNeighbor(int row, int col) {
int lowest, result;
result = 0;
lowest = floodMaze[row][col];
if((mouseMaze[row][col] & UPPER_WALL) != UPPER_WALL) {
if(floodMaze[row - 1][col] < lowest) {
lowest = floodMaze[row - 1][col];
result = UP;
}
else if(floodMaze[row - 1][col] == lowest)
result |= UP;
}
if((mouseMaze[row][col] & LOWER_WALL) != LOWER_WALL) {
if(floodMaze[row + 1][col] < lowest) {
lowest = floodMaze[row + 1][col];
result = DOWN;
}
else if(floodMaze[row + 1][col] == lowest)
result |= DOWN;
}
if((mouseMaze[row][col] & LEFT_WALL) != LEFT_WALL) {
if(floodMaze[row][col - 1] < lowest) {
lowest = floodMaze[row][col - 1];
result = LEFT;
}
else if(floodMaze[row][col - 1] == lowest)
result |= LEFT;
}
if((mouseMaze[row][col] & RIGHT_WALL) != RIGHT_WALL) {
if(floodMaze[row][col + 1] < lowest) {
lowest = floodMaze[row][col + 1];
result = RIGHT;
}
else if(floodMaze[row][col + 1] == lowest)
result |= RIGHT;
}
return result;
} | [
"int",
"findLowerNeighbor",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"int",
"lowest",
",",
"result",
";",
"result",
"=",
"0",
";",
"lowest",
"=",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"]",
";",
"if",
"(",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"UPPER_WALL",
")",
"!=",
"UPPER_WALL",
")",
"{",
"if",
"(",
"floodMaze",
"[",
"row",
"-",
"1",
"]",
"[",
"col",
"]",
"<",
"lowest",
")",
"{",
"lowest",
"=",
"floodMaze",
"[",
"row",
"-",
"1",
"]",
"[",
"col",
"]",
";",
"result",
"=",
"UP",
";",
"}",
"else",
"if",
"(",
"floodMaze",
"[",
"row",
"-",
"1",
"]",
"[",
"col",
"]",
"==",
"lowest",
")",
"result",
"|=",
"UP",
";",
"}",
"if",
"(",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LOWER_WALL",
")",
"!=",
"LOWER_WALL",
")",
"{",
"if",
"(",
"floodMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
"<",
"lowest",
")",
"{",
"lowest",
"=",
"floodMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
";",
"result",
"=",
"DOWN",
";",
"}",
"else",
"if",
"(",
"floodMaze",
"[",
"row",
"+",
"1",
"]",
"[",
"col",
"]",
"==",
"lowest",
")",
"result",
"|=",
"DOWN",
";",
"}",
"if",
"(",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"LEFT_WALL",
")",
"!=",
"LEFT_WALL",
")",
"{",
"if",
"(",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
"<",
"lowest",
")",
"{",
"lowest",
"=",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
";",
"result",
"=",
"LEFT",
";",
"}",
"else",
"if",
"(",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"-",
"1",
"]",
"==",
"lowest",
")",
"result",
"|=",
"LEFT",
";",
"}",
"if",
"(",
"(",
"mouseMaze",
"[",
"row",
"]",
"[",
"col",
"]",
"&",
"RIGHT_WALL",
")",
"!=",
"RIGHT_WALL",
")",
"{",
"if",
"(",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
"<",
"lowest",
")",
"{",
"lowest",
"=",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
";",
"result",
"=",
"RIGHT",
";",
"}",
"else",
"if",
"(",
"floodMaze",
"[",
"row",
"]",
"[",
"col",
"+",
"1",
"]",
"==",
"lowest",
")",
"result",
"|=",
"RIGHT",
";",
"}",
"return",
"result",
";",
"}"
] | Routine Name: findLowerNeighbor
File: mouse.c | [
"Routine",
"Name",
":",
"findLowerNeighbor",
"File",
":",
"mouse",
".",
"c"
] | [
"/* \n * lowest - smallest found flood\n * result - lowest directions\n */",
"//lowest = MAZE_WIDTH * MAZE_WIDTH - 1;",
"/* 1. Check if adjacent tile is neighbor (accessible by mouse)\n * 2. If neighboring, see if flood value is lower or equal to current lowest\n * 3. Update lowest and lowest tile bits accordingly\n */",
"//Check upper neighbor",
"//Check lower neighbor",
"//Check left neighbor",
"//Check right neighbor"
] | [
{
"param": "row",
"type": "int"
},
{
"param": "col",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31f0f938dd15bb736a164ff445a88f330c025315 | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/pairs.c | [
"Python-2.0"
] | C | PAIR | void | void
PAIR(int *outcome)
{ int u, w, temp;
#ifdef DEBUG
printf("Pair v=%d\n",v);
#endif
e = NEXTEDGE[v];
while (SLACK(e) != 2*DELTA)
e = NEXTPAIR[e];
w = BEND (e);
LINK[BMATE (w)] = -e;
u = BMATE (v);
while (LINK[u] != -e) {
LINK[u] = -e;
if (MATE[w] != DUMMYEDGE) {
temp = v;
v = w;
w = temp; }
v = BLINK (v);
u = BMATE (v);
}
if (u == DUMMYVERTEX && v != w) {
*outcome = 1;
return;
}
newlast = v;
newbase = v;
oldfirst = NEXTVTX[v];
LINK_PATH (e);
LINK_PATH (OPPEDGE (e));
NEXTVTX[newlast] = oldfirst;
if (LASTVTX[newbase] == newbase)
LASTVTX[newbase] = newlast;
NEXTPAIR[DUMMYEDGE] = DUMMYEDGE;
MERGE_PAIRS (newbase);
i = NEXTVTX[newbase];
do {
MERGE_PAIRS (i);
i = NEXTVTX[LASTVTX[i]];
SCAN (i, 2*DELTA - SLACK(MATE[i]));
i = NEXTVTX[LASTVTX[i]];
} while (i != oldfirst);
*outcome = 0;
return;
} | /* Process an edge linking two linked vertices */
/* Note: global variable v set to the base of one end of the linking edge */ | Process an edge linking two linked vertices
Note: global variable v set to the base of one end of the linking edge | [
"Process",
"an",
"edge",
"linking",
"two",
"linked",
"vertices",
"Note",
":",
"global",
"variable",
"v",
"set",
"to",
"the",
"base",
"of",
"one",
"end",
"of",
"the",
"linking",
"edge"
] | void
PAIR(int *outcome)
{ int u, w, temp;
#ifdef DEBUG
printf("Pair v=%d\n",v);
#endif
e = NEXTEDGE[v];
while (SLACK(e) != 2*DELTA)
e = NEXTPAIR[e];
w = BEND (e);
LINK[BMATE (w)] = -e;
u = BMATE (v);
while (LINK[u] != -e) {
LINK[u] = -e;
if (MATE[w] != DUMMYEDGE) {
temp = v;
v = w;
w = temp; }
v = BLINK (v);
u = BMATE (v);
}
if (u == DUMMYVERTEX && v != w) {
*outcome = 1;
return;
}
newlast = v;
newbase = v;
oldfirst = NEXTVTX[v];
LINK_PATH (e);
LINK_PATH (OPPEDGE (e));
NEXTVTX[newlast] = oldfirst;
if (LASTVTX[newbase] == newbase)
LASTVTX[newbase] = newlast;
NEXTPAIR[DUMMYEDGE] = DUMMYEDGE;
MERGE_PAIRS (newbase);
i = NEXTVTX[newbase];
do {
MERGE_PAIRS (i);
i = NEXTVTX[LASTVTX[i]];
SCAN (i, 2*DELTA - SLACK(MATE[i]));
i = NEXTVTX[LASTVTX[i]];
} while (i != oldfirst);
*outcome = 0;
return;
} | [
"void",
"PAIR",
"(",
"int",
"*",
"outcome",
")",
"{",
"int",
"u",
",",
"w",
",",
"temp",
";",
"#ifdef",
"DEBUG",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"v",
")",
";",
"#endif",
"e",
"=",
"NEXTEDGE",
"[",
"v",
"]",
";",
"while",
"(",
"SLACK",
"(",
"e",
")",
"!=",
"2",
"*",
"DELTA",
")",
"e",
"=",
"NEXTPAIR",
"[",
"e",
"]",
";",
"w",
"=",
"BEND",
"(",
"e",
")",
";",
"LINK",
"[",
"BMATE",
"(",
"w",
")",
"]",
"=",
"-",
"e",
";",
"u",
"=",
"BMATE",
"(",
"v",
")",
";",
"while",
"(",
"LINK",
"[",
"u",
"]",
"!=",
"-",
"e",
")",
"{",
"LINK",
"[",
"u",
"]",
"=",
"-",
"e",
";",
"if",
"(",
"MATE",
"[",
"w",
"]",
"!=",
"DUMMYEDGE",
")",
"{",
"temp",
"=",
"v",
";",
"v",
"=",
"w",
";",
"w",
"=",
"temp",
";",
"}",
"v",
"=",
"BLINK",
"(",
"v",
")",
";",
"u",
"=",
"BMATE",
"(",
"v",
")",
";",
"}",
"if",
"(",
"u",
"==",
"DUMMYVERTEX",
"&&",
"v",
"!=",
"w",
")",
"{",
"*",
"outcome",
"=",
"1",
";",
"return",
";",
"}",
"newlast",
"=",
"v",
";",
"newbase",
"=",
"v",
";",
"oldfirst",
"=",
"NEXTVTX",
"[",
"v",
"]",
";",
"LINK_PATH",
"(",
"e",
")",
";",
"LINK_PATH",
"(",
"OPPEDGE",
"(",
"e",
")",
")",
";",
"NEXTVTX",
"[",
"newlast",
"]",
"=",
"oldfirst",
";",
"if",
"(",
"LASTVTX",
"[",
"newbase",
"]",
"==",
"newbase",
")",
"LASTVTX",
"[",
"newbase",
"]",
"=",
"newlast",
";",
"NEXTPAIR",
"[",
"DUMMYEDGE",
"]",
"=",
"DUMMYEDGE",
";",
"MERGE_PAIRS",
"(",
"newbase",
")",
";",
"i",
"=",
"NEXTVTX",
"[",
"newbase",
"]",
";",
"do",
"{",
"MERGE_PAIRS",
"(",
"i",
")",
";",
"i",
"=",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"i",
"]",
"]",
";",
"SCAN",
"(",
"i",
",",
"2",
"*",
"DELTA",
"-",
"SLACK",
"(",
"MATE",
"[",
"i",
"]",
")",
")",
";",
"i",
"=",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"i",
"]",
"]",
";",
"}",
"while",
"(",
"i",
"!=",
"oldfirst",
")",
";",
"*",
"outcome",
"=",
"0",
";",
"return",
";",
"}"
] | Process an edge linking two linked vertices
Note: global variable v set to the base of one end of the linking edge | [
"Process",
"an",
"edge",
"linking",
"two",
"linked",
"vertices",
"Note",
":",
"global",
"variable",
"v",
"set",
"to",
"the",
"base",
"of",
"one",
"end",
"of",
"the",
"linking",
"edge"
] | [] | [
{
"param": "outcome",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outcome",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31f0f938dd15bb736a164ff445a88f330c025315 | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/pairs.c | [
"Python-2.0"
] | C | MERGE_PAIRS | void | void
MERGE_PAIRS(int v)
{
#ifdef DEBUG
printf("Merge Pairs v=%d\n",v);
#endif
NEXT_D[v] = LAST_D;
pairpoint = DUMMYEDGE;
f = NEXTEDGE[v];
while (f != DUMMYEDGE) {
e = f;
neighbor = END[e];
f = NEXTPAIR[f];
if (BASE[neighbor] != newbase)
INSERT_PAIR();
}
} | /* merges a subblossom's pair vector into a new blossom's pair vector */
/* v is the base of the previously unlinked subblossom */
/* Note: global variable newbase set to the base of the new blossom */
/* called with NEXTPAIR[DUMMYEDGE] pointing to the first edge */
/* on newbase's pair vector */ | merges a subblossom's pair vector into a new blossom's pair vector
v is the base of the previously unlinked subblossom
Note: global variable newbase set to the base of the new blossom
called with NEXTPAIR[DUMMYEDGE] pointing to the first edge
on newbase's pair vector | [
"merges",
"a",
"subblossom",
"'",
"s",
"pair",
"vector",
"into",
"a",
"new",
"blossom",
"'",
"s",
"pair",
"vector",
"v",
"is",
"the",
"base",
"of",
"the",
"previously",
"unlinked",
"subblossom",
"Note",
":",
"global",
"variable",
"newbase",
"set",
"to",
"the",
"base",
"of",
"the",
"new",
"blossom",
"called",
"with",
"NEXTPAIR",
"[",
"DUMMYEDGE",
"]",
"pointing",
"to",
"the",
"first",
"edge",
"on",
"newbase",
"'",
"s",
"pair",
"vector"
] | void
MERGE_PAIRS(int v)
{
#ifdef DEBUG
printf("Merge Pairs v=%d\n",v);
#endif
NEXT_D[v] = LAST_D;
pairpoint = DUMMYEDGE;
f = NEXTEDGE[v];
while (f != DUMMYEDGE) {
e = f;
neighbor = END[e];
f = NEXTPAIR[f];
if (BASE[neighbor] != newbase)
INSERT_PAIR();
}
} | [
"void",
"MERGE_PAIRS",
"(",
"int",
"v",
")",
"{",
"#ifdef",
"DEBUG",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"v",
")",
";",
"#endif",
"NEXT_D",
"[",
"v",
"]",
"=",
"LAST_D",
";",
"pairpoint",
"=",
"DUMMYEDGE",
";",
"f",
"=",
"NEXTEDGE",
"[",
"v",
"]",
";",
"while",
"(",
"f",
"!=",
"DUMMYEDGE",
")",
"{",
"e",
"=",
"f",
";",
"neighbor",
"=",
"END",
"[",
"e",
"]",
";",
"f",
"=",
"NEXTPAIR",
"[",
"f",
"]",
";",
"if",
"(",
"BASE",
"[",
"neighbor",
"]",
"!=",
"newbase",
")",
"INSERT_PAIR",
"(",
")",
";",
"}",
"}"
] | merges a subblossom's pair vector into a new blossom's pair vector
v is the base of the previously unlinked subblossom
Note: global variable newbase set to the base of the new blossom
called with NEXTPAIR[DUMMYEDGE] pointing to the first edge
on newbase's pair vector | [
"merges",
"a",
"subblossom",
"'",
"s",
"pair",
"vector",
"into",
"a",
"new",
"blossom",
"'",
"s",
"pair",
"vector",
"v",
"is",
"the",
"base",
"of",
"the",
"previously",
"unlinked",
"subblossom",
"Note",
":",
"global",
"variable",
"newbase",
"set",
"to",
"the",
"base",
"of",
"the",
"new",
"blossom",
"called",
"with",
"NEXTPAIR",
"[",
"DUMMYEDGE",
"]",
"pointing",
"to",
"the",
"first",
"edge",
"on",
"newbase",
"'",
"s",
"pair",
"vector"
] | [] | [
{
"param": "v",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "v",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31f0f938dd15bb736a164ff445a88f330c025315 | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/pairs.c | [
"Python-2.0"
] | C | LINK_PATH | void | void
LINK_PATH (int e)
{ int u;
#ifdef DEBUG
printf("Link Path e=%d-%d\n", END[OPPEDGE(e)], END[e]);
#endif
v = BEND (e);
while (v != newbase) {
u = BMATE (v);
LINK[u] = OPPEDGE (e);
NEXTVTX[newlast] = v;
NEXTVTX[LASTVTX[v]] = u;
newlast = LASTVTX[u];
i = v;
BASE[i] = newbase;
i = NEXTVTX[i];
while (i != DUMMYVERTEX) {
BASE[i] = newbase;
i = NEXTVTX[i];
}
e = LINK[v];
v = BEND (e);
}
} | /* links the unlinked vertices in the path P(END[e],newbase) */
/* Note: global variable newbase is set to the base vertex of the new blossom */
/* newlast is set to the last vertex in newbase's current blossom*/ | links the unlinked vertices in the path P(END[e],newbase)
Note: global variable newbase is set to the base vertex of the new blossom
newlast is set to the last vertex in newbase's current blossom | [
"links",
"the",
"unlinked",
"vertices",
"in",
"the",
"path",
"P",
"(",
"END",
"[",
"e",
"]",
"newbase",
")",
"Note",
":",
"global",
"variable",
"newbase",
"is",
"set",
"to",
"the",
"base",
"vertex",
"of",
"the",
"new",
"blossom",
"newlast",
"is",
"set",
"to",
"the",
"last",
"vertex",
"in",
"newbase",
"'",
"s",
"current",
"blossom"
] | void
LINK_PATH (int e)
{ int u;
#ifdef DEBUG
printf("Link Path e=%d-%d\n", END[OPPEDGE(e)], END[e]);
#endif
v = BEND (e);
while (v != newbase) {
u = BMATE (v);
LINK[u] = OPPEDGE (e);
NEXTVTX[newlast] = v;
NEXTVTX[LASTVTX[v]] = u;
newlast = LASTVTX[u];
i = v;
BASE[i] = newbase;
i = NEXTVTX[i];
while (i != DUMMYVERTEX) {
BASE[i] = newbase;
i = NEXTVTX[i];
}
e = LINK[v];
v = BEND (e);
}
} | [
"void",
"LINK_PATH",
"(",
"int",
"e",
")",
"{",
"int",
"u",
";",
"#ifdef",
"DEBUG",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"END",
"[",
"OPPEDGE",
"(",
"e",
")",
"]",
",",
"END",
"[",
"e",
"]",
")",
";",
"#endif",
"v",
"=",
"BEND",
"(",
"e",
")",
";",
"while",
"(",
"v",
"!=",
"newbase",
")",
"{",
"u",
"=",
"BMATE",
"(",
"v",
")",
";",
"LINK",
"[",
"u",
"]",
"=",
"OPPEDGE",
"(",
"e",
")",
";",
"NEXTVTX",
"[",
"newlast",
"]",
"=",
"v",
";",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"v",
"]",
"]",
"=",
"u",
";",
"newlast",
"=",
"LASTVTX",
"[",
"u",
"]",
";",
"i",
"=",
"v",
";",
"BASE",
"[",
"i",
"]",
"=",
"newbase",
";",
"i",
"=",
"NEXTVTX",
"[",
"i",
"]",
";",
"while",
"(",
"i",
"!=",
"DUMMYVERTEX",
")",
"{",
"BASE",
"[",
"i",
"]",
"=",
"newbase",
";",
"i",
"=",
"NEXTVTX",
"[",
"i",
"]",
";",
"}",
"e",
"=",
"LINK",
"[",
"v",
"]",
";",
"v",
"=",
"BEND",
"(",
"e",
")",
";",
"}",
"}"
] | links the unlinked vertices in the path P(END[e],newbase)
Note: global variable newbase is set to the base vertex of the new blossom
newlast is set to the last vertex in newbase's current blossom | [
"links",
"the",
"unlinked",
"vertices",
"in",
"the",
"path",
"P",
"(",
"END",
"[",
"e",
"]",
"newbase",
")",
"Note",
":",
"global",
"variable",
"newbase",
"is",
"set",
"to",
"the",
"base",
"vertex",
"of",
"the",
"new",
"blossom",
"newlast",
"is",
"set",
"to",
"the",
"last",
"vertex",
"in",
"newbase",
"'",
"s",
"current",
"blossom"
] | [] | [
{
"param": "e",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31f0f938dd15bb736a164ff445a88f330c025315 | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/pairs.c | [
"Python-2.0"
] | C | INSERT_PAIR | void | void
INSERT_PAIR (void)
{ int del_e;
#ifdef DEBUG
printf("Insert Pair e=%d-%d\n",END[OPPEDGE(e)],END[e]);
#endif
del_e = SLACK(e)/2;
nextpoint = NEXTPAIR[pairpoint];
while (END[nextpoint] < neighbor) {
pairpoint = nextpoint;
nextpoint = NEXTPAIR[nextpoint];
}
if (END[nextpoint] == neighbor) {
if (del_e >= SLACK (nextpoint)/2)
return;
nextpoint = NEXTPAIR[nextpoint];
}
NEXTPAIR[pairpoint] = e;
pairpoint = e;
NEXTPAIR[e] = nextpoint;
if (NEXT_D[newbase] > del_e)
NEXT_D[newbase] = del_e;
} | /* Update a blossom's pair vector. */
/* Note: called with global variable e set to the edge to be inserted. */
/* neighbor set to the vertex at the end of e */
/* pairpoint set to the next pair on the pair vector */ | Update a blossom's pair vector.
Note: called with global variable e set to the edge to be inserted.
neighbor set to the vertex at the end of e
pairpoint set to the next pair on the pair vector | [
"Update",
"a",
"blossom",
"'",
"s",
"pair",
"vector",
".",
"Note",
":",
"called",
"with",
"global",
"variable",
"e",
"set",
"to",
"the",
"edge",
"to",
"be",
"inserted",
".",
"neighbor",
"set",
"to",
"the",
"vertex",
"at",
"the",
"end",
"of",
"e",
"pairpoint",
"set",
"to",
"the",
"next",
"pair",
"on",
"the",
"pair",
"vector"
] | void
INSERT_PAIR (void)
{ int del_e;
#ifdef DEBUG
printf("Insert Pair e=%d-%d\n",END[OPPEDGE(e)],END[e]);
#endif
del_e = SLACK(e)/2;
nextpoint = NEXTPAIR[pairpoint];
while (END[nextpoint] < neighbor) {
pairpoint = nextpoint;
nextpoint = NEXTPAIR[nextpoint];
}
if (END[nextpoint] == neighbor) {
if (del_e >= SLACK (nextpoint)/2)
return;
nextpoint = NEXTPAIR[nextpoint];
}
NEXTPAIR[pairpoint] = e;
pairpoint = e;
NEXTPAIR[e] = nextpoint;
if (NEXT_D[newbase] > del_e)
NEXT_D[newbase] = del_e;
} | [
"void",
"INSERT_PAIR",
"(",
"void",
")",
"{",
"int",
"del_e",
";",
"#ifdef",
"DEBUG",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"END",
"[",
"OPPEDGE",
"(",
"e",
")",
"]",
",",
"END",
"[",
"e",
"]",
")",
";",
"#endif",
"del_e",
"=",
"SLACK",
"(",
"e",
")",
"/",
"2",
";",
"nextpoint",
"=",
"NEXTPAIR",
"[",
"pairpoint",
"]",
";",
"while",
"(",
"END",
"[",
"nextpoint",
"]",
"<",
"neighbor",
")",
"{",
"pairpoint",
"=",
"nextpoint",
";",
"nextpoint",
"=",
"NEXTPAIR",
"[",
"nextpoint",
"]",
";",
"}",
"if",
"(",
"END",
"[",
"nextpoint",
"]",
"==",
"neighbor",
")",
"{",
"if",
"(",
"del_e",
">=",
"SLACK",
"(",
"nextpoint",
")",
"/",
"2",
")",
"return",
";",
"nextpoint",
"=",
"NEXTPAIR",
"[",
"nextpoint",
"]",
";",
"}",
"NEXTPAIR",
"[",
"pairpoint",
"]",
"=",
"e",
";",
"pairpoint",
"=",
"e",
";",
"NEXTPAIR",
"[",
"e",
"]",
"=",
"nextpoint",
";",
"if",
"(",
"NEXT_D",
"[",
"newbase",
"]",
">",
"del_e",
")",
"NEXT_D",
"[",
"newbase",
"]",
"=",
"del_e",
";",
"}"
] | Update a blossom's pair vector. | [
"Update",
"a",
"blossom",
"'",
"s",
"pair",
"vector",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0ab893766af2ef0829a80c706a22a590b9a1dfe1 | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_splines.c | [
"Python-2.0"
] | C | g2_c_raspln | void | void g2_c_raspln(int n, const double *points, double tn, double *sxy)
{
int i, j;
double bias, tnFactor, tangentL1, tangentL2;
double D1x, D1y, D2x, D2y, t1x, t1y, t2x, t2y;
double h1[nb+1]; /* Values of the Hermite basis functions */
double h2[nb+1]; /* at nb+1 evenly spaced points in [0,1] */
double h3[nb+1];
double h4[nb+1];
double * const x = (double *) g2_malloc(n*2*sizeof(double));
double * const y = x + n;
g2_split(n, points, x, y);
/*
* First, store the values of the Hermite basis functions in a table h[ ]
* so no time is wasted recalculating them
*/
for (i = 0; i < nb+1; i++) {
double t, tt, ttt;
t = (double) i / nb;
tt = t * t;
ttt = t * tt;
h1[i] = 2. * ttt - 3. * tt + 1.;
h2[i] = -2. * ttt + 3. * tt;
h3[i] = ttt - 2. * tt + t;
h4[i] = ttt - tt;
}
/*
* Set local tnFactor based on input parameter tn
*/
if (tn <= 0.) {
tnFactor = 2.;
fputs("g2_c_raspln: Using Tension Factor 0.0: very rounded", stderr);
}
else if (tn >= 2.) {
tnFactor = 0.;
fputs("g2_c_raspln: Using Tension Factor 2.0: not rounded at all", stderr);
}
else tnFactor = 2. - tn;
D1x = D1y = 0.; /* first point has no preceding point */
for (j = 0; j < n - 2; j++) {
t1x = x[j+1] - x[j];
t1y = y[j+1] - y[j];
t2x = x[j+2] - x[j+1];
t2y = y[j+2] - y[j+1];
tangentL1 = t1x * t1x + t1y * t1y;
tangentL2 = t2x * t2x + t2y * t2y;
if (tangentL1 + tangentL2 == 0) bias = .5;
else bias = tangentL2 / (tangentL1 + tangentL2);
D2x = tnFactor * (bias * t1x + (1 - bias) * t2x);
D2y = tnFactor * (bias * t1y + (1 - bias) * t2y);
for (i = 0; i < nb; i++) {
sxy[2 * nb * j + i + i] =
h1[i] * x[j] + h2[i] * x[j+1] + h3[i] * D1x + h4[i] * D2x;
sxy[2 * nb * j + i + i + 1] =
h1[i] * y[j] + h2[i] * y[j+1] + h3[i] * D1y + h4[i] * D2y;
}
D1x = D2x; /* store as preceding point in */
D1y = D2y; /* the next pass */
}
/*
* Do the last subinterval as a special case since no point follows the
* last point
*/
for (i = 0; i < nb+1; i++) {
sxy[2 * nb * (n-2) + i + i] =
h1[i] * x[n-2] + h2[i] * x[n-1] + h3[i] * D1x;
sxy[2 * nb * (n-2) + i + i + 1] =
h1[i] * y[n-2] + h2[i] * y[n-1] + h3[i] * D1y;
}
g2_free(x);
} | /*
* Number of straight connecting lines of which each polynomial consists.
* So between one data point and the next, (nb-1) points are placed.
*/ | Number of straight connecting lines of which each polynomial consists.
So between one data point and the next, (nb-1) points are placed. | [
"Number",
"of",
"straight",
"connecting",
"lines",
"of",
"which",
"each",
"polynomial",
"consists",
".",
"So",
"between",
"one",
"data",
"point",
"and",
"the",
"next",
"(",
"nb",
"-",
"1",
")",
"points",
"are",
"placed",
"."
] | void g2_c_raspln(int n, const double *points, double tn, double *sxy)
{
int i, j;
double bias, tnFactor, tangentL1, tangentL2;
double D1x, D1y, D2x, D2y, t1x, t1y, t2x, t2y;
double h1[nb+1];
double h2[nb+1];
double h3[nb+1];
double h4[nb+1];
double * const x = (double *) g2_malloc(n*2*sizeof(double));
double * const y = x + n;
g2_split(n, points, x, y);
for (i = 0; i < nb+1; i++) {
double t, tt, ttt;
t = (double) i / nb;
tt = t * t;
ttt = t * tt;
h1[i] = 2. * ttt - 3. * tt + 1.;
h2[i] = -2. * ttt + 3. * tt;
h3[i] = ttt - 2. * tt + t;
h4[i] = ttt - tt;
}
if (tn <= 0.) {
tnFactor = 2.;
fputs("g2_c_raspln: Using Tension Factor 0.0: very rounded", stderr);
}
else if (tn >= 2.) {
tnFactor = 0.;
fputs("g2_c_raspln: Using Tension Factor 2.0: not rounded at all", stderr);
}
else tnFactor = 2. - tn;
D1x = D1y = 0.;
for (j = 0; j < n - 2; j++) {
t1x = x[j+1] - x[j];
t1y = y[j+1] - y[j];
t2x = x[j+2] - x[j+1];
t2y = y[j+2] - y[j+1];
tangentL1 = t1x * t1x + t1y * t1y;
tangentL2 = t2x * t2x + t2y * t2y;
if (tangentL1 + tangentL2 == 0) bias = .5;
else bias = tangentL2 / (tangentL1 + tangentL2);
D2x = tnFactor * (bias * t1x + (1 - bias) * t2x);
D2y = tnFactor * (bias * t1y + (1 - bias) * t2y);
for (i = 0; i < nb; i++) {
sxy[2 * nb * j + i + i] =
h1[i] * x[j] + h2[i] * x[j+1] + h3[i] * D1x + h4[i] * D2x;
sxy[2 * nb * j + i + i + 1] =
h1[i] * y[j] + h2[i] * y[j+1] + h3[i] * D1y + h4[i] * D2y;
}
D1x = D2x;
D1y = D2y;
}
for (i = 0; i < nb+1; i++) {
sxy[2 * nb * (n-2) + i + i] =
h1[i] * x[n-2] + h2[i] * x[n-1] + h3[i] * D1x;
sxy[2 * nb * (n-2) + i + i + 1] =
h1[i] * y[n-2] + h2[i] * y[n-1] + h3[i] * D1y;
}
g2_free(x);
} | [
"void",
"g2_c_raspln",
"(",
"int",
"n",
",",
"const",
"double",
"*",
"points",
",",
"double",
"tn",
",",
"double",
"*",
"sxy",
")",
"{",
"int",
"i",
",",
"j",
";",
"double",
"bias",
",",
"tnFactor",
",",
"tangentL1",
",",
"tangentL2",
";",
"double",
"D1x",
",",
"D1y",
",",
"D2x",
",",
"D2y",
",",
"t1x",
",",
"t1y",
",",
"t2x",
",",
"t2y",
";",
"double",
"h1",
"[",
"nb",
"+",
"1",
"]",
";",
"double",
"h2",
"[",
"nb",
"+",
"1",
"]",
";",
"double",
"h3",
"[",
"nb",
"+",
"1",
"]",
";",
"double",
"h4",
"[",
"nb",
"+",
"1",
"]",
";",
"double",
"*",
"const",
"x",
"=",
"(",
"double",
"*",
")",
"g2_malloc",
"(",
"n",
"*",
"2",
"*",
"sizeof",
"(",
"double",
")",
")",
";",
"double",
"*",
"const",
"y",
"=",
"x",
"+",
"n",
";",
"g2_split",
"(",
"n",
",",
"points",
",",
"x",
",",
"y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
"+",
"1",
";",
"i",
"++",
")",
"{",
"double",
"t",
",",
"tt",
",",
"ttt",
";",
"t",
"=",
"(",
"double",
")",
"i",
"/",
"nb",
";",
"tt",
"=",
"t",
"*",
"t",
";",
"ttt",
"=",
"t",
"*",
"tt",
";",
"h1",
"[",
"i",
"]",
"=",
"2.",
"*",
"ttt",
"-",
"3.",
"*",
"tt",
"+",
"1.",
";",
"h2",
"[",
"i",
"]",
"=",
"-2.",
"*",
"ttt",
"+",
"3.",
"*",
"tt",
";",
"h3",
"[",
"i",
"]",
"=",
"ttt",
"-",
"2.",
"*",
"tt",
"+",
"t",
";",
"h4",
"[",
"i",
"]",
"=",
"ttt",
"-",
"tt",
";",
"}",
"if",
"(",
"tn",
"<=",
"0.",
")",
"{",
"tnFactor",
"=",
"2.",
";",
"fputs",
"(",
"\"",
"\"",
",",
"stderr",
")",
";",
"}",
"else",
"if",
"(",
"tn",
">=",
"2.",
")",
"{",
"tnFactor",
"=",
"0.",
";",
"fputs",
"(",
"\"",
"\"",
",",
"stderr",
")",
";",
"}",
"else",
"tnFactor",
"=",
"2.",
"-",
"tn",
";",
"D1x",
"=",
"D1y",
"=",
"0.",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
"-",
"2",
";",
"j",
"++",
")",
"{",
"t1x",
"=",
"x",
"[",
"j",
"+",
"1",
"]",
"-",
"x",
"[",
"j",
"]",
";",
"t1y",
"=",
"y",
"[",
"j",
"+",
"1",
"]",
"-",
"y",
"[",
"j",
"]",
";",
"t2x",
"=",
"x",
"[",
"j",
"+",
"2",
"]",
"-",
"x",
"[",
"j",
"+",
"1",
"]",
";",
"t2y",
"=",
"y",
"[",
"j",
"+",
"2",
"]",
"-",
"y",
"[",
"j",
"+",
"1",
"]",
";",
"tangentL1",
"=",
"t1x",
"*",
"t1x",
"+",
"t1y",
"*",
"t1y",
";",
"tangentL2",
"=",
"t2x",
"*",
"t2x",
"+",
"t2y",
"*",
"t2y",
";",
"if",
"(",
"tangentL1",
"+",
"tangentL2",
"==",
"0",
")",
"bias",
"=",
".5",
";",
"else",
"bias",
"=",
"tangentL2",
"/",
"(",
"tangentL1",
"+",
"tangentL2",
")",
";",
"D2x",
"=",
"tnFactor",
"*",
"(",
"bias",
"*",
"t1x",
"+",
"(",
"1",
"-",
"bias",
")",
"*",
"t2x",
")",
";",
"D2y",
"=",
"tnFactor",
"*",
"(",
"bias",
"*",
"t1y",
"+",
"(",
"1",
"-",
"bias",
")",
"*",
"t2y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"2",
"*",
"nb",
"*",
"j",
"+",
"i",
"+",
"i",
"]",
"=",
"h1",
"[",
"i",
"]",
"*",
"x",
"[",
"j",
"]",
"+",
"h2",
"[",
"i",
"]",
"*",
"x",
"[",
"j",
"+",
"1",
"]",
"+",
"h3",
"[",
"i",
"]",
"*",
"D1x",
"+",
"h4",
"[",
"i",
"]",
"*",
"D2x",
";",
"sxy",
"[",
"2",
"*",
"nb",
"*",
"j",
"+",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"h1",
"[",
"i",
"]",
"*",
"y",
"[",
"j",
"]",
"+",
"h2",
"[",
"i",
"]",
"*",
"y",
"[",
"j",
"+",
"1",
"]",
"+",
"h3",
"[",
"i",
"]",
"*",
"D1y",
"+",
"h4",
"[",
"i",
"]",
"*",
"D2y",
";",
"}",
"D1x",
"=",
"D2x",
";",
"D1y",
"=",
"D2y",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
"+",
"1",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"2",
"*",
"nb",
"*",
"(",
"n",
"-",
"2",
")",
"+",
"i",
"+",
"i",
"]",
"=",
"h1",
"[",
"i",
"]",
"*",
"x",
"[",
"n",
"-",
"2",
"]",
"+",
"h2",
"[",
"i",
"]",
"*",
"x",
"[",
"n",
"-",
"1",
"]",
"+",
"h3",
"[",
"i",
"]",
"*",
"D1x",
";",
"sxy",
"[",
"2",
"*",
"nb",
"*",
"(",
"n",
"-",
"2",
")",
"+",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"h1",
"[",
"i",
"]",
"*",
"y",
"[",
"n",
"-",
"2",
"]",
"+",
"h2",
"[",
"i",
"]",
"*",
"y",
"[",
"n",
"-",
"1",
"]",
"+",
"h3",
"[",
"i",
"]",
"*",
"D1y",
";",
"}",
"g2_free",
"(",
"x",
")",
";",
"}"
] | Number of straight connecting lines of which each polynomial consists. | [
"Number",
"of",
"straight",
"connecting",
"lines",
"of",
"which",
"each",
"polynomial",
"consists",
"."
] | [
"/* Values of the Hermite basis functions */",
"/* at nb+1 evenly spaced points in [0,1] */",
"/*\n * First, store the values of the Hermite basis functions in a table h[ ]\n * so no time is wasted recalculating them\n */",
"/*\n * Set local tnFactor based on input parameter tn\n */",
"/* first point has no preceding point */",
"/* store as preceding point in */",
"/* the next pass */",
"/*\n * Do the last subinterval as a special case since no point follows the\n * last point\n */"
] | [
{
"param": "n",
"type": "int"
},
{
"param": "points",
"type": "double"
},
{
"param": "tn",
"type": "double"
},
{
"param": "sxy",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "points",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tn",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sxy",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ab893766af2ef0829a80c706a22a590b9a1dfe1 | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_splines.c | [
"Python-2.0"
] | C | g2_raspln | void | void g2_raspln(int dev, int n, double *points, double tn)
{
const int m = (n-1)*nb+1;
double * const sxy = (double *) g2_malloc(m*2*sizeof(double)); /* coords of the entire spline curve */
g2_c_raspln(n, points, tn, sxy);
g2_poly_line(dev, m, sxy);
g2_free(sxy);
} | /**
*
* Plot a piecewise cubic polynomial with adjustable roundness
* through the given data points.
* Each Hermite polynomial between two data points is made up of 40 lines.
* Tension factor \a tn must be between 0.0 (very rounded)
* and 2.0 (not rounded at all, i.e. essentially a \ref g2_poly_line "polyline").
*
* \param dev device id
* \param n number of data points (not the size of buffer \a points)
* \param points buffer of \a n data points x1, y1, ... x\a n, y\a n
* \param tn tension factor in the range [0.0, 2.0]
*
* \ingroup splines
*/ | Plot a piecewise cubic polynomial with adjustable roundness
through the given data points.
Each Hermite polynomial between two data points is made up of 40 lines.
Tension factor \a tn must be between 0.0 (very rounded)
and 2.0 (not rounded at all, i.e. essentially a \ref g2_poly_line "polyline").
\ingroup splines | [
"Plot",
"a",
"piecewise",
"cubic",
"polynomial",
"with",
"adjustable",
"roundness",
"through",
"the",
"given",
"data",
"points",
".",
"Each",
"Hermite",
"polynomial",
"between",
"two",
"data",
"points",
"is",
"made",
"up",
"of",
"40",
"lines",
".",
"Tension",
"factor",
"\\",
"a",
"tn",
"must",
"be",
"between",
"0",
".",
"0",
"(",
"very",
"rounded",
")",
"and",
"2",
".",
"0",
"(",
"not",
"rounded",
"at",
"all",
"i",
".",
"e",
".",
"essentially",
"a",
"\\",
"ref",
"g2_poly_line",
"\"",
"polyline",
"\"",
")",
".",
"\\",
"ingroup",
"splines"
] | void g2_raspln(int dev, int n, double *points, double tn)
{
const int m = (n-1)*nb+1;
double * const sxy = (double *) g2_malloc(m*2*sizeof(double));
g2_c_raspln(n, points, tn, sxy);
g2_poly_line(dev, m, sxy);
g2_free(sxy);
} | [
"void",
"g2_raspln",
"(",
"int",
"dev",
",",
"int",
"n",
",",
"double",
"*",
"points",
",",
"double",
"tn",
")",
"{",
"const",
"int",
"m",
"=",
"(",
"n",
"-",
"1",
")",
"*",
"nb",
"+",
"1",
";",
"double",
"*",
"const",
"sxy",
"=",
"(",
"double",
"*",
")",
"g2_malloc",
"(",
"m",
"*",
"2",
"*",
"sizeof",
"(",
"double",
")",
")",
";",
"g2_c_raspln",
"(",
"n",
",",
"points",
",",
"tn",
",",
"sxy",
")",
";",
"g2_poly_line",
"(",
"dev",
",",
"m",
",",
"sxy",
")",
";",
"g2_free",
"(",
"sxy",
")",
";",
"}"
] | Plot a piecewise cubic polynomial with adjustable roundness
through the given data points. | [
"Plot",
"a",
"piecewise",
"cubic",
"polynomial",
"with",
"adjustable",
"roundness",
"through",
"the",
"given",
"data",
"points",
"."
] | [
"/* coords of the entire spline curve */"
] | [
{
"param": "dev",
"type": "int"
},
{
"param": "n",
"type": "int"
},
{
"param": "points",
"type": "double"
},
{
"param": "tn",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "points",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tn",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ab893766af2ef0829a80c706a22a590b9a1dfe1 | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_splines.c | [
"Python-2.0"
] | C | g2_filled_raspln | void | void g2_filled_raspln(int dev, int n, double *points, double tn)
{
const int m = (n-1)*nb+2;
double * const sxy = (double *) g2_malloc(m*2*sizeof(double)); /* coords of the entire spline curve */
g2_c_raspln(n, points, tn, sxy);
sxy[m+m-2] = points[n+n-2];
sxy[m+m-1] = points[1];
g2_filled_polygon(dev, m, sxy);
g2_free(sxy);
} | /**
*
* Plot a filled piecewise cubic polynomial with adjustable roundness
* through the given data points.
* Each Hermite polynomial between two data points is made up of 40 lines.
* Tension factor \a tn must be between 0.0 (very rounded)
* and 2.0 (not rounded at all, i.e. essentially a \ref g2_poly_line "polyline").
*
* \param dev device id
* \param n number of data points (not the size of buffer \a points)
* \param points buffer of \a n data points x1, y1, ... x\a n, y\a n
* \param tn tension factor in the range [0.0, 2.0]
*
* \ingroup splines
*/ | Plot a filled piecewise cubic polynomial with adjustable roundness
through the given data points.
Each Hermite polynomial between two data points is made up of 40 lines.
Tension factor \a tn must be between 0.0 (very rounded)
and 2.0 (not rounded at all, i.e. essentially a \ref g2_poly_line "polyline").
\ingroup splines | [
"Plot",
"a",
"filled",
"piecewise",
"cubic",
"polynomial",
"with",
"adjustable",
"roundness",
"through",
"the",
"given",
"data",
"points",
".",
"Each",
"Hermite",
"polynomial",
"between",
"two",
"data",
"points",
"is",
"made",
"up",
"of",
"40",
"lines",
".",
"Tension",
"factor",
"\\",
"a",
"tn",
"must",
"be",
"between",
"0",
".",
"0",
"(",
"very",
"rounded",
")",
"and",
"2",
".",
"0",
"(",
"not",
"rounded",
"at",
"all",
"i",
".",
"e",
".",
"essentially",
"a",
"\\",
"ref",
"g2_poly_line",
"\"",
"polyline",
"\"",
")",
".",
"\\",
"ingroup",
"splines"
] | void g2_filled_raspln(int dev, int n, double *points, double tn)
{
const int m = (n-1)*nb+2;
double * const sxy = (double *) g2_malloc(m*2*sizeof(double));
g2_c_raspln(n, points, tn, sxy);
sxy[m+m-2] = points[n+n-2];
sxy[m+m-1] = points[1];
g2_filled_polygon(dev, m, sxy);
g2_free(sxy);
} | [
"void",
"g2_filled_raspln",
"(",
"int",
"dev",
",",
"int",
"n",
",",
"double",
"*",
"points",
",",
"double",
"tn",
")",
"{",
"const",
"int",
"m",
"=",
"(",
"n",
"-",
"1",
")",
"*",
"nb",
"+",
"2",
";",
"double",
"*",
"const",
"sxy",
"=",
"(",
"double",
"*",
")",
"g2_malloc",
"(",
"m",
"*",
"2",
"*",
"sizeof",
"(",
"double",
")",
")",
";",
"g2_c_raspln",
"(",
"n",
",",
"points",
",",
"tn",
",",
"sxy",
")",
";",
"sxy",
"[",
"m",
"+",
"m",
"-",
"2",
"]",
"=",
"points",
"[",
"n",
"+",
"n",
"-",
"2",
"]",
";",
"sxy",
"[",
"m",
"+",
"m",
"-",
"1",
"]",
"=",
"points",
"[",
"1",
"]",
";",
"g2_filled_polygon",
"(",
"dev",
",",
"m",
",",
"sxy",
")",
";",
"g2_free",
"(",
"sxy",
")",
";",
"}"
] | Plot a filled piecewise cubic polynomial with adjustable roundness
through the given data points. | [
"Plot",
"a",
"filled",
"piecewise",
"cubic",
"polynomial",
"with",
"adjustable",
"roundness",
"through",
"the",
"given",
"data",
"points",
"."
] | [
"/* coords of the entire spline curve */"
] | [
{
"param": "dev",
"type": "int"
},
{
"param": "n",
"type": "int"
},
{
"param": "points",
"type": "double"
},
{
"param": "tn",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "points",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tn",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ab893766af2ef0829a80c706a22a590b9a1dfe1 | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_splines.c | [
"Python-2.0"
] | C | g2_c_para_3 | void | void g2_c_para_3(int n, const double *points, int m, double *sxy)
{
#define dgr (3+1)
#define nb2 (nb*2)
int i, j;
double x1t, y1t;
double o, step;
double X[nb2]; /* x-coords of the current curve piece */
double Y[nb2]; /* y-coords of the current curve piece */
double t[dgr]; /* data point parameter values */
double Xpts[dgr]; /* x-coords data point subsection */
double Ypts[dgr]; /* y-coords data point subsection */
double s[nb2]; /* parameter values at which to interpolate */
m = m; /* dummy argument; stop compiler complaints */
/* Do first TWO subintervals first */
g2_split(dgr, points, Xpts, Ypts);
t[0] = 0.;
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
step = t[2] / nb2;
for (i = 0; i < nb2; i++) s[i] = i * step;
g2_c_newton(dgr, t, Xpts, nb2, s, X);
g2_c_newton(dgr, t, Ypts, nb2, s, Y);
for (i = 0; i < nb2; i++) {
sxy[i+i] = X[i];
sxy[i+i+1] = Y[i];
}
/* Next, do later central subintervals */
for (j = 1; j < n - dgr + 1; j++) {
g2_split(dgr, points + j + j, Xpts, Ypts);
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
o = t[1]; /* look up once */
step = (t[2] - o) / nb;
for (i = 0; i < nb; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb, s, X);
g2_c_newton(dgr, t, Ypts, nb, s, Y);
for (i = 0; i < nb; i++) {
sxy[(j + 1) * nb2 + i + i] = X[i];
sxy[(j + 1) * nb2 + i + i + 1] = Y[i];
}
}
/* Now do last subinterval */
o = t[2];
step = (t[3] - o) / nb;
for (i = 0; i < nb; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb, s, X);
g2_c_newton(dgr, t, Ypts, nb, s, Y);
for (i = 0; i < nb; i++) {
sxy[(n - dgr + 2) * nb2 + i + i] = X[i];
sxy[(n - dgr + 2) * nb2 + i + i + 1] = Y[i];
}
sxy[(n - 1) * nb2] = points[n+n-2];
sxy[(n - 1) * nb2 + 1] = points[n+n-1];
} | /*
* #undef nb
* #define nb 40
* Number of straight connecting lines of which each polynomial consists.
* So between one data point and the next, (nb-1) points are placed.
*/ | #undef nb
#define nb 40
Number of straight connecting lines of which each polynomial consists.
So between one data point and the next, (nb-1) points are placed. | [
"#undef",
"nb",
"#define",
"nb",
"40",
"Number",
"of",
"straight",
"connecting",
"lines",
"of",
"which",
"each",
"polynomial",
"consists",
".",
"So",
"between",
"one",
"data",
"point",
"and",
"the",
"next",
"(",
"nb",
"-",
"1",
")",
"points",
"are",
"placed",
"."
] | void g2_c_para_3(int n, const double *points, int m, double *sxy)
{
#define dgr (3+1)
#define nb2 (nb*2)
int i, j;
double x1t, y1t;
double o, step;
double X[nb2];
double Y[nb2];
double t[dgr];
double Xpts[dgr];
double Ypts[dgr];
double s[nb2];
m = m;
g2_split(dgr, points, Xpts, Ypts);
t[0] = 0.;
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
step = t[2] / nb2;
for (i = 0; i < nb2; i++) s[i] = i * step;
g2_c_newton(dgr, t, Xpts, nb2, s, X);
g2_c_newton(dgr, t, Ypts, nb2, s, Y);
for (i = 0; i < nb2; i++) {
sxy[i+i] = X[i];
sxy[i+i+1] = Y[i];
}
for (j = 1; j < n - dgr + 1; j++) {
g2_split(dgr, points + j + j, Xpts, Ypts);
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
o = t[1];
step = (t[2] - o) / nb;
for (i = 0; i < nb; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb, s, X);
g2_c_newton(dgr, t, Ypts, nb, s, Y);
for (i = 0; i < nb; i++) {
sxy[(j + 1) * nb2 + i + i] = X[i];
sxy[(j + 1) * nb2 + i + i + 1] = Y[i];
}
}
o = t[2];
step = (t[3] - o) / nb;
for (i = 0; i < nb; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb, s, X);
g2_c_newton(dgr, t, Ypts, nb, s, Y);
for (i = 0; i < nb; i++) {
sxy[(n - dgr + 2) * nb2 + i + i] = X[i];
sxy[(n - dgr + 2) * nb2 + i + i + 1] = Y[i];
}
sxy[(n - 1) * nb2] = points[n+n-2];
sxy[(n - 1) * nb2 + 1] = points[n+n-1];
} | [
"void",
"g2_c_para_3",
"(",
"int",
"n",
",",
"const",
"double",
"*",
"points",
",",
"int",
"m",
",",
"double",
"*",
"sxy",
")",
"{",
"#define",
"dgr",
"\t(3+1)",
"\n",
"#define",
"nb2",
"\t(nb*2)",
"\n",
"int",
"i",
",",
"j",
";",
"double",
"x1t",
",",
"y1t",
";",
"double",
"o",
",",
"step",
";",
"double",
"X",
"[",
"nb2",
"]",
";",
"double",
"Y",
"[",
"nb2",
"]",
";",
"double",
"t",
"[",
"dgr",
"]",
";",
"double",
"Xpts",
"[",
"dgr",
"]",
";",
"double",
"Ypts",
"[",
"dgr",
"]",
";",
"double",
"s",
"[",
"nb2",
"]",
";",
"m",
"=",
"m",
";",
"g2_split",
"(",
"dgr",
",",
"points",
",",
"Xpts",
",",
"Ypts",
")",
";",
"t",
"[",
"0",
"]",
"=",
"0.",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"dgr",
";",
"i",
"++",
")",
"{",
"x1t",
"=",
"Xpts",
"[",
"i",
"]",
"-",
"Xpts",
"[",
"i",
"-",
"1",
"]",
";",
"y1t",
"=",
"Ypts",
"[",
"i",
"]",
"-",
"Ypts",
"[",
"i",
"-",
"1",
"]",
";",
"t",
"[",
"i",
"]",
"=",
"t",
"[",
"i",
"-",
"1",
"]",
"+",
"sqrt",
"(",
"x1t",
"*",
"x1t",
"+",
"y1t",
"*",
"y1t",
")",
";",
"}",
"step",
"=",
"t",
"[",
"2",
"]",
"/",
"nb2",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb2",
";",
"i",
"++",
")",
"s",
"[",
"i",
"]",
"=",
"i",
"*",
"step",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Xpts",
",",
"nb2",
",",
"s",
",",
"X",
")",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Ypts",
",",
"nb2",
",",
"s",
",",
"Y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb2",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"i",
"+",
"i",
"]",
"=",
"X",
"[",
"i",
"]",
";",
"sxy",
"[",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"Y",
"[",
"i",
"]",
";",
"}",
"for",
"(",
"j",
"=",
"1",
";",
"j",
"<",
"n",
"-",
"dgr",
"+",
"1",
";",
"j",
"++",
")",
"{",
"g2_split",
"(",
"dgr",
",",
"points",
"+",
"j",
"+",
"j",
",",
"Xpts",
",",
"Ypts",
")",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"dgr",
";",
"i",
"++",
")",
"{",
"x1t",
"=",
"Xpts",
"[",
"i",
"]",
"-",
"Xpts",
"[",
"i",
"-",
"1",
"]",
";",
"y1t",
"=",
"Ypts",
"[",
"i",
"]",
"-",
"Ypts",
"[",
"i",
"-",
"1",
"]",
";",
"t",
"[",
"i",
"]",
"=",
"t",
"[",
"i",
"-",
"1",
"]",
"+",
"sqrt",
"(",
"x1t",
"*",
"x1t",
"+",
"y1t",
"*",
"y1t",
")",
";",
"}",
"o",
"=",
"t",
"[",
"1",
"]",
";",
"step",
"=",
"(",
"t",
"[",
"2",
"]",
"-",
"o",
")",
"/",
"nb",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
";",
"i",
"++",
")",
"s",
"[",
"i",
"]",
"=",
"i",
"*",
"step",
"+",
"o",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Xpts",
",",
"nb",
",",
"s",
",",
"X",
")",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Ypts",
",",
"nb",
",",
"s",
",",
"Y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"(",
"j",
"+",
"1",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"]",
"=",
"X",
"[",
"i",
"]",
";",
"sxy",
"[",
"(",
"j",
"+",
"1",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"Y",
"[",
"i",
"]",
";",
"}",
"}",
"o",
"=",
"t",
"[",
"2",
"]",
";",
"step",
"=",
"(",
"t",
"[",
"3",
"]",
"-",
"o",
")",
"/",
"nb",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
";",
"i",
"++",
")",
"s",
"[",
"i",
"]",
"=",
"i",
"*",
"step",
"+",
"o",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Xpts",
",",
"nb",
",",
"s",
",",
"X",
")",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Ypts",
",",
"nb",
",",
"s",
",",
"Y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"(",
"n",
"-",
"dgr",
"+",
"2",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"]",
"=",
"X",
"[",
"i",
"]",
";",
"sxy",
"[",
"(",
"n",
"-",
"dgr",
"+",
"2",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"Y",
"[",
"i",
"]",
";",
"}",
"sxy",
"[",
"(",
"n",
"-",
"1",
")",
"*",
"nb2",
"]",
"=",
"points",
"[",
"n",
"+",
"n",
"-",
"2",
"]",
";",
"sxy",
"[",
"(",
"n",
"-",
"1",
")",
"*",
"nb2",
"+",
"1",
"]",
"=",
"points",
"[",
"n",
"+",
"n",
"-",
"1",
"]",
";",
"}"
] | #undef nb
#define nb 40
Number of straight connecting lines of which each polynomial consists. | [
"#undef",
"nb",
"#define",
"nb",
"40",
"Number",
"of",
"straight",
"connecting",
"lines",
"of",
"which",
"each",
"polynomial",
"consists",
"."
] | [
"/* x-coords of the current curve piece */",
"/* y-coords of the current curve piece */",
"/* data point parameter values */",
"/* x-coords data point subsection */",
"/* y-coords data point subsection */",
"/* parameter values at which to interpolate */",
"/* dummy argument; stop compiler complaints */",
"/* Do first TWO subintervals first */",
"/* Next, do later central subintervals */",
"/* look up once */",
"/* Now do last subinterval */"
] | [
{
"param": "n",
"type": "int"
},
{
"param": "points",
"type": "double"
},
{
"param": "m",
"type": "int"
},
{
"param": "sxy",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "points",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "m",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sxy",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ab893766af2ef0829a80c706a22a590b9a1dfe1 | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_splines.c | [
"Python-2.0"
] | C | g2_c_para_5 | void | void g2_c_para_5(int n, const double *points, int m, double *sxy)
{
#undef dgr
#define dgr (5+1)
#define nb3 (nb*3)
int i, j;
double x1t, y1t;
double o, step;
double X[nb3]; /* x-coords of the current curve piece */
double Y[nb3]; /* y-coords of the current curve piece */
double t[dgr]; /* data point parameter values */
double Xpts[dgr]; /* x-coords data point subsection */
double Ypts[dgr]; /* y-coords data point subsection */
double s[nb3]; /* parameter values at which to interpolate */
m = m; /* dummy argument; stop compiler complaints */
/* Do first THREE subintervals first */
g2_split(dgr, points, Xpts, Ypts);
t[0] = 0.;
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
step = t[3] / nb3;
for (i = 0; i < nb3; i++) s[i] = i * step;
g2_c_newton(dgr, t, Xpts, nb3, s, X);
g2_c_newton(dgr, t, Ypts, nb3, s, Y);
for (i = 0; i < nb3; i++) {
sxy[i+i] = X[i];
sxy[i+i+1] = Y[i];
}
/* Next, do later central subintervals */
for (j = 1; j < n - dgr + 1; j++) {
g2_split(dgr, points + j + j, Xpts, Ypts);
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
o = t[2]; /* look up once */
step = (t[3] - o) / nb;
for (i = 0; i < nb; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb, s, X);
g2_c_newton(dgr, t, Ypts, nb, s, Y);
for (i = 0; i < nb; i++) {
sxy[(j + 2) * nb2 + i + i] = X[i];
sxy[(j + 2) * nb2 + i + i + 1] = Y[i];
}
}
/* Now do last TWO subinterval */
o = t[3];
step = (t[5] - o) / nb2;
for (i = 0; i < nb2; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb2, s, X);
g2_c_newton(dgr, t, Ypts, nb2, s, Y);
for (i = 0; i < nb2; i++) {
sxy[(n - dgr + 3) * nb2 + i + i] = X[i];
sxy[(n - dgr + 3) * nb2 + i + i + 1] = Y[i];
}
sxy[(n - 1) * nb2] = points[n+n-2];
sxy[(n - 1) * nb2 + 1] = points[n+n-1];
} | /*
* Number of straight connecting lines of which each polynomial consists.
* So between one data point and the next, (nb-1) points are placed.
*/ | Number of straight connecting lines of which each polynomial consists.
So between one data point and the next, (nb-1) points are placed. | [
"Number",
"of",
"straight",
"connecting",
"lines",
"of",
"which",
"each",
"polynomial",
"consists",
".",
"So",
"between",
"one",
"data",
"point",
"and",
"the",
"next",
"(",
"nb",
"-",
"1",
")",
"points",
"are",
"placed",
"."
] | void g2_c_para_5(int n, const double *points, int m, double *sxy)
{
#undef dgr
#define dgr (5+1)
#define nb3 (nb*3)
int i, j;
double x1t, y1t;
double o, step;
double X[nb3];
double Y[nb3];
double t[dgr];
double Xpts[dgr];
double Ypts[dgr];
double s[nb3];
m = m;
g2_split(dgr, points, Xpts, Ypts);
t[0] = 0.;
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
step = t[3] / nb3;
for (i = 0; i < nb3; i++) s[i] = i * step;
g2_c_newton(dgr, t, Xpts, nb3, s, X);
g2_c_newton(dgr, t, Ypts, nb3, s, Y);
for (i = 0; i < nb3; i++) {
sxy[i+i] = X[i];
sxy[i+i+1] = Y[i];
}
for (j = 1; j < n - dgr + 1; j++) {
g2_split(dgr, points + j + j, Xpts, Ypts);
for (i = 1; i < dgr; i++) {
x1t = Xpts[i] - Xpts[i-1];
y1t = Ypts[i] - Ypts[i-1];
t[i] = t[i-1] + sqrt(x1t * x1t + y1t * y1t);
}
o = t[2];
step = (t[3] - o) / nb;
for (i = 0; i < nb; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb, s, X);
g2_c_newton(dgr, t, Ypts, nb, s, Y);
for (i = 0; i < nb; i++) {
sxy[(j + 2) * nb2 + i + i] = X[i];
sxy[(j + 2) * nb2 + i + i + 1] = Y[i];
}
}
o = t[3];
step = (t[5] - o) / nb2;
for (i = 0; i < nb2; i++) s[i] = i * step + o;
g2_c_newton(dgr, t, Xpts, nb2, s, X);
g2_c_newton(dgr, t, Ypts, nb2, s, Y);
for (i = 0; i < nb2; i++) {
sxy[(n - dgr + 3) * nb2 + i + i] = X[i];
sxy[(n - dgr + 3) * nb2 + i + i + 1] = Y[i];
}
sxy[(n - 1) * nb2] = points[n+n-2];
sxy[(n - 1) * nb2 + 1] = points[n+n-1];
} | [
"void",
"g2_c_para_5",
"(",
"int",
"n",
",",
"const",
"double",
"*",
"points",
",",
"int",
"m",
",",
"double",
"*",
"sxy",
")",
"{",
"#undef",
"\tdgr",
"\n",
"#define",
"dgr",
"\t(5+1)",
"\n",
"#define",
"nb3",
"\t(nb*3)",
"\n",
"int",
"i",
",",
"j",
";",
"double",
"x1t",
",",
"y1t",
";",
"double",
"o",
",",
"step",
";",
"double",
"X",
"[",
"nb3",
"]",
";",
"double",
"Y",
"[",
"nb3",
"]",
";",
"double",
"t",
"[",
"dgr",
"]",
";",
"double",
"Xpts",
"[",
"dgr",
"]",
";",
"double",
"Ypts",
"[",
"dgr",
"]",
";",
"double",
"s",
"[",
"nb3",
"]",
";",
"m",
"=",
"m",
";",
"g2_split",
"(",
"dgr",
",",
"points",
",",
"Xpts",
",",
"Ypts",
")",
";",
"t",
"[",
"0",
"]",
"=",
"0.",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"dgr",
";",
"i",
"++",
")",
"{",
"x1t",
"=",
"Xpts",
"[",
"i",
"]",
"-",
"Xpts",
"[",
"i",
"-",
"1",
"]",
";",
"y1t",
"=",
"Ypts",
"[",
"i",
"]",
"-",
"Ypts",
"[",
"i",
"-",
"1",
"]",
";",
"t",
"[",
"i",
"]",
"=",
"t",
"[",
"i",
"-",
"1",
"]",
"+",
"sqrt",
"(",
"x1t",
"*",
"x1t",
"+",
"y1t",
"*",
"y1t",
")",
";",
"}",
"step",
"=",
"t",
"[",
"3",
"]",
"/",
"nb3",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb3",
";",
"i",
"++",
")",
"s",
"[",
"i",
"]",
"=",
"i",
"*",
"step",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Xpts",
",",
"nb3",
",",
"s",
",",
"X",
")",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Ypts",
",",
"nb3",
",",
"s",
",",
"Y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb3",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"i",
"+",
"i",
"]",
"=",
"X",
"[",
"i",
"]",
";",
"sxy",
"[",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"Y",
"[",
"i",
"]",
";",
"}",
"for",
"(",
"j",
"=",
"1",
";",
"j",
"<",
"n",
"-",
"dgr",
"+",
"1",
";",
"j",
"++",
")",
"{",
"g2_split",
"(",
"dgr",
",",
"points",
"+",
"j",
"+",
"j",
",",
"Xpts",
",",
"Ypts",
")",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"dgr",
";",
"i",
"++",
")",
"{",
"x1t",
"=",
"Xpts",
"[",
"i",
"]",
"-",
"Xpts",
"[",
"i",
"-",
"1",
"]",
";",
"y1t",
"=",
"Ypts",
"[",
"i",
"]",
"-",
"Ypts",
"[",
"i",
"-",
"1",
"]",
";",
"t",
"[",
"i",
"]",
"=",
"t",
"[",
"i",
"-",
"1",
"]",
"+",
"sqrt",
"(",
"x1t",
"*",
"x1t",
"+",
"y1t",
"*",
"y1t",
")",
";",
"}",
"o",
"=",
"t",
"[",
"2",
"]",
";",
"step",
"=",
"(",
"t",
"[",
"3",
"]",
"-",
"o",
")",
"/",
"nb",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
";",
"i",
"++",
")",
"s",
"[",
"i",
"]",
"=",
"i",
"*",
"step",
"+",
"o",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Xpts",
",",
"nb",
",",
"s",
",",
"X",
")",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Ypts",
",",
"nb",
",",
"s",
",",
"Y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"(",
"j",
"+",
"2",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"]",
"=",
"X",
"[",
"i",
"]",
";",
"sxy",
"[",
"(",
"j",
"+",
"2",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"Y",
"[",
"i",
"]",
";",
"}",
"}",
"o",
"=",
"t",
"[",
"3",
"]",
";",
"step",
"=",
"(",
"t",
"[",
"5",
"]",
"-",
"o",
")",
"/",
"nb2",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb2",
";",
"i",
"++",
")",
"s",
"[",
"i",
"]",
"=",
"i",
"*",
"step",
"+",
"o",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Xpts",
",",
"nb2",
",",
"s",
",",
"X",
")",
";",
"g2_c_newton",
"(",
"dgr",
",",
"t",
",",
"Ypts",
",",
"nb2",
",",
"s",
",",
"Y",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nb2",
";",
"i",
"++",
")",
"{",
"sxy",
"[",
"(",
"n",
"-",
"dgr",
"+",
"3",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"]",
"=",
"X",
"[",
"i",
"]",
";",
"sxy",
"[",
"(",
"n",
"-",
"dgr",
"+",
"3",
")",
"*",
"nb2",
"+",
"i",
"+",
"i",
"+",
"1",
"]",
"=",
"Y",
"[",
"i",
"]",
";",
"}",
"sxy",
"[",
"(",
"n",
"-",
"1",
")",
"*",
"nb2",
"]",
"=",
"points",
"[",
"n",
"+",
"n",
"-",
"2",
"]",
";",
"sxy",
"[",
"(",
"n",
"-",
"1",
")",
"*",
"nb2",
"+",
"1",
"]",
"=",
"points",
"[",
"n",
"+",
"n",
"-",
"1",
"]",
";",
"}"
] | Number of straight connecting lines of which each polynomial consists. | [
"Number",
"of",
"straight",
"connecting",
"lines",
"of",
"which",
"each",
"polynomial",
"consists",
"."
] | [
"/* x-coords of the current curve piece */",
"/* y-coords of the current curve piece */",
"/* data point parameter values */",
"/* x-coords data point subsection */",
"/* y-coords data point subsection */",
"/* parameter values at which to interpolate */",
"/* dummy argument; stop compiler complaints */",
"/* Do first THREE subintervals first */",
"/* Next, do later central subintervals */",
"/* look up once */",
"/* Now do last TWO subinterval */"
] | [
{
"param": "n",
"type": "int"
},
{
"param": "points",
"type": "double"
},
{
"param": "m",
"type": "int"
},
{
"param": "sxy",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "points",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "m",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sxy",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8b870387c15e02ccd7c9776d9d0a4d176ed7446f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_device.c | [
"Python-2.0"
] | C | g2_device_exist | int | int g2_device_exist(int dix)
{
if(dix<0 || dix>=g2_dev_size ||
g2_dev[dix].t==g2_ILLEGAL || g2_dev[dix].t==g2_NDEV)
return 0;
return 1;
} | /*
*
* 1 if device exist otherwise 0
*
*/ | 1 if device exist otherwise 0 | [
"1",
"if",
"device",
"exist",
"otherwise",
"0"
] | int g2_device_exist(int dix)
{
if(dix<0 || dix>=g2_dev_size ||
g2_dev[dix].t==g2_ILLEGAL || g2_dev[dix].t==g2_NDEV)
return 0;
return 1;
} | [
"int",
"g2_device_exist",
"(",
"int",
"dix",
")",
"{",
"if",
"(",
"dix",
"<",
"0",
"||",
"dix",
">=",
"g2_dev_size",
"||",
"g2_dev",
"[",
"dix",
"]",
".",
"t",
"==",
"g2_ILLEGAL",
"||",
"g2_dev",
"[",
"dix",
"]",
".",
"t",
"==",
"g2_NDEV",
")",
"return",
"0",
";",
"return",
"1",
";",
"}"
] | 1 if device exist otherwise 0 | [
"1",
"if",
"device",
"exist",
"otherwise",
"0"
] | [] | [
{
"param": "dix",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dix",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8b870387c15e02ccd7c9776d9d0a4d176ed7446f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_device.c | [
"Python-2.0"
] | C | g2_get_free_device | int | int g2_get_free_device()
{
int i, dix;
if(g2_dev==NULL) { /* if NULL initialize */
g2_dev_size=1;
g2_dev=g2_malloc(sizeof(g2_device));
g2_dev[0].t=g2_NDEV; /* set to free */
g2_dev[0].d.pd=NULL; /* no device yet */
}
dix=-1;
for(i=0;i<g2_dev_size;i++) /* find empty place */
if(g2_dev[i].t==g2_NDEV) {
dix=i;
break;
}
if(dix<0) { /* no place for device */
dix=g2_dev_size++;
g2_dev=g2_realloc(g2_dev, g2_dev_size*sizeof(g2_device));
g2_dev[dix].t=g2_NDEV; /* set to free */
g2_dev[dix].d.pd=NULL; /* no device yet */
}
return dix;
} | /*
*
* get free place for new device
*
*/ | get free place for new device | [
"get",
"free",
"place",
"for",
"new",
"device"
] | int g2_get_free_device()
{
int i, dix;
if(g2_dev==NULL) {
g2_dev_size=1;
g2_dev=g2_malloc(sizeof(g2_device));
g2_dev[0].t=g2_NDEV;
g2_dev[0].d.pd=NULL;
}
dix=-1;
for(i=0;i<g2_dev_size;i++)
if(g2_dev[i].t==g2_NDEV) {
dix=i;
break;
}
if(dix<0) {
dix=g2_dev_size++;
g2_dev=g2_realloc(g2_dev, g2_dev_size*sizeof(g2_device));
g2_dev[dix].t=g2_NDEV;
g2_dev[dix].d.pd=NULL;
}
return dix;
} | [
"int",
"g2_get_free_device",
"(",
")",
"{",
"int",
"i",
",",
"dix",
";",
"if",
"(",
"g2_dev",
"==",
"NULL",
")",
"{",
"g2_dev_size",
"=",
"1",
";",
"g2_dev",
"=",
"g2_malloc",
"(",
"sizeof",
"(",
"g2_device",
")",
")",
";",
"g2_dev",
"[",
"0",
"]",
".",
"t",
"=",
"g2_NDEV",
";",
"g2_dev",
"[",
"0",
"]",
".",
"d",
".",
"pd",
"=",
"NULL",
";",
"}",
"dix",
"=",
"-1",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"g2_dev_size",
";",
"i",
"++",
")",
"if",
"(",
"g2_dev",
"[",
"i",
"]",
".",
"t",
"==",
"g2_NDEV",
")",
"{",
"dix",
"=",
"i",
";",
"break",
";",
"}",
"if",
"(",
"dix",
"<",
"0",
")",
"{",
"dix",
"=",
"g2_dev_size",
"++",
";",
"g2_dev",
"=",
"g2_realloc",
"(",
"g2_dev",
",",
"g2_dev_size",
"*",
"sizeof",
"(",
"g2_device",
")",
")",
";",
"g2_dev",
"[",
"dix",
"]",
".",
"t",
"=",
"g2_NDEV",
";",
"g2_dev",
"[",
"dix",
"]",
".",
"d",
".",
"pd",
"=",
"NULL",
";",
"}",
"return",
"dix",
";",
"}"
] | get free place for new device | [
"get",
"free",
"place",
"for",
"new",
"device"
] | [
"/* if NULL initialize */",
"/* set to free */",
"/* no device yet */",
"/* find empty place */",
"/* no place for device */",
"/* set to free */",
"/* no device yet */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_move_r | void | void g2_move_r(int dev, double dx, double dy)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_move_r: No such device: %d\n", dev);
return;
}
devp->x+=dx; /* set graph. cursor */
devp->y+=dy;
switch(devp->t) {
case g2_PD:
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_move_r(devp->d.vd->dix[i], dx, dy);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | /**
*
* Move graphic cursor relative to the currner graphical cursor position.
*
* \param dev device
* \param dx x coordinate increment
* \param dy y coordinate increment
*
* \ingroup graphic
*/ | Move graphic cursor relative to the currner graphical cursor position.
\param dev device
\param dx x coordinate increment
\param dy y coordinate increment
\ingroup graphic | [
"Move",
"graphic",
"cursor",
"relative",
"to",
"the",
"currner",
"graphical",
"cursor",
"position",
".",
"\\",
"param",
"dev",
"device",
"\\",
"param",
"dx",
"x",
"coordinate",
"increment",
"\\",
"param",
"dy",
"y",
"coordinate",
"increment",
"\\",
"ingroup",
"graphic"
] | void g2_move_r(int dev, double dx, double dy)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_move_r: No such device: %d\n", dev);
return;
}
devp->x+=dx;
devp->y+=dy;
switch(devp->t) {
case g2_PD:
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_move_r(devp->d.vd->dix[i], dx, dy);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | [
"void",
"g2_move_r",
"(",
"int",
"dev",
",",
"double",
"dx",
",",
"double",
"dy",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"devp",
"->",
"x",
"+=",
"dx",
";",
"devp",
"->",
"y",
"+=",
"dy",
";",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_move_r",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"dx",
",",
"dy",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Move graphic cursor relative to the currner graphical cursor position. | [
"Move",
"graphic",
"cursor",
"relative",
"to",
"the",
"currner",
"graphical",
"cursor",
"position",
"."
] | [
"/* set graph. cursor */"
] | [
{
"param": "dev",
"type": "int"
},
{
"param": "dx",
"type": "double"
},
{
"param": "dy",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dx",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dy",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_plot_r | void | void g2_plot_r(int dev, double rx, double ry)
{
g2_device *devp;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_plot_r: No such device: %d\n", dev);
return;
}
g2_plot(dev, devp->x+rx, devp->y+ry);
__g2_last_device=dev;
} | /**
*
* Plot a point relative to graphical cursor.
*
* \param dev device
* \param rx relative x coordinate
* \param ry relative y coordinate
*
* \ingroup graphic
*/ | Plot a point relative to graphical cursor.
\param dev device
\param rx relative x coordinate
\param ry relative y coordinate
\ingroup graphic | [
"Plot",
"a",
"point",
"relative",
"to",
"graphical",
"cursor",
".",
"\\",
"param",
"dev",
"device",
"\\",
"param",
"rx",
"relative",
"x",
"coordinate",
"\\",
"param",
"ry",
"relative",
"y",
"coordinate",
"\\",
"ingroup",
"graphic"
] | void g2_plot_r(int dev, double rx, double ry)
{
g2_device *devp;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_plot_r: No such device: %d\n", dev);
return;
}
g2_plot(dev, devp->x+rx, devp->y+ry);
__g2_last_device=dev;
} | [
"void",
"g2_plot_r",
"(",
"int",
"dev",
",",
"double",
"rx",
",",
"double",
"ry",
")",
"{",
"g2_device",
"*",
"devp",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"g2_plot",
"(",
"dev",
",",
"devp",
"->",
"x",
"+",
"rx",
",",
"devp",
"->",
"y",
"+",
"ry",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Plot a point relative to graphical cursor. | [
"Plot",
"a",
"point",
"relative",
"to",
"graphical",
"cursor",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "rx",
"type": "double"
},
{
"param": "ry",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rx",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ry",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_line_r | void | void g2_line_r(int dev, double dx, double dy)
{
g2_device *devp;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_line_r: No such device: %d\n", dev);
return;
}
g2_line(dev, devp->x, devp->y, devp->x+dx, devp->y+dy);
__g2_last_device=dev;
} | /**
*
* Draw line relative to the graphic cursor.
*
* \param dev device
* \param dx relative x coordinate
* \param dy relative y coordinate
*
* \ingroup graphic
*/ | Draw line relative to the graphic cursor.
\param dev device
\param dx relative x coordinate
\param dy relative y coordinate
\ingroup graphic | [
"Draw",
"line",
"relative",
"to",
"the",
"graphic",
"cursor",
".",
"\\",
"param",
"dev",
"device",
"\\",
"param",
"dx",
"relative",
"x",
"coordinate",
"\\",
"param",
"dy",
"relative",
"y",
"coordinate",
"\\",
"ingroup",
"graphic"
] | void g2_line_r(int dev, double dx, double dy)
{
g2_device *devp;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_line_r: No such device: %d\n", dev);
return;
}
g2_line(dev, devp->x, devp->y, devp->x+dx, devp->y+dy);
__g2_last_device=dev;
} | [
"void",
"g2_line_r",
"(",
"int",
"dev",
",",
"double",
"dx",
",",
"double",
"dy",
")",
"{",
"g2_device",
"*",
"devp",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"g2_line",
"(",
"dev",
",",
"devp",
"->",
"x",
",",
"devp",
"->",
"y",
",",
"devp",
"->",
"x",
"+",
"dx",
",",
"devp",
"->",
"y",
"+",
"dy",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Draw line relative to the graphic cursor. | [
"Draw",
"line",
"relative",
"to",
"the",
"graphic",
"cursor",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "dx",
"type": "double"
},
{
"param": "dy",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dx",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dy",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_triangle | void | void g2_triangle(int dev,
double x1, double y1,
double x2, double y2,
double x3, double y3)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_triangle: No such device: %d\n", dev);
return;
}
devp->x=x3;
devp->y=y3;
switch(devp->t) {
case g2_PD:
g2_triangle_pd(devp->d.pd,
x1, y1,
x2, y2,
x3, y3);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_triangle(devp->d.vd->dix[i], x1, y1, x2, y2, x3, y3);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | /**
*
* Draw a triangle described by 3 corner points.
*
* \param dev device
* \param x1 x coordinate of the 1st corner
* \param y1 y coordinate of the 1st corner
* \param x2 x coordinate of the 2nd corner
* \param y2 y coordinate of the 2nd corner
* \param x3 x coordinate of the 3rd corner
* \param y3 y coordinate of the 3rd corner
*
* \ingroup graphic
*/ | Draw a triangle described by 3 corner points.
\ingroup graphic | [
"Draw",
"a",
"triangle",
"described",
"by",
"3",
"corner",
"points",
".",
"\\",
"ingroup",
"graphic"
] | void g2_triangle(int dev,
double x1, double y1,
double x2, double y2,
double x3, double y3)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_triangle: No such device: %d\n", dev);
return;
}
devp->x=x3;
devp->y=y3;
switch(devp->t) {
case g2_PD:
g2_triangle_pd(devp->d.pd,
x1, y1,
x2, y2,
x3, y3);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_triangle(devp->d.vd->dix[i], x1, y1, x2, y2, x3, y3);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | [
"void",
"g2_triangle",
"(",
"int",
"dev",
",",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"x2",
",",
"double",
"y2",
",",
"double",
"x3",
",",
"double",
"y3",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"devp",
"->",
"x",
"=",
"x3",
";",
"devp",
"->",
"y",
"=",
"y3",
";",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_triangle_pd",
"(",
"devp",
"->",
"d",
".",
"pd",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"x3",
",",
"y3",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_triangle",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"x3",
",",
"y3",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"if",
"(",
"devp",
"->",
"auto_flush",
")",
"g2_flush",
"(",
"dev",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Draw a triangle described by 3 corner points. | [
"Draw",
"a",
"triangle",
"described",
"by",
"3",
"corner",
"points",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x1",
"type": "double"
},
{
"param": "y1",
"type": "double"
},
{
"param": "x2",
"type": "double"
},
{
"param": "y2",
"type": "double"
},
{
"param": "x3",
"type": "double"
},
{
"param": "y3",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x3",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y3",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_filled_triangle | void | void g2_filled_triangle(int dev,
double x1, double y1,
double x2, double y2,
double x3, double y3)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_filled_triangle: No such device: %d\n", dev);
return;
}
devp->x=x3;
devp->y=y3;
switch(devp->t) {
case g2_PD:
g2_filled_triangle_pd(devp->d.pd,
x1, y1,
x2, y2,
x3, y3);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_filled_triangle(devp->d.vd->dix[i], x1, y1, x2, y2, x3, y3);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | /**
*
* Draw a filled triangle specified by the 3 corner points.
*
* \param dev device
* \param x1 x coordinate of the 1st corner
* \param y1 y coordinate of the 1st corner
* \param x2 x coordinate of the 2nd corner
* \param y2 y coordinate of the 2nd corner
* \param x3 x coordinate of the 3rd corner
* \param y3 y coordinate of the 3rd corner
*
* \ingroup graphic
*/ | Draw a filled triangle specified by the 3 corner points.
\ingroup graphic | [
"Draw",
"a",
"filled",
"triangle",
"specified",
"by",
"the",
"3",
"corner",
"points",
".",
"\\",
"ingroup",
"graphic"
] | void g2_filled_triangle(int dev,
double x1, double y1,
double x2, double y2,
double x3, double y3)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_filled_triangle: No such device: %d\n", dev);
return;
}
devp->x=x3;
devp->y=y3;
switch(devp->t) {
case g2_PD:
g2_filled_triangle_pd(devp->d.pd,
x1, y1,
x2, y2,
x3, y3);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_filled_triangle(devp->d.vd->dix[i], x1, y1, x2, y2, x3, y3);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | [
"void",
"g2_filled_triangle",
"(",
"int",
"dev",
",",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"x2",
",",
"double",
"y2",
",",
"double",
"x3",
",",
"double",
"y3",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"devp",
"->",
"x",
"=",
"x3",
";",
"devp",
"->",
"y",
"=",
"y3",
";",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_filled_triangle_pd",
"(",
"devp",
"->",
"d",
".",
"pd",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"x3",
",",
"y3",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_filled_triangle",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"x3",
",",
"y3",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"if",
"(",
"devp",
"->",
"auto_flush",
")",
"g2_flush",
"(",
"dev",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Draw a filled triangle specified by the 3 corner points. | [
"Draw",
"a",
"filled",
"triangle",
"specified",
"by",
"the",
"3",
"corner",
"points",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x1",
"type": "double"
},
{
"param": "y1",
"type": "double"
},
{
"param": "x2",
"type": "double"
},
{
"param": "y2",
"type": "double"
},
{
"param": "x3",
"type": "double"
},
{
"param": "y3",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x3",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y3",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_rectangle | void | void g2_rectangle(int dev, double x1, double y1, double x2, double y2)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_rectangle: No such device: %d\n", dev);
return;
}
devp->x=x2;
devp->y=y2;
switch(devp->t) {
case g2_PD:
g2_rectangle_pd(devp->d.pd, x1, y1, x2, y2);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_rectangle(devp->d.vd->dix[i], x1, y1, x2, y2);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | /**
*
* Draw a rectangle specified by the two opposite corner points.
*
* \param dev device
* \param x1 x coordinate of the 1st corner
* \param y1 y coordinate of the 1st corner
* \param x2 x coordinate of the 3rd corner
* \param y2 y coordinate of the 3rd corner
*
* \ingroup graphic
*/ | Draw a rectangle specified by the two opposite corner points.
\ingroup graphic | [
"Draw",
"a",
"rectangle",
"specified",
"by",
"the",
"two",
"opposite",
"corner",
"points",
".",
"\\",
"ingroup",
"graphic"
] | void g2_rectangle(int dev, double x1, double y1, double x2, double y2)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_rectangle: No such device: %d\n", dev);
return;
}
devp->x=x2;
devp->y=y2;
switch(devp->t) {
case g2_PD:
g2_rectangle_pd(devp->d.pd, x1, y1, x2, y2);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_rectangle(devp->d.vd->dix[i], x1, y1, x2, y2);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | [
"void",
"g2_rectangle",
"(",
"int",
"dev",
",",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"x2",
",",
"double",
"y2",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"devp",
"->",
"x",
"=",
"x2",
";",
"devp",
"->",
"y",
"=",
"y2",
";",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_rectangle_pd",
"(",
"devp",
"->",
"d",
".",
"pd",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_rectangle",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"if",
"(",
"devp",
"->",
"auto_flush",
")",
"g2_flush",
"(",
"dev",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Draw a rectangle specified by the two opposite corner points. | [
"Draw",
"a",
"rectangle",
"specified",
"by",
"the",
"two",
"opposite",
"corner",
"points",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x1",
"type": "double"
},
{
"param": "y1",
"type": "double"
},
{
"param": "x2",
"type": "double"
},
{
"param": "y2",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_filled_rectangle | void | void g2_filled_rectangle(int dev, double x1, double y1, double x2, double y2)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_filled_rectangle: No such device: %d\n", dev);
return;
}
devp->x=x2;
devp->y=y2;
switch(devp->t) {
case g2_PD:
g2_filled_rectangle_pd(devp->d.pd, x1, y1, x2, y2);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_filled_rectangle(devp->d.vd->dix[i], x1, y1, x2, y2);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | /**
*
* Draw a filled rectangle specified by the two opposite corner points.
*
* \param dev device
* \param x1 x coordinate of the 1st corner
* \param y1 y coordinate of the 1st corner
* \param x2 x coordinate of the 3rd corner
* \param y2 y coordinate of the 3rd corner
*
* \ingroup graphic
*/ | Draw a filled rectangle specified by the two opposite corner points.
\ingroup graphic | [
"Draw",
"a",
"filled",
"rectangle",
"specified",
"by",
"the",
"two",
"opposite",
"corner",
"points",
".",
"\\",
"ingroup",
"graphic"
] | void g2_filled_rectangle(int dev, double x1, double y1, double x2, double y2)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_filled_rectangle: No such device: %d\n", dev);
return;
}
devp->x=x2;
devp->y=y2;
switch(devp->t) {
case g2_PD:
g2_filled_rectangle_pd(devp->d.pd, x1, y1, x2, y2);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_filled_rectangle(devp->d.vd->dix[i], x1, y1, x2, y2);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | [
"void",
"g2_filled_rectangle",
"(",
"int",
"dev",
",",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"x2",
",",
"double",
"y2",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"devp",
"->",
"x",
"=",
"x2",
";",
"devp",
"->",
"y",
"=",
"y2",
";",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_filled_rectangle_pd",
"(",
"devp",
"->",
"d",
".",
"pd",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_filled_rectangle",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"if",
"(",
"devp",
"->",
"auto_flush",
")",
"g2_flush",
"(",
"dev",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Draw a filled rectangle specified by the two opposite corner points. | [
"Draw",
"a",
"filled",
"rectangle",
"specified",
"by",
"the",
"two",
"opposite",
"corner",
"points",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x1",
"type": "double"
},
{
"param": "y1",
"type": "double"
},
{
"param": "x2",
"type": "double"
},
{
"param": "y2",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y1",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y2",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_filled_circle | void | void g2_filled_circle(int dev, double x, double y, double r)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_filled_circle: No such device: %d\n", dev);
return;
}
devp->x=x;
devp->y=y;
switch(devp->t) {
case g2_PD:
g2_filled_circle_pd(devp->d.pd, x, y, r);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_filled_circle(devp->d.vd->dix[i], x, y, r);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | /**
*
* Draw a filled circle.
*
* \param dev device
* \param x x coordinate of the center
* \param y y coordinate of the center
* \param r radius
*
* \ingroup graphic
*/ | Draw a filled circle.
\param dev device
\param x x coordinate of the center
\param y y coordinate of the center
\param r radius
\ingroup graphic | [
"Draw",
"a",
"filled",
"circle",
".",
"\\",
"param",
"dev",
"device",
"\\",
"param",
"x",
"x",
"coordinate",
"of",
"the",
"center",
"\\",
"param",
"y",
"y",
"coordinate",
"of",
"the",
"center",
"\\",
"param",
"r",
"radius",
"\\",
"ingroup",
"graphic"
] | void g2_filled_circle(int dev, double x, double y, double r)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_filled_circle: No such device: %d\n", dev);
return;
}
devp->x=x;
devp->y=y;
switch(devp->t) {
case g2_PD:
g2_filled_circle_pd(devp->d.pd, x, y, r);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_filled_circle(devp->d.vd->dix[i], x, y, r);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | [
"void",
"g2_filled_circle",
"(",
"int",
"dev",
",",
"double",
"x",
",",
"double",
"y",
",",
"double",
"r",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"devp",
"->",
"x",
"=",
"x",
";",
"devp",
"->",
"y",
"=",
"y",
";",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_filled_circle_pd",
"(",
"devp",
"->",
"d",
".",
"pd",
",",
"x",
",",
"y",
",",
"r",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_filled_circle",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"x",
",",
"y",
",",
"r",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"if",
"(",
"devp",
"->",
"auto_flush",
")",
"g2_flush",
"(",
"dev",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Draw a filled circle. | [
"Draw",
"a",
"filled",
"circle",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x",
"type": "double"
},
{
"param": "y",
"type": "double"
},
{
"param": "r",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8e1c015c6ba49a9c91ad7a8979736e93346d14f | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_graphic.c | [
"Python-2.0"
] | C | g2_plot_QP | void | void g2_plot_QP(int dev, double x, double y)
{
g2_device *devp;
double d;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_plot_QP: No such device: %d\n", dev);
return;
}
x=dtoi(x);
y=dtoi(y);
d=devp->QPd;
switch(devp->QPshape) {
case QPrect:
g2_filled_rectangle(dev, x*d-d/2, y*d-d/2, x*d+d/2, y*d+d/2);
break;
case QPcirc:
g2_filled_circle(dev, x*d, y*d, d/2.0);
break;
default:
fprintf(stderr, "g2: QP: unknown shape\n");
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | /**
*
* Quasi Pixel fake. Quasi pixel is introduced to make easier
* plotting of cellular automata and related pictures. QP is simple a big pixel as
* specified by g2_set_QP(). Coordinates are skaled accordingly, so no recalculation
* is needed on client side.
*
* \param dev device
* \param x x coordinate
* \param y y coordinate
*
* \ingroup graphic
*/ | Quasi Pixel fake. Quasi pixel is introduced to make easier
plotting of cellular automata and related pictures. QP is simple a big pixel as
specified by g2_set_QP(). Coordinates are skaled accordingly, so no recalculation
is needed on client side.
\param dev device
\param x x coordinate
\param y y coordinate
\ingroup graphic | [
"Quasi",
"Pixel",
"fake",
".",
"Quasi",
"pixel",
"is",
"introduced",
"to",
"make",
"easier",
"plotting",
"of",
"cellular",
"automata",
"and",
"related",
"pictures",
".",
"QP",
"is",
"simple",
"a",
"big",
"pixel",
"as",
"specified",
"by",
"g2_set_QP",
"()",
".",
"Coordinates",
"are",
"skaled",
"accordingly",
"so",
"no",
"recalculation",
"is",
"needed",
"on",
"client",
"side",
".",
"\\",
"param",
"dev",
"device",
"\\",
"param",
"x",
"x",
"coordinate",
"\\",
"param",
"y",
"y",
"coordinate",
"\\",
"ingroup",
"graphic"
] | void g2_plot_QP(int dev, double x, double y)
{
g2_device *devp;
double d;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_plot_QP: No such device: %d\n", dev);
return;
}
x=dtoi(x);
y=dtoi(y);
d=devp->QPd;
switch(devp->QPshape) {
case QPrect:
g2_filled_rectangle(dev, x*d-d/2, y*d-d/2, x*d+d/2, y*d+d/2);
break;
case QPcirc:
g2_filled_circle(dev, x*d, y*d, d/2.0);
break;
default:
fprintf(stderr, "g2: QP: unknown shape\n");
break;
}
if(devp->auto_flush)
g2_flush(dev);
__g2_last_device=dev;
} | [
"void",
"g2_plot_QP",
"(",
"int",
"dev",
",",
"double",
"x",
",",
"double",
"y",
")",
"{",
"g2_device",
"*",
"devp",
";",
"double",
"d",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"x",
"=",
"dtoi",
"(",
"x",
")",
";",
"y",
"=",
"dtoi",
"(",
"y",
")",
";",
"d",
"=",
"devp",
"->",
"QPd",
";",
"switch",
"(",
"devp",
"->",
"QPshape",
")",
"{",
"case",
"QPrect",
":",
"g2_filled_rectangle",
"(",
"dev",
",",
"x",
"*",
"d",
"-",
"d",
"/",
"2",
",",
"y",
"*",
"d",
"-",
"d",
"/",
"2",
",",
"x",
"*",
"d",
"+",
"d",
"/",
"2",
",",
"y",
"*",
"d",
"+",
"d",
"/",
"2",
")",
";",
"break",
";",
"case",
"QPcirc",
":",
"g2_filled_circle",
"(",
"dev",
",",
"x",
"*",
"d",
",",
"y",
"*",
"d",
",",
"d",
"/",
"2.0",
")",
";",
"break",
";",
"default",
":",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"}",
"if",
"(",
"devp",
"->",
"auto_flush",
")",
"g2_flush",
"(",
"dev",
")",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Quasi Pixel fake. | [
"Quasi",
"Pixel",
"fake",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x",
"type": "double"
},
{
"param": "y",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
918c79cc9fe62dd93065b944f9f58412a300aa64 | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_virtual_device.c | [
"Python-2.0"
] | C | g2_is_attached | int | int g2_is_attached(int vd, int dev)
{
g2_device *vdp, *devp;
int i;
if(vd==dev)
return 1;
if((devp=g2_get_device_pointer(dev))==NULL)
return 0;
if((vdp=g2_get_device_pointer(vd))==NULL)
return 0;
if(devp==vdp)
return 1;
if(vdp->t!=g2_VD)
return 0;
for(i=0;i<vdp->d.vd->N;i++) {
if(vdp->d.vd->dix[i]==dev)
return 1;
if(g2_is_attached(vdp->d.vd->dix[i], dev))
return 1;
}
return 0;
} | /*
* Return 1 if dev is attached to vd
*/ | Return 1 if dev is attached to vd | [
"Return",
"1",
"if",
"dev",
"is",
"attached",
"to",
"vd"
] | int g2_is_attached(int vd, int dev)
{
g2_device *vdp, *devp;
int i;
if(vd==dev)
return 1;
if((devp=g2_get_device_pointer(dev))==NULL)
return 0;
if((vdp=g2_get_device_pointer(vd))==NULL)
return 0;
if(devp==vdp)
return 1;
if(vdp->t!=g2_VD)
return 0;
for(i=0;i<vdp->d.vd->N;i++) {
if(vdp->d.vd->dix[i]==dev)
return 1;
if(g2_is_attached(vdp->d.vd->dix[i], dev))
return 1;
}
return 0;
} | [
"int",
"g2_is_attached",
"(",
"int",
"vd",
",",
"int",
"dev",
")",
"{",
"g2_device",
"*",
"vdp",
",",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"vd",
"==",
"dev",
")",
"return",
"1",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"return",
"0",
";",
"if",
"(",
"(",
"vdp",
"=",
"g2_get_device_pointer",
"(",
"vd",
")",
")",
"==",
"NULL",
")",
"return",
"0",
";",
"if",
"(",
"devp",
"==",
"vdp",
")",
"return",
"1",
";",
"if",
"(",
"vdp",
"->",
"t",
"!=",
"g2_VD",
")",
"return",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"vdp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"{",
"if",
"(",
"vdp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
"==",
"dev",
")",
"return",
"1",
";",
"if",
"(",
"g2_is_attached",
"(",
"vdp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"dev",
")",
")",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | Return 1 if dev is attached to vd | [
"Return",
"1",
"if",
"dev",
"is",
"attached",
"to",
"vd"
] | [] | [
{
"param": "vd",
"type": "int"
},
{
"param": "dev",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vd",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c8b7154c7117bab033e0aaccbf6b5e7895465d5b | threadmapper/ViennaRNA | src/bin/RNAup.c | [
"Python-2.0"
] | C | tokenize | void | void
tokenize(char *line,
char **seq1,
char **seq2)
{
char *pos;
int cut = -1;
pos = strchr(line, '&');
if (pos) {
cut = (int)(pos - line) + 1;
(*seq1) = (char *)vrna_alloc((cut + 1) * sizeof(char));
(*seq2) = (char *)vrna_alloc(((strlen(line) - cut) + 2) * sizeof(char));
if (strchr(pos + 1, '&'))
vrna_message_error("more than one cut-point in input");
*pos = '\0';
(void)sscanf(line, "%s", *seq1);
(void)sscanf(pos + 1, "%s", *seq2);
} else {
(*seq1) = (char *)vrna_alloc((strlen(line) + 1) * sizeof(char));
(*seq2) = NULL;
sscanf(line, "%s", *seq1);
}
if (cut > -1) {
if (cut_point == -1) {
cut_point = cut;
} else if (cut_point != cut) {
fprintf(stderr, "cut_point = %d cut = %d\n", cut_point, cut);
vrna_message_error("Sequence and Structure have different cut points.");
}
}
free(line);
return;
} | /* using sscanf instead of strcpy get's rid of trainling junk on the input line */ | using sscanf instead of strcpy get's rid of trainling junk on the input line | [
"using",
"sscanf",
"instead",
"of",
"strcpy",
"get",
"'",
"s",
"rid",
"of",
"trainling",
"junk",
"on",
"the",
"input",
"line"
] | void
tokenize(char *line,
char **seq1,
char **seq2)
{
char *pos;
int cut = -1;
pos = strchr(line, '&');
if (pos) {
cut = (int)(pos - line) + 1;
(*seq1) = (char *)vrna_alloc((cut + 1) * sizeof(char));
(*seq2) = (char *)vrna_alloc(((strlen(line) - cut) + 2) * sizeof(char));
if (strchr(pos + 1, '&'))
vrna_message_error("more than one cut-point in input");
*pos = '\0';
(void)sscanf(line, "%s", *seq1);
(void)sscanf(pos + 1, "%s", *seq2);
} else {
(*seq1) = (char *)vrna_alloc((strlen(line) + 1) * sizeof(char));
(*seq2) = NULL;
sscanf(line, "%s", *seq1);
}
if (cut > -1) {
if (cut_point == -1) {
cut_point = cut;
} else if (cut_point != cut) {
fprintf(stderr, "cut_point = %d cut = %d\n", cut_point, cut);
vrna_message_error("Sequence and Structure have different cut points.");
}
}
free(line);
return;
} | [
"void",
"tokenize",
"(",
"char",
"*",
"line",
",",
"char",
"*",
"*",
"seq1",
",",
"char",
"*",
"*",
"seq2",
")",
"{",
"char",
"*",
"pos",
";",
"int",
"cut",
"=",
"-1",
";",
"pos",
"=",
"strchr",
"(",
"line",
",",
"'",
"'",
")",
";",
"if",
"(",
"pos",
")",
"{",
"cut",
"=",
"(",
"int",
")",
"(",
"pos",
"-",
"line",
")",
"+",
"1",
";",
"(",
"*",
"seq1",
")",
"=",
"(",
"char",
"*",
")",
"vrna_alloc",
"(",
"(",
"cut",
"+",
"1",
")",
"*",
"sizeof",
"(",
"char",
")",
")",
";",
"(",
"*",
"seq2",
")",
"=",
"(",
"char",
"*",
")",
"vrna_alloc",
"(",
"(",
"(",
"strlen",
"(",
"line",
")",
"-",
"cut",
")",
"+",
"2",
")",
"*",
"sizeof",
"(",
"char",
")",
")",
";",
"if",
"(",
"strchr",
"(",
"pos",
"+",
"1",
",",
"'",
"'",
")",
")",
"vrna_message_error",
"(",
"\"",
"\"",
")",
";",
"*",
"pos",
"=",
"'",
"\\0",
"'",
";",
"(",
"void",
")",
"sscanf",
"(",
"line",
",",
"\"",
"\"",
",",
"*",
"seq1",
")",
";",
"(",
"void",
")",
"sscanf",
"(",
"pos",
"+",
"1",
",",
"\"",
"\"",
",",
"*",
"seq2",
")",
";",
"}",
"else",
"{",
"(",
"*",
"seq1",
")",
"=",
"(",
"char",
"*",
")",
"vrna_alloc",
"(",
"(",
"strlen",
"(",
"line",
")",
"+",
"1",
")",
"*",
"sizeof",
"(",
"char",
")",
")",
";",
"(",
"*",
"seq2",
")",
"=",
"NULL",
";",
"sscanf",
"(",
"line",
",",
"\"",
"\"",
",",
"*",
"seq1",
")",
";",
"}",
"if",
"(",
"cut",
">",
"-1",
")",
"{",
"if",
"(",
"cut_point",
"==",
"-1",
")",
"{",
"cut_point",
"=",
"cut",
";",
"}",
"else",
"if",
"(",
"cut_point",
"!=",
"cut",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"cut_point",
",",
"cut",
")",
";",
"vrna_message_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"free",
"(",
"line",
")",
";",
"return",
";",
"}"
] | using sscanf instead of strcpy get's rid of trainling junk on the input line | [
"using",
"sscanf",
"instead",
"of",
"strcpy",
"get",
"'",
"s",
"rid",
"of",
"trainling",
"junk",
"on",
"the",
"input",
"line"
] | [] | [
{
"param": "line",
"type": "char"
},
{
"param": "seq1",
"type": "char"
},
{
"param": "seq2",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "line",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seq1",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seq2",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c8b7154c7117bab033e0aaccbf6b5e7895465d5b | threadmapper/ViennaRNA | src/bin/RNAup.c | [
"Python-2.0"
] | C | seperate_bp | void | void
seperate_bp(char **inter,
int len1,
char **intra_l,
char **intra_s)
{
int i, j, len;
short *pt = NULL;
char *temp_inter, *pt_inter;
len = strlen((*inter));
/* printf("inter\n%s\n",(*inter)); */
i = len + 1;
temp_inter = (char *)vrna_alloc(sizeof(char) * i);
/* to make a pair_table convert <|> to (|) */
pt_inter = (char *)vrna_alloc(sizeof(char) * i);
/* if shorter seq is first seq in constrained string, write the
* longer one as the first one */
temp_inter[strlen((*inter))] = '\0';
pt_inter[strlen((*inter))] = '\0';
if (cut_point < len1) {
/* write the constrain for the longer seq first */
for (j = 0, i = cut_point - 1; i < len; i++, j++) {
switch ((*inter)[i]) {
case '(':
temp_inter[j] = ')';
pt_inter[j] = ')';
break;
case ')':
temp_inter[j] = '(';
pt_inter[j] = '(';
break;
default:
temp_inter[j] = (*inter)[i];
pt_inter[j] = '.';
}
}
/* then add the constrain for the shorter seq */
for (i = 0; i < cut_point - 1; i++, j++) {
switch ((*inter)[i]) {
case '(':
temp_inter[j] = ')';
pt_inter[j] = ')';
break;
case ')':
temp_inter[j] = '(';
pt_inter[j] = '(';
break;
default:
temp_inter[j] = (*inter)[i];
pt_inter[j] = '.';
}
}
cut_point = len1 + 1;
strcpy((*inter), temp_inter);
} else {
for (i = 0; i < strlen((*inter)); i++) {
switch ((*inter)[i]) {
case '(':
pt_inter[i] = '(';
break;
case ')':
pt_inter[i] = ')';
break;
default:
pt_inter[i] = '.';
}
}
}
pt = vrna_ptable(pt_inter);
/* intramolecular structure in longer (_l) and shorter (_s) seq */
(*intra_l) = (char *)vrna_alloc(sizeof(char) * (len1 + 1));
(*intra_s) = (char *)vrna_alloc(sizeof(char) * (strlen((*inter)) - len1 + 2));
(*intra_l)[len1] = '\0';
(*intra_s)[strlen((*inter)) - len1 + 1] = '\0';
/* now seperate intermolecular from intramolecular bp */
for (i = 1; i <= pt[0]; i++) {
if (pt[i] == 0) {
temp_inter[i - 1] = (*inter)[i - 1];
if (i < cut_point) {
(*intra_l)[i - 1] = (*inter)[i - 1];
if ((*inter)[i - 1] == '|')
(*intra_l)[i - 1] = '.';
} else {
(*intra_s)[i - cut_point] = (*inter)[i - 1];
if ((*inter)[i - 1] == '|')
(*intra_s)[i - cut_point] = '.';
}
} else {
if (i < cut_point) {
/* intermolekular bp */
if (pt[i] >= cut_point) {
temp_inter[i - 1] = (*inter)[i - 1];
(*intra_l)[i - 1] = '.';
(*intra_s)[pt[i] - cut_point] = '.';
} else {
/* intramolekular bp */
(*intra_l)[i - 1] = (*inter)[i - 1];
temp_inter[i - 1] = '.';
}
} else {
/* i>=cut_point */
/* intermolekular bp */
if (pt[i] < cut_point) {
temp_inter[i - 1] = (*inter)[i - 1];
/* (*intra_s)[i-1] = '.'; */
} else {
/* intramolekular bp */
(*intra_s)[i - cut_point] = (*inter)[i - 1];
temp_inter[i - 1] = '.';
}
}
}
}
/* printf("%s -1\n%s -2\n%s -3\n%s -4\n",(*inter),temp_inter,(*intra_l),(*intra_s)); */
strcpy((*inter), temp_inter);
free(temp_inter);
free(pt_inter);
free(pt);
} | /* len1 is the length of the LONGER input seq ! */ | len1 is the length of the LONGER input seq ! | [
"len1",
"is",
"the",
"length",
"of",
"the",
"LONGER",
"input",
"seq",
"!"
] | void
seperate_bp(char **inter,
int len1,
char **intra_l,
char **intra_s)
{
int i, j, len;
short *pt = NULL;
char *temp_inter, *pt_inter;
len = strlen((*inter));
i = len + 1;
temp_inter = (char *)vrna_alloc(sizeof(char) * i);
pt_inter = (char *)vrna_alloc(sizeof(char) * i);
temp_inter[strlen((*inter))] = '\0';
pt_inter[strlen((*inter))] = '\0';
if (cut_point < len1) {
for (j = 0, i = cut_point - 1; i < len; i++, j++) {
switch ((*inter)[i]) {
case '(':
temp_inter[j] = ')';
pt_inter[j] = ')';
break;
case ')':
temp_inter[j] = '(';
pt_inter[j] = '(';
break;
default:
temp_inter[j] = (*inter)[i];
pt_inter[j] = '.';
}
}
for (i = 0; i < cut_point - 1; i++, j++) {
switch ((*inter)[i]) {
case '(':
temp_inter[j] = ')';
pt_inter[j] = ')';
break;
case ')':
temp_inter[j] = '(';
pt_inter[j] = '(';
break;
default:
temp_inter[j] = (*inter)[i];
pt_inter[j] = '.';
}
}
cut_point = len1 + 1;
strcpy((*inter), temp_inter);
} else {
for (i = 0; i < strlen((*inter)); i++) {
switch ((*inter)[i]) {
case '(':
pt_inter[i] = '(';
break;
case ')':
pt_inter[i] = ')';
break;
default:
pt_inter[i] = '.';
}
}
}
pt = vrna_ptable(pt_inter);
(*intra_l) = (char *)vrna_alloc(sizeof(char) * (len1 + 1));
(*intra_s) = (char *)vrna_alloc(sizeof(char) * (strlen((*inter)) - len1 + 2));
(*intra_l)[len1] = '\0';
(*intra_s)[strlen((*inter)) - len1 + 1] = '\0';
for (i = 1; i <= pt[0]; i++) {
if (pt[i] == 0) {
temp_inter[i - 1] = (*inter)[i - 1];
if (i < cut_point) {
(*intra_l)[i - 1] = (*inter)[i - 1];
if ((*inter)[i - 1] == '|')
(*intra_l)[i - 1] = '.';
} else {
(*intra_s)[i - cut_point] = (*inter)[i - 1];
if ((*inter)[i - 1] == '|')
(*intra_s)[i - cut_point] = '.';
}
} else {
if (i < cut_point) {
if (pt[i] >= cut_point) {
temp_inter[i - 1] = (*inter)[i - 1];
(*intra_l)[i - 1] = '.';
(*intra_s)[pt[i] - cut_point] = '.';
} else {
(*intra_l)[i - 1] = (*inter)[i - 1];
temp_inter[i - 1] = '.';
}
} else {
if (pt[i] < cut_point) {
temp_inter[i - 1] = (*inter)[i - 1];
} else {
(*intra_s)[i - cut_point] = (*inter)[i - 1];
temp_inter[i - 1] = '.';
}
}
}
}
strcpy((*inter), temp_inter);
free(temp_inter);
free(pt_inter);
free(pt);
} | [
"void",
"seperate_bp",
"(",
"char",
"*",
"*",
"inter",
",",
"int",
"len1",
",",
"char",
"*",
"*",
"intra_l",
",",
"char",
"*",
"*",
"intra_s",
")",
"{",
"int",
"i",
",",
"j",
",",
"len",
";",
"short",
"*",
"pt",
"=",
"NULL",
";",
"char",
"*",
"temp_inter",
",",
"*",
"pt_inter",
";",
"len",
"=",
"strlen",
"(",
"(",
"*",
"inter",
")",
")",
";",
"i",
"=",
"len",
"+",
"1",
";",
"temp_inter",
"=",
"(",
"char",
"*",
")",
"vrna_alloc",
"(",
"sizeof",
"(",
"char",
")",
"*",
"i",
")",
";",
"pt_inter",
"=",
"(",
"char",
"*",
")",
"vrna_alloc",
"(",
"sizeof",
"(",
"char",
")",
"*",
"i",
")",
";",
"temp_inter",
"[",
"strlen",
"(",
"(",
"*",
"inter",
")",
")",
"]",
"=",
"'",
"\\0",
"'",
";",
"pt_inter",
"[",
"strlen",
"(",
"(",
"*",
"inter",
")",
")",
"]",
"=",
"'",
"\\0",
"'",
";",
"if",
"(",
"cut_point",
"<",
"len1",
")",
"{",
"for",
"(",
"j",
"=",
"0",
",",
"i",
"=",
"cut_point",
"-",
"1",
";",
"i",
"<",
"len",
";",
"i",
"++",
",",
"j",
"++",
")",
"{",
"switch",
"(",
"(",
"*",
"inter",
")",
"[",
"i",
"]",
")",
"{",
"case",
"'",
"'",
":",
"temp_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"pt_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"temp_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"pt_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"temp_inter",
"[",
"j",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"]",
";",
"pt_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"cut_point",
"-",
"1",
";",
"i",
"++",
",",
"j",
"++",
")",
"{",
"switch",
"(",
"(",
"*",
"inter",
")",
"[",
"i",
"]",
")",
"{",
"case",
"'",
"'",
":",
"temp_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"pt_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"temp_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"pt_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"temp_inter",
"[",
"j",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"]",
";",
"pt_inter",
"[",
"j",
"]",
"=",
"'",
"'",
";",
"}",
"}",
"cut_point",
"=",
"len1",
"+",
"1",
";",
"strcpy",
"(",
"(",
"*",
"inter",
")",
",",
"temp_inter",
")",
";",
"}",
"else",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"strlen",
"(",
"(",
"*",
"inter",
")",
")",
";",
"i",
"++",
")",
"{",
"switch",
"(",
"(",
"*",
"inter",
")",
"[",
"i",
"]",
")",
"{",
"case",
"'",
"'",
":",
"pt_inter",
"[",
"i",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"pt_inter",
"[",
"i",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"pt_inter",
"[",
"i",
"]",
"=",
"'",
"'",
";",
"}",
"}",
"}",
"pt",
"=",
"vrna_ptable",
"(",
"pt_inter",
")",
";",
"(",
"*",
"intra_l",
")",
"=",
"(",
"char",
"*",
")",
"vrna_alloc",
"(",
"sizeof",
"(",
"char",
")",
"*",
"(",
"len1",
"+",
"1",
")",
")",
";",
"(",
"*",
"intra_s",
")",
"=",
"(",
"char",
"*",
")",
"vrna_alloc",
"(",
"sizeof",
"(",
"char",
")",
"*",
"(",
"strlen",
"(",
"(",
"*",
"inter",
")",
")",
"-",
"len1",
"+",
"2",
")",
")",
";",
"(",
"*",
"intra_l",
")",
"[",
"len1",
"]",
"=",
"'",
"\\0",
"'",
";",
"(",
"*",
"intra_s",
")",
"[",
"strlen",
"(",
"(",
"*",
"inter",
")",
")",
"-",
"len1",
"+",
"1",
"]",
"=",
"'",
"\\0",
"'",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<=",
"pt",
"[",
"0",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pt",
"[",
"i",
"]",
"==",
"0",
")",
"{",
"temp_inter",
"[",
"i",
"-",
"1",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
";",
"if",
"(",
"i",
"<",
"cut_point",
")",
"{",
"(",
"*",
"intra_l",
")",
"[",
"i",
"-",
"1",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
";",
"if",
"(",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
"==",
"'",
"'",
")",
"(",
"*",
"intra_l",
")",
"[",
"i",
"-",
"1",
"]",
"=",
"'",
"'",
";",
"}",
"else",
"{",
"(",
"*",
"intra_s",
")",
"[",
"i",
"-",
"cut_point",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
";",
"if",
"(",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
"==",
"'",
"'",
")",
"(",
"*",
"intra_s",
")",
"[",
"i",
"-",
"cut_point",
"]",
"=",
"'",
"'",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"i",
"<",
"cut_point",
")",
"{",
"if",
"(",
"pt",
"[",
"i",
"]",
">=",
"cut_point",
")",
"{",
"temp_inter",
"[",
"i",
"-",
"1",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
";",
"(",
"*",
"intra_l",
")",
"[",
"i",
"-",
"1",
"]",
"=",
"'",
"'",
";",
"(",
"*",
"intra_s",
")",
"[",
"pt",
"[",
"i",
"]",
"-",
"cut_point",
"]",
"=",
"'",
"'",
";",
"}",
"else",
"{",
"(",
"*",
"intra_l",
")",
"[",
"i",
"-",
"1",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
";",
"temp_inter",
"[",
"i",
"-",
"1",
"]",
"=",
"'",
"'",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"pt",
"[",
"i",
"]",
"<",
"cut_point",
")",
"{",
"temp_inter",
"[",
"i",
"-",
"1",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
";",
"}",
"else",
"{",
"(",
"*",
"intra_s",
")",
"[",
"i",
"-",
"cut_point",
"]",
"=",
"(",
"*",
"inter",
")",
"[",
"i",
"-",
"1",
"]",
";",
"temp_inter",
"[",
"i",
"-",
"1",
"]",
"=",
"'",
"'",
";",
"}",
"}",
"}",
"}",
"strcpy",
"(",
"(",
"*",
"inter",
")",
",",
"temp_inter",
")",
";",
"free",
"(",
"temp_inter",
")",
";",
"free",
"(",
"pt_inter",
")",
";",
"free",
"(",
"pt",
")",
";",
"}"
] | len1 is the length of the LONGER input seq ! | [
"len1",
"is",
"the",
"length",
"of",
"the",
"LONGER",
"input",
"seq",
"!"
] | [
"/* printf(\"inter\\n%s\\n\",(*inter)); */",
"/* to make a pair_table convert <|> to (|) */",
"/* if shorter seq is first seq in constrained string, write the\n * longer one as the first one */",
"/* write the constrain for the longer seq first */",
"/* then add the constrain for the shorter seq */",
"/* intramolecular structure in longer (_l) and shorter (_s) seq */",
"/* now seperate intermolecular from intramolecular bp */",
"/* intermolekular bp */",
"/* intramolekular bp */",
"/* i>=cut_point */",
"/* intermolekular bp */",
"/* (*intra_s)[i-1] = '.'; */",
"/* intramolekular bp */",
"/* printf(\"%s -1\\n%s -2\\n%s -3\\n%s -4\\n\",(*inter),temp_inter,(*intra_l),(*intra_s)); */"
] | [
{
"param": "inter",
"type": "char"
},
{
"param": "len1",
"type": "int"
},
{
"param": "intra_l",
"type": "char"
},
{
"param": "intra_s",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "inter",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "len1",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "intra_l",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "intra_s",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2fbf682e08eb26dd25c24fcfa124bbd431c89ae | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/pointer.c | [
"Python-2.0"
] | C | POINTER | void | void
POINTER (int u, int v, int e)
{ int i, del;
#ifdef DEBUG
printf("Pointer u,v,e=%d %d %d-%d\n",u,v,END[OPPEDGE(e)],END[e]);
#endif
LINK[u] = -DUMMYEDGE;
NEXTVTX[LASTVTX[u]] = DUMMYVERTEX;
NEXTVTX[LASTVTX[v]] = DUMMYVERTEX;
if (LASTVTX[u] != u) {
i = MATE[NEXTVTX[u]];
del = -SLACK(i) / 2;
}
else del = LAST_D;
i = u;
while (i != DUMMYVERTEX) {
Y[i] += del;
NEXT_D[i] += del;
i = NEXTVTX[i];
}
if (LINK[v] < 0) {
LINK[v] = e;
NEXTPAIR[DUMMYEDGE] = DUMMYEDGE;
SCAN (v, DELTA);
return;
}
else {
LINK[v] = e;
return;
}
} | /* Assign a pointer link to a vertex. Edge e joins a vertex in blossom */
/* u to a linked vertex. */ | Assign a pointer link to a vertex. Edge e joins a vertex in blossom
u to a linked vertex. | [
"Assign",
"a",
"pointer",
"link",
"to",
"a",
"vertex",
".",
"Edge",
"e",
"joins",
"a",
"vertex",
"in",
"blossom",
"u",
"to",
"a",
"linked",
"vertex",
"."
] | void
POINTER (int u, int v, int e)
{ int i, del;
#ifdef DEBUG
printf("Pointer u,v,e=%d %d %d-%d\n",u,v,END[OPPEDGE(e)],END[e]);
#endif
LINK[u] = -DUMMYEDGE;
NEXTVTX[LASTVTX[u]] = DUMMYVERTEX;
NEXTVTX[LASTVTX[v]] = DUMMYVERTEX;
if (LASTVTX[u] != u) {
i = MATE[NEXTVTX[u]];
del = -SLACK(i) / 2;
}
else del = LAST_D;
i = u;
while (i != DUMMYVERTEX) {
Y[i] += del;
NEXT_D[i] += del;
i = NEXTVTX[i];
}
if (LINK[v] < 0) {
LINK[v] = e;
NEXTPAIR[DUMMYEDGE] = DUMMYEDGE;
SCAN (v, DELTA);
return;
}
else {
LINK[v] = e;
return;
}
} | [
"void",
"POINTER",
"(",
"int",
"u",
",",
"int",
"v",
",",
"int",
"e",
")",
"{",
"int",
"i",
",",
"del",
";",
"#ifdef",
"DEBUG",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"u",
",",
"v",
",",
"END",
"[",
"OPPEDGE",
"(",
"e",
")",
"]",
",",
"END",
"[",
"e",
"]",
")",
";",
"#endif",
"LINK",
"[",
"u",
"]",
"=",
"-",
"DUMMYEDGE",
";",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"u",
"]",
"]",
"=",
"DUMMYVERTEX",
";",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"v",
"]",
"]",
"=",
"DUMMYVERTEX",
";",
"if",
"(",
"LASTVTX",
"[",
"u",
"]",
"!=",
"u",
")",
"{",
"i",
"=",
"MATE",
"[",
"NEXTVTX",
"[",
"u",
"]",
"]",
";",
"del",
"=",
"-",
"SLACK",
"(",
"i",
")",
"/",
"2",
";",
"}",
"else",
"del",
"=",
"LAST_D",
";",
"i",
"=",
"u",
";",
"while",
"(",
"i",
"!=",
"DUMMYVERTEX",
")",
"{",
"Y",
"[",
"i",
"]",
"+=",
"del",
";",
"NEXT_D",
"[",
"i",
"]",
"+=",
"del",
";",
"i",
"=",
"NEXTVTX",
"[",
"i",
"]",
";",
"}",
"if",
"(",
"LINK",
"[",
"v",
"]",
"<",
"0",
")",
"{",
"LINK",
"[",
"v",
"]",
"=",
"e",
";",
"NEXTPAIR",
"[",
"DUMMYEDGE",
"]",
"=",
"DUMMYEDGE",
";",
"SCAN",
"(",
"v",
",",
"DELTA",
")",
";",
"return",
";",
"}",
"else",
"{",
"LINK",
"[",
"v",
"]",
"=",
"e",
";",
"return",
";",
"}",
"}"
] | Assign a pointer link to a vertex. | [
"Assign",
"a",
"pointer",
"link",
"to",
"a",
"vertex",
"."
] | [] | [
{
"param": "u",
"type": "int"
},
{
"param": "v",
"type": "int"
},
{
"param": "e",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "u",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2fbf682e08eb26dd25c24fcfa124bbd431c89ae | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/pointer.c | [
"Python-2.0"
] | C | SCAN | void | void
SCAN (int x, int del)
{ int u, del_e;
#ifdef DEBUG
printf("Scan del=%d x=%d\n",del,x);
#endif
newbase = BASE[x];
stopscan = NEXTVTX[LASTVTX[x]];
while (x != stopscan) {
Y[x] += del;
NEXT_D[x] = LAST_D;
pairpoint = DUMMYEDGE;
e = A[x];
while (e != 0) {
neighbor = END[e];
u = BASE[neighbor];
if (LINK[u] < 0) {
if (LINK[BMATE (u)] < 0 || LASTVTX[u] != u) {
del_e = SLACK (e);
if (NEXT_D[neighbor] > del_e) {
NEXT_D[neighbor] = del_e;
NEXTEDGE[neighbor] = e;
}
}
}
else if (u != newbase) {
INSERT_PAIR();
}
e = A[e];
}
x = NEXTVTX[x];
}
NEXTEDGE[newbase] = NEXTPAIR[DUMMYEDGE];
} | /* Scan each vertex in the blossom whose base is x */ | Scan each vertex in the blossom whose base is x | [
"Scan",
"each",
"vertex",
"in",
"the",
"blossom",
"whose",
"base",
"is",
"x"
] | void
SCAN (int x, int del)
{ int u, del_e;
#ifdef DEBUG
printf("Scan del=%d x=%d\n",del,x);
#endif
newbase = BASE[x];
stopscan = NEXTVTX[LASTVTX[x]];
while (x != stopscan) {
Y[x] += del;
NEXT_D[x] = LAST_D;
pairpoint = DUMMYEDGE;
e = A[x];
while (e != 0) {
neighbor = END[e];
u = BASE[neighbor];
if (LINK[u] < 0) {
if (LINK[BMATE (u)] < 0 || LASTVTX[u] != u) {
del_e = SLACK (e);
if (NEXT_D[neighbor] > del_e) {
NEXT_D[neighbor] = del_e;
NEXTEDGE[neighbor] = e;
}
}
}
else if (u != newbase) {
INSERT_PAIR();
}
e = A[e];
}
x = NEXTVTX[x];
}
NEXTEDGE[newbase] = NEXTPAIR[DUMMYEDGE];
} | [
"void",
"SCAN",
"(",
"int",
"x",
",",
"int",
"del",
")",
"{",
"int",
"u",
",",
"del_e",
";",
"#ifdef",
"DEBUG",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"del",
",",
"x",
")",
";",
"#endif",
"newbase",
"=",
"BASE",
"[",
"x",
"]",
";",
"stopscan",
"=",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"x",
"]",
"]",
";",
"while",
"(",
"x",
"!=",
"stopscan",
")",
"{",
"Y",
"[",
"x",
"]",
"+=",
"del",
";",
"NEXT_D",
"[",
"x",
"]",
"=",
"LAST_D",
";",
"pairpoint",
"=",
"DUMMYEDGE",
";",
"e",
"=",
"A",
"[",
"x",
"]",
";",
"while",
"(",
"e",
"!=",
"0",
")",
"{",
"neighbor",
"=",
"END",
"[",
"e",
"]",
";",
"u",
"=",
"BASE",
"[",
"neighbor",
"]",
";",
"if",
"(",
"LINK",
"[",
"u",
"]",
"<",
"0",
")",
"{",
"if",
"(",
"LINK",
"[",
"BMATE",
"(",
"u",
")",
"]",
"<",
"0",
"||",
"LASTVTX",
"[",
"u",
"]",
"!=",
"u",
")",
"{",
"del_e",
"=",
"SLACK",
"(",
"e",
")",
";",
"if",
"(",
"NEXT_D",
"[",
"neighbor",
"]",
">",
"del_e",
")",
"{",
"NEXT_D",
"[",
"neighbor",
"]",
"=",
"del_e",
";",
"NEXTEDGE",
"[",
"neighbor",
"]",
"=",
"e",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"u",
"!=",
"newbase",
")",
"{",
"INSERT_PAIR",
"(",
")",
";",
"}",
"e",
"=",
"A",
"[",
"e",
"]",
";",
"}",
"x",
"=",
"NEXTVTX",
"[",
"x",
"]",
";",
"}",
"NEXTEDGE",
"[",
"newbase",
"]",
"=",
"NEXTPAIR",
"[",
"DUMMYEDGE",
"]",
";",
"}"
] | Scan each vertex in the blossom whose base is x | [
"Scan",
"each",
"vertex",
"in",
"the",
"blossom",
"whose",
"base",
"is",
"x"
] | [] | [
{
"param": "x",
"type": "int"
},
{
"param": "del",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "del",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
63e30bc7221e14150cb1deb57144030d3d928ea7 | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/term.c | [
"Python-2.0"
] | C | SET_BOUNDS | void | void
SET_BOUNDS ()
{ int del;
for (v=1; v <= U; ++v) {
if (LINK[v] < 0 || BASE[v] != v) {
NEXT_D[v] = LAST_D;
continue;
}
LINK[v] = -LINK[v];
i = v;
while (i != DUMMYVERTEX) {
Y[i] -= DELTA;
i = NEXTVTX[i];
}
f = MATE[v];
if (f != DUMMYEDGE) {
i = BEND(f);
del = SLACK(f);
while (i != DUMMYVERTEX) {
Y[i] -= del;
i = NEXTVTX[i];
}
}
NEXT_D[v] = LAST_D;
}
} | /* updates numerical bounds for linking paths. */
/* called with LAST_D set to the bound on DELTA for the next search */ | updates numerical bounds for linking paths.
called with LAST_D set to the bound on DELTA for the next search | [
"updates",
"numerical",
"bounds",
"for",
"linking",
"paths",
".",
"called",
"with",
"LAST_D",
"set",
"to",
"the",
"bound",
"on",
"DELTA",
"for",
"the",
"next",
"search"
] | void
SET_BOUNDS ()
{ int del;
for (v=1; v <= U; ++v) {
if (LINK[v] < 0 || BASE[v] != v) {
NEXT_D[v] = LAST_D;
continue;
}
LINK[v] = -LINK[v];
i = v;
while (i != DUMMYVERTEX) {
Y[i] -= DELTA;
i = NEXTVTX[i];
}
f = MATE[v];
if (f != DUMMYEDGE) {
i = BEND(f);
del = SLACK(f);
while (i != DUMMYVERTEX) {
Y[i] -= del;
i = NEXTVTX[i];
}
}
NEXT_D[v] = LAST_D;
}
} | [
"void",
"SET_BOUNDS",
"(",
")",
"{",
"int",
"del",
";",
"for",
"(",
"v",
"=",
"1",
";",
"v",
"<=",
"U",
";",
"++",
"v",
")",
"{",
"if",
"(",
"LINK",
"[",
"v",
"]",
"<",
"0",
"||",
"BASE",
"[",
"v",
"]",
"!=",
"v",
")",
"{",
"NEXT_D",
"[",
"v",
"]",
"=",
"LAST_D",
";",
"continue",
";",
"}",
"LINK",
"[",
"v",
"]",
"=",
"-",
"LINK",
"[",
"v",
"]",
";",
"i",
"=",
"v",
";",
"while",
"(",
"i",
"!=",
"DUMMYVERTEX",
")",
"{",
"Y",
"[",
"i",
"]",
"-=",
"DELTA",
";",
"i",
"=",
"NEXTVTX",
"[",
"i",
"]",
";",
"}",
"f",
"=",
"MATE",
"[",
"v",
"]",
";",
"if",
"(",
"f",
"!=",
"DUMMYEDGE",
")",
"{",
"i",
"=",
"BEND",
"(",
"f",
")",
";",
"del",
"=",
"SLACK",
"(",
"f",
")",
";",
"while",
"(",
"i",
"!=",
"DUMMYVERTEX",
")",
"{",
"Y",
"[",
"i",
"]",
"-=",
"del",
";",
"i",
"=",
"NEXTVTX",
"[",
"i",
"]",
";",
"}",
"}",
"NEXT_D",
"[",
"v",
"]",
"=",
"LAST_D",
";",
"}",
"}"
] | updates numerical bounds for linking paths. | [
"updates",
"numerical",
"bounds",
"for",
"linking",
"paths",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
63e30bc7221e14150cb1deb57144030d3d928ea7 | threadmapper/ViennaRNA | src/RNAforester/src/wmatch/term.c | [
"Python-2.0"
] | C | UNPAIR_ALL | void | void
UNPAIR_ALL ()
{ int u;
for (v=1; v <= U; ++v) {
if (BASE[v] != v || LASTVTX[v] == v)
continue;
nextu = v;
NEXTVTX[LASTVTX[nextu]] = DUMMYVERTEX;
while (1) {
u = nextu;
nextu = NEXTVTX[nextu];
UNLINK (u);
if (LASTVTX[u] != u) {
f = (LASTEDGE[2] == OPPEDGE(e)) ? LASTEDGE[1] : LASTEDGE[2];
NEXTVTX[LASTVTX[BEND(f)]] = u;
}
newbase = BMATE (BMATE(u));
if (newbase != DUMMYVERTEX && newbase != u) {
LINK[u] = -DUMMYEDGE;
REMATCH (newbase, MATE[u]);
}
while (LASTVTX[nextu] == nextu && nextu != DUMMYVERTEX)
nextu = NEXTVTX[nextu];
if (LASTVTX[nextu] == nextu && nextu == DUMMYVERTEX)
break;
}
}
} | /* undoes all blossoms to get the final matching */ | undoes all blossoms to get the final matching | [
"undoes",
"all",
"blossoms",
"to",
"get",
"the",
"final",
"matching"
] | void
UNPAIR_ALL ()
{ int u;
for (v=1; v <= U; ++v) {
if (BASE[v] != v || LASTVTX[v] == v)
continue;
nextu = v;
NEXTVTX[LASTVTX[nextu]] = DUMMYVERTEX;
while (1) {
u = nextu;
nextu = NEXTVTX[nextu];
UNLINK (u);
if (LASTVTX[u] != u) {
f = (LASTEDGE[2] == OPPEDGE(e)) ? LASTEDGE[1] : LASTEDGE[2];
NEXTVTX[LASTVTX[BEND(f)]] = u;
}
newbase = BMATE (BMATE(u));
if (newbase != DUMMYVERTEX && newbase != u) {
LINK[u] = -DUMMYEDGE;
REMATCH (newbase, MATE[u]);
}
while (LASTVTX[nextu] == nextu && nextu != DUMMYVERTEX)
nextu = NEXTVTX[nextu];
if (LASTVTX[nextu] == nextu && nextu == DUMMYVERTEX)
break;
}
}
} | [
"void",
"UNPAIR_ALL",
"(",
")",
"{",
"int",
"u",
";",
"for",
"(",
"v",
"=",
"1",
";",
"v",
"<=",
"U",
";",
"++",
"v",
")",
"{",
"if",
"(",
"BASE",
"[",
"v",
"]",
"!=",
"v",
"||",
"LASTVTX",
"[",
"v",
"]",
"==",
"v",
")",
"continue",
";",
"nextu",
"=",
"v",
";",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"nextu",
"]",
"]",
"=",
"DUMMYVERTEX",
";",
"while",
"(",
"1",
")",
"{",
"u",
"=",
"nextu",
";",
"nextu",
"=",
"NEXTVTX",
"[",
"nextu",
"]",
";",
"UNLINK",
"(",
"u",
")",
";",
"if",
"(",
"LASTVTX",
"[",
"u",
"]",
"!=",
"u",
")",
"{",
"f",
"=",
"(",
"LASTEDGE",
"[",
"2",
"]",
"==",
"OPPEDGE",
"(",
"e",
")",
")",
"?",
"LASTEDGE",
"[",
"1",
"]",
":",
"LASTEDGE",
"[",
"2",
"]",
";",
"NEXTVTX",
"[",
"LASTVTX",
"[",
"BEND",
"(",
"f",
")",
"]",
"]",
"=",
"u",
";",
"}",
"newbase",
"=",
"BMATE",
"(",
"BMATE",
"(",
"u",
")",
")",
";",
"if",
"(",
"newbase",
"!=",
"DUMMYVERTEX",
"&&",
"newbase",
"!=",
"u",
")",
"{",
"LINK",
"[",
"u",
"]",
"=",
"-",
"DUMMYEDGE",
";",
"REMATCH",
"(",
"newbase",
",",
"MATE",
"[",
"u",
"]",
")",
";",
"}",
"while",
"(",
"LASTVTX",
"[",
"nextu",
"]",
"==",
"nextu",
"&&",
"nextu",
"!=",
"DUMMYVERTEX",
")",
"nextu",
"=",
"NEXTVTX",
"[",
"nextu",
"]",
";",
"if",
"(",
"LASTVTX",
"[",
"nextu",
"]",
"==",
"nextu",
"&&",
"nextu",
"==",
"DUMMYVERTEX",
")",
"break",
";",
"}",
"}",
"}"
] | undoes all blossoms to get the final matching | [
"undoes",
"all",
"blossoms",
"to",
"get",
"the",
"final",
"matching"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1c35e62f989ffa82e4126f1a4c8bdb870ed0a5b5 | threadmapper/ViennaRNA | src/cthreadpool/thpool.c | [
"Python-2.0"
] | C | thpool_add_work | int | int thpool_add_work(thpool_* thpool_p, void (*function_p)(void*), void* arg_p){
job* newjob;
newjob=(struct job*)malloc(sizeof(struct job));
if (newjob==NULL){
err("thpool_add_work(): Could not allocate memory for new job\n");
return -1;
}
/* add function and argument */
newjob->function=function_p;
newjob->arg=arg_p;
/* add job to queue */
jobqueue_push(&thpool_p->jobqueue, newjob);
/* increment the job placed count */
thpool_p->num_jobs_placed++;
return 0;
} | /* Add work to the thread pool */ | Add work to the thread pool | [
"Add",
"work",
"to",
"the",
"thread",
"pool"
] | int thpool_add_work(thpool_* thpool_p, void (*function_p)(void*), void* arg_p){
job* newjob;
newjob=(struct job*)malloc(sizeof(struct job));
if (newjob==NULL){
err("thpool_add_work(): Could not allocate memory for new job\n");
return -1;
}
newjob->function=function_p;
newjob->arg=arg_p;
jobqueue_push(&thpool_p->jobqueue, newjob);
thpool_p->num_jobs_placed++;
return 0;
} | [
"int",
"thpool_add_work",
"(",
"thpool_",
"*",
"thpool_p",
",",
"void",
"(",
"*",
"function_p",
")",
"(",
"void",
"*",
")",
",",
"void",
"*",
"arg_p",
")",
"{",
"job",
"*",
"newjob",
";",
"newjob",
"=",
"(",
"struct",
"job",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"struct",
"job",
")",
")",
";",
"if",
"(",
"newjob",
"==",
"NULL",
")",
"{",
"err",
"(",
"\"",
"\\n",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"newjob",
"->",
"function",
"=",
"function_p",
";",
"newjob",
"->",
"arg",
"=",
"arg_p",
";",
"jobqueue_push",
"(",
"&",
"thpool_p",
"->",
"jobqueue",
",",
"newjob",
")",
";",
"thpool_p",
"->",
"num_jobs_placed",
"++",
";",
"return",
"0",
";",
"}"
] | Add work to the thread pool | [
"Add",
"work",
"to",
"the",
"thread",
"pool"
] | [
"/* add function and argument */",
"/* add job to queue */",
"/* increment the job placed count */"
] | [
{
"param": "thpool_p",
"type": "thpool_"
},
{
"param": "function_p",
"type": "void"
},
{
"param": "arg_p",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "thpool_p",
"type": "thpool_",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "function_p",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "arg_p",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1c35e62f989ffa82e4126f1a4c8bdb870ed0a5b5 | threadmapper/ViennaRNA | src/cthreadpool/thpool.c | [
"Python-2.0"
] | C | thread_init | int | static int thread_init (thpool_* thpool_p, struct thread** thread_p, int id){
*thread_p = (struct thread*)malloc(sizeof(struct thread));
if (thread_p == NULL){
err("thread_init(): Could not allocate memory for thread\n");
return -1;
}
(*thread_p)->thpool_p = thpool_p;
(*thread_p)->id = id;
pthread_create(&(*thread_p)->pthread, NULL, (void *)thread_do, (*thread_p));
pthread_detach((*thread_p)->pthread);
return 0;
} | /* Initialize a thread in the thread pool
*
* @param thread address to the pointer of the thread to be created
* @param id id to be given to the thread
* @return 0 on success, -1 otherwise.
*/ | Initialize a thread in the thread pool
@param thread address to the pointer of the thread to be created
@param id id to be given to the thread
@return 0 on success, -1 otherwise. | [
"Initialize",
"a",
"thread",
"in",
"the",
"thread",
"pool",
"@param",
"thread",
"address",
"to",
"the",
"pointer",
"of",
"the",
"thread",
"to",
"be",
"created",
"@param",
"id",
"id",
"to",
"be",
"given",
"to",
"the",
"thread",
"@return",
"0",
"on",
"success",
"-",
"1",
"otherwise",
"."
] | static int thread_init (thpool_* thpool_p, struct thread** thread_p, int id){
*thread_p = (struct thread*)malloc(sizeof(struct thread));
if (thread_p == NULL){
err("thread_init(): Could not allocate memory for thread\n");
return -1;
}
(*thread_p)->thpool_p = thpool_p;
(*thread_p)->id = id;
pthread_create(&(*thread_p)->pthread, NULL, (void *)thread_do, (*thread_p));
pthread_detach((*thread_p)->pthread);
return 0;
} | [
"static",
"int",
"thread_init",
"(",
"thpool_",
"*",
"thpool_p",
",",
"struct",
"thread",
"*",
"*",
"thread_p",
",",
"int",
"id",
")",
"{",
"*",
"thread_p",
"=",
"(",
"struct",
"thread",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"struct",
"thread",
")",
")",
";",
"if",
"(",
"thread_p",
"==",
"NULL",
")",
"{",
"err",
"(",
"\"",
"\\n",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"(",
"*",
"thread_p",
")",
"->",
"thpool_p",
"=",
"thpool_p",
";",
"(",
"*",
"thread_p",
")",
"->",
"id",
"=",
"id",
";",
"pthread_create",
"(",
"&",
"(",
"*",
"thread_p",
")",
"->",
"pthread",
",",
"NULL",
",",
"(",
"void",
"*",
")",
"thread_do",
",",
"(",
"*",
"thread_p",
")",
")",
";",
"pthread_detach",
"(",
"(",
"*",
"thread_p",
")",
"->",
"pthread",
")",
";",
"return",
"0",
";",
"}"
] | Initialize a thread in the thread pool
@param thread address to the pointer of the thread to be created
@param id id to be given to the thread
@return 0 on success, -1 otherwise. | [
"Initialize",
"a",
"thread",
"in",
"the",
"thread",
"pool",
"@param",
"thread",
"address",
"to",
"the",
"pointer",
"of",
"the",
"thread",
"to",
"be",
"created",
"@param",
"id",
"id",
"to",
"be",
"given",
"to",
"the",
"thread",
"@return",
"0",
"on",
"success",
"-",
"1",
"otherwise",
"."
] | [] | [
{
"param": "thpool_p",
"type": "thpool_"
},
{
"param": "thread_p",
"type": "struct thread"
},
{
"param": "id",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "thpool_p",
"type": "thpool_",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "thread_p",
"type": "struct thread",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d7cdf598c9aa81042e4156413deefea560c5582a | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_control.c | [
"Python-2.0"
] | C | g2_reset_palette | void | void g2_reset_palette(int dev)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_reset_palette: No such device: %d\n", dev);
return;
}
switch(devp->t) {
case g2_PD:
g2_clear_palette(dev);
g2_allocate_basic_colors(dev);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_reset_palette(devp->d.vd->dix[i]);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | /**
*
* Clear collor palette (remove all inks) and reallocate basic colors.
*
* \param dev device
*
* \ingroup color
*/ | Clear collor palette (remove all inks) and reallocate basic colors.
\param dev device
\ingroup color | [
"Clear",
"collor",
"palette",
"(",
"remove",
"all",
"inks",
")",
"and",
"reallocate",
"basic",
"colors",
".",
"\\",
"param",
"dev",
"device",
"\\",
"ingroup",
"color"
] | void g2_reset_palette(int dev)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_reset_palette: No such device: %d\n", dev);
return;
}
switch(devp->t) {
case g2_PD:
g2_clear_palette(dev);
g2_allocate_basic_colors(dev);
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_reset_palette(devp->d.vd->dix[i]);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | [
"void",
"g2_reset_palette",
"(",
"int",
"dev",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_clear_palette",
"(",
"dev",
")",
";",
"g2_allocate_basic_colors",
"(",
"dev",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_reset_palette",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Clear collor palette (remove all inks) and reallocate basic colors. | [
"Clear",
"collor",
"palette",
"(",
"remove",
"all",
"inks",
")",
"and",
"reallocate",
"basic",
"colors",
"."
] | [] | [
{
"param": "dev",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d7cdf598c9aa81042e4156413deefea560c5582a | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_control.c | [
"Python-2.0"
] | C | g2_query_pointer | void | void g2_query_pointer(int dev, double *x, double *y, unsigned int *button)
{
g2_device *devp;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_query_pointer: No such device: %d\n", dev);
return;
}
switch(devp->t) {
case g2_PD:
g2_query_pointer_pd(devp->d.pd, x, y, button);
break;
case g2_VD:
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | /**
*
* Query pointer (e.g. mouse for X11) position and button state. See
* the demo program pointer.c for an example.
*
* \param dev device
* \param x returns pointer x coordinate
* \param y returns pointer y coordinate
* \param button returns button state
*
* \ingroup control
*/ | Query pointer position and button state. See
the demo program pointer.c for an example.
\param dev device
\param x returns pointer x coordinate
\param y returns pointer y coordinate
\param button returns button state
\ingroup control | [
"Query",
"pointer",
"position",
"and",
"button",
"state",
".",
"See",
"the",
"demo",
"program",
"pointer",
".",
"c",
"for",
"an",
"example",
".",
"\\",
"param",
"dev",
"device",
"\\",
"param",
"x",
"returns",
"pointer",
"x",
"coordinate",
"\\",
"param",
"y",
"returns",
"pointer",
"y",
"coordinate",
"\\",
"param",
"button",
"returns",
"button",
"state",
"\\",
"ingroup",
"control"
] | void g2_query_pointer(int dev, double *x, double *y, unsigned int *button)
{
g2_device *devp;
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr, "g2_query_pointer: No such device: %d\n", dev);
return;
}
switch(devp->t) {
case g2_PD:
g2_query_pointer_pd(devp->d.pd, x, y, button);
break;
case g2_VD:
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | [
"void",
"g2_query_pointer",
"(",
"int",
"dev",
",",
"double",
"*",
"x",
",",
"double",
"*",
"y",
",",
"unsigned",
"int",
"*",
"button",
")",
"{",
"g2_device",
"*",
"devp",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_query_pointer_pd",
"(",
"devp",
"->",
"d",
".",
"pd",
",",
"x",
",",
"y",
",",
"button",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Query pointer (e.g. | [
"Query",
"pointer",
"(",
"e",
".",
"g",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x",
"type": "double"
},
{
"param": "y",
"type": "double"
},
{
"param": "button",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "button",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d7cdf598c9aa81042e4156413deefea560c5582a | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_control.c | [
"Python-2.0"
] | C | g2_get_pd_handles | void | void g2_get_pd_handles(int pd, void *handles[G2_PD_HANDLES_SIZE])
{
g2_device *devp;
int i;
for(i=0;i<G2_PD_HANDLES_SIZE;i++) {
handles[i]=NULL;
}
if((devp=g2_get_device_pointer(pd))==NULL) {
g2_log(Error, "g2: Error! g2_get_pd_handles: No such device: %d\n", pd);
return;
}
switch(devp->t) {
case g2_PD:
g2_get_pd_handles_pd(devp->d.pd, handles);
break;
case g2_VD:
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
} | /**
*
* Get pointers to physical device specific handles. This function
* should be used only if you are familiar with the g2 source code.
* For details see physical device source code (e.g. in src/X11/).
* Example usage can be found in demo/handles.c.
*
* \param pd physical device
* \param handles returns pointers to physical device low level handles
*
* \ingroup control
*/ | Get pointers to physical device specific handles. This function
should be used only if you are familiar with the g2 source code.
For details see physical device source code .
Example usage can be found in demo/handles.c.
\param pd physical device
\param handles returns pointers to physical device low level handles
\ingroup control | [
"Get",
"pointers",
"to",
"physical",
"device",
"specific",
"handles",
".",
"This",
"function",
"should",
"be",
"used",
"only",
"if",
"you",
"are",
"familiar",
"with",
"the",
"g2",
"source",
"code",
".",
"For",
"details",
"see",
"physical",
"device",
"source",
"code",
".",
"Example",
"usage",
"can",
"be",
"found",
"in",
"demo",
"/",
"handles",
".",
"c",
".",
"\\",
"param",
"pd",
"physical",
"device",
"\\",
"param",
"handles",
"returns",
"pointers",
"to",
"physical",
"device",
"low",
"level",
"handles",
"\\",
"ingroup",
"control"
] | void g2_get_pd_handles(int pd, void *handles[G2_PD_HANDLES_SIZE])
{
g2_device *devp;
int i;
for(i=0;i<G2_PD_HANDLES_SIZE;i++) {
handles[i]=NULL;
}
if((devp=g2_get_device_pointer(pd))==NULL) {
g2_log(Error, "g2: Error! g2_get_pd_handles: No such device: %d\n", pd);
return;
}
switch(devp->t) {
case g2_PD:
g2_get_pd_handles_pd(devp->d.pd, handles);
break;
case g2_VD:
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
} | [
"void",
"g2_get_pd_handles",
"(",
"int",
"pd",
",",
"void",
"*",
"handles",
"[",
"G2_PD_HANDLES_SIZE",
"]",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"G2_PD_HANDLES_SIZE",
";",
"i",
"++",
")",
"{",
"handles",
"[",
"i",
"]",
"=",
"NULL",
";",
"}",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"pd",
")",
")",
"==",
"NULL",
")",
"{",
"g2_log",
"(",
"Error",
",",
"\"",
"\\n",
"\"",
",",
"pd",
")",
";",
"return",
";",
"}",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"g2_get_pd_handles_pd",
"(",
"devp",
"->",
"d",
".",
"pd",
",",
"handles",
")",
";",
"break",
";",
"case",
"g2_VD",
":",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"}"
] | Get pointers to physical device specific handles. | [
"Get",
"pointers",
"to",
"physical",
"device",
"specific",
"handles",
"."
] | [] | [
{
"param": "pd",
"type": "int"
},
{
"param": "handles",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pd",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handles",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1870d941c07151e916f8367248965f0fcb661814 | threadmapper/ViennaRNA | src/bin/RNAplfold.c | [
"Python-2.0"
] | C | isnan_f | int | static inline int
isnan_f(float x)
{
volatile float tmp = x;
return tmp != x;
} | /* Use volatile tmp variable to prevent optimization by compiler. */ | Use volatile tmp variable to prevent optimization by compiler. | [
"Use",
"volatile",
"tmp",
"variable",
"to",
"prevent",
"optimization",
"by",
"compiler",
"."
] | static inline int
isnan_f(float x)
{
volatile float tmp = x;
return tmp != x;
} | [
"static",
"inline",
"int",
"isnan_f",
"(",
"float",
"x",
")",
"{",
"volatile",
"float",
"tmp",
"=",
"x",
";",
"return",
"tmp",
"!=",
"x",
";",
"}"
] | Use volatile tmp variable to prevent optimization by compiler. | [
"Use",
"volatile",
"tmp",
"variable",
"to",
"prevent",
"optimization",
"by",
"compiler",
"."
] | [] | [
{
"param": "x",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7c04d2c8b26c4a866aa14c9304c3ca3bda5ae40a | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_control_pd.c | [
"Python-2.0"
] | C | g2_query_pointer_pd | void | void g2_query_pointer_pd(g2_physical_device *pd,
double *x, double *y, unsigned int *button)
{
int ix, iy;
double dx, dy;
if(pd->ff[g2_QueryPointer].fun!=NULL) {
switch(pd->coor_type) {
case g2_IntCoor:
pd->ff[g2_QueryPointer].fun(pd->pid, pd->pdp,
&ix, &iy, button);
g2_pdc2uc(pd, ix, iy, x, y);
break;
case g2_DoubleCoor:
pd->ff[g2_QueryPointer].fun(pd->pid, pd->pdp,
&dx, &dy, button);
g2_pdc2uc(pd, dx, dy, x, y);
break;
}
} else {
/* no emulation for query pointer */
}
} | /*
*
* Query pointer position and button state
*
*/ | Query pointer position and button state | [
"Query",
"pointer",
"position",
"and",
"button",
"state"
] | void g2_query_pointer_pd(g2_physical_device *pd,
double *x, double *y, unsigned int *button)
{
int ix, iy;
double dx, dy;
if(pd->ff[g2_QueryPointer].fun!=NULL) {
switch(pd->coor_type) {
case g2_IntCoor:
pd->ff[g2_QueryPointer].fun(pd->pid, pd->pdp,
&ix, &iy, button);
g2_pdc2uc(pd, ix, iy, x, y);
break;
case g2_DoubleCoor:
pd->ff[g2_QueryPointer].fun(pd->pid, pd->pdp,
&dx, &dy, button);
g2_pdc2uc(pd, dx, dy, x, y);
break;
}
} else {
}
} | [
"void",
"g2_query_pointer_pd",
"(",
"g2_physical_device",
"*",
"pd",
",",
"double",
"*",
"x",
",",
"double",
"*",
"y",
",",
"unsigned",
"int",
"*",
"button",
")",
"{",
"int",
"ix",
",",
"iy",
";",
"double",
"dx",
",",
"dy",
";",
"if",
"(",
"pd",
"->",
"ff",
"[",
"g2_QueryPointer",
"]",
".",
"fun",
"!=",
"NULL",
")",
"{",
"switch",
"(",
"pd",
"->",
"coor_type",
")",
"{",
"case",
"g2_IntCoor",
":",
"pd",
"->",
"ff",
"[",
"g2_QueryPointer",
"]",
".",
"fun",
"(",
"pd",
"->",
"pid",
",",
"pd",
"->",
"pdp",
",",
"&",
"ix",
",",
"&",
"iy",
",",
"button",
")",
";",
"g2_pdc2uc",
"(",
"pd",
",",
"ix",
",",
"iy",
",",
"x",
",",
"y",
")",
";",
"break",
";",
"case",
"g2_DoubleCoor",
":",
"pd",
"->",
"ff",
"[",
"g2_QueryPointer",
"]",
".",
"fun",
"(",
"pd",
"->",
"pid",
",",
"pd",
"->",
"pdp",
",",
"&",
"dx",
",",
"&",
"dy",
",",
"button",
")",
";",
"g2_pdc2uc",
"(",
"pd",
",",
"dx",
",",
"dy",
",",
"x",
",",
"y",
")",
";",
"break",
";",
"}",
"}",
"else",
"{",
"}",
"}"
] | Query pointer position and button state | [
"Query",
"pointer",
"position",
"and",
"button",
"state"
] | [
"/* no emulation for query pointer */"
] | [
{
"param": "pd",
"type": "g2_physical_device"
},
{
"param": "x",
"type": "double"
},
{
"param": "y",
"type": "double"
},
{
"param": "button",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pd",
"type": "g2_physical_device",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "button",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
47ce2e2432ea45ae20081cf129f2fb5ed989403c | threadmapper/ViennaRNA | src/Kinfold/cache.c | [
"Python-2.0"
] | C | lookup_cache | cache_entry | cache_entry *lookup_cache (char *x) {
int cacheval;
cache_entry *c;
cacheval=cache_f(x);
if ((c=cachetab[cacheval]))
if (strcmp(c->structure,x)==0) return c;
return NULL;
} | /* returns NULL unless x is in the cache */ | returns NULL unless x is in the cache | [
"returns",
"NULL",
"unless",
"x",
"is",
"in",
"the",
"cache"
] | cache_entry *lookup_cache (char *x) {
int cacheval;
cache_entry *c;
cacheval=cache_f(x);
if ((c=cachetab[cacheval]))
if (strcmp(c->structure,x)==0) return c;
return NULL;
} | [
"cache_entry",
"*",
"lookup_cache",
"(",
"char",
"*",
"x",
")",
"{",
"int",
"cacheval",
";",
"cache_entry",
"*",
"c",
";",
"cacheval",
"=",
"cache_f",
"(",
"x",
")",
";",
"if",
"(",
"(",
"c",
"=",
"cachetab",
"[",
"cacheval",
"]",
")",
")",
"if",
"(",
"strcmp",
"(",
"c",
"->",
"structure",
",",
"x",
")",
"==",
"0",
")",
"return",
"c",
";",
"return",
"NULL",
";",
"}"
] | returns NULL unless x is in the cache | [
"returns",
"NULL",
"unless",
"x",
"is",
"in",
"the",
"cache"
] | [] | [
{
"param": "x",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
47ce2e2432ea45ae20081cf129f2fb5ed989403c | threadmapper/ViennaRNA | src/Kinfold/cache.c | [
"Python-2.0"
] | C | write_cache | int | int write_cache (cache_entry *x) {
int cacheval;
cache_entry *c;
cacheval=cache_f(x->structure);
if ((c=cachetab[cacheval])) {
free(c->structure);
free(c->neighbors);
free(c->rates);
free(c->energies);
free(c);
}
cachetab[cacheval]=x;
return 0;
} | /* returns 1 if x already was in the cache */ | returns 1 if x already was in the cache | [
"returns",
"1",
"if",
"x",
"already",
"was",
"in",
"the",
"cache"
] | int write_cache (cache_entry *x) {
int cacheval;
cache_entry *c;
cacheval=cache_f(x->structure);
if ((c=cachetab[cacheval])) {
free(c->structure);
free(c->neighbors);
free(c->rates);
free(c->energies);
free(c);
}
cachetab[cacheval]=x;
return 0;
} | [
"int",
"write_cache",
"(",
"cache_entry",
"*",
"x",
")",
"{",
"int",
"cacheval",
";",
"cache_entry",
"*",
"c",
";",
"cacheval",
"=",
"cache_f",
"(",
"x",
"->",
"structure",
")",
";",
"if",
"(",
"(",
"c",
"=",
"cachetab",
"[",
"cacheval",
"]",
")",
")",
"{",
"free",
"(",
"c",
"->",
"structure",
")",
";",
"free",
"(",
"c",
"->",
"neighbors",
")",
";",
"free",
"(",
"c",
"->",
"rates",
")",
";",
"free",
"(",
"c",
"->",
"energies",
")",
";",
"free",
"(",
"c",
")",
";",
"}",
"cachetab",
"[",
"cacheval",
"]",
"=",
"x",
";",
"return",
"0",
";",
"}"
] | returns 1 if x already was in the cache | [
"returns",
"1",
"if",
"x",
"already",
"was",
"in",
"the",
"cache"
] | [] | [
{
"param": "x",
"type": "cache_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "cache_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fcae5ce731b4b05004e431e8bdc12bae6d20c875 | threadmapper/ViennaRNA | src/bin/RNAdos.c | [
"Python-2.0"
] | C | hash_comparison_dos | int | static int
hash_comparison_dos(void *x,
void *y)
{
key_value *hem_x = ((key_value *)x);
key_value *hem_y = ((key_value *)y);
if ((x == NULL) ^ (y == NULL))
return 1;
return !(hem_x->key == hem_y->key);
} | /***
* 0 is equal, 1 is different!
*/ | 0 is equal, 1 is different! | [
"0",
"is",
"equal",
"1",
"is",
"different!"
] | static int
hash_comparison_dos(void *x,
void *y)
{
key_value *hem_x = ((key_value *)x);
key_value *hem_y = ((key_value *)y);
if ((x == NULL) ^ (y == NULL))
return 1;
return !(hem_x->key == hem_y->key);
} | [
"static",
"int",
"hash_comparison_dos",
"(",
"void",
"*",
"x",
",",
"void",
"*",
"y",
")",
"{",
"key_value",
"*",
"hem_x",
"=",
"(",
"(",
"key_value",
"*",
")",
"x",
")",
";",
"key_value",
"*",
"hem_y",
"=",
"(",
"(",
"key_value",
"*",
")",
"y",
")",
";",
"if",
"(",
"(",
"x",
"==",
"NULL",
")",
"^",
"(",
"y",
"==",
"NULL",
")",
")",
"return",
"1",
";",
"return",
"!",
"(",
"hem_x",
"->",
"key",
"==",
"hem_y",
"->",
"key",
")",
";",
"}"
] | 0 is equal, 1 is different! | [
"0",
"is",
"equal",
"1",
"is",
"different!"
] | [] | [
{
"param": "x",
"type": "void"
},
{
"param": "y",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
418b4ed832a0ad42fe8237d6fd387b4be775ff0a | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_device.c | [
"Python-2.0"
] | C | g2_set_auto_flush | void | void g2_set_auto_flush(int dev, int on_off)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
g2_log(Error, "g2: Error! g2_set_auto_flush: No such device: %d\n", dev);
return;
}
switch(devp->t) {
case g2_PD:
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++) {
g2_set_auto_flush(devp->d.vd->dix[i], on_off);
}
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
devp->auto_flush=on_off; /* set auto flush for all (vd and pd) devices */
__g2_last_device=dev;
} | /**
*
* Set auto flush mode for device \a dev. Auto flush mode means that after each graphical
* operation g2 library automatically calls flush function to ensure that output is realy
* displayed. However, freqent flushing decreases performance. Alternative is to flush
* output when needed by calling g2_flush function.
*
* \param dev device
* \param on_off 1-on 0-off
*
* \ingroup device
*/ | Set auto flush mode for device \a dev. Auto flush mode means that after each graphical
operation g2 library automatically calls flush function to ensure that output is realy
displayed. However, freqent flushing decreases performance. Alternative is to flush
output when needed by calling g2_flush function.
\param dev device
\param on_off 1-on 0-off
\ingroup device | [
"Set",
"auto",
"flush",
"mode",
"for",
"device",
"\\",
"a",
"dev",
".",
"Auto",
"flush",
"mode",
"means",
"that",
"after",
"each",
"graphical",
"operation",
"g2",
"library",
"automatically",
"calls",
"flush",
"function",
"to",
"ensure",
"that",
"output",
"is",
"realy",
"displayed",
".",
"However",
"freqent",
"flushing",
"decreases",
"performance",
".",
"Alternative",
"is",
"to",
"flush",
"output",
"when",
"needed",
"by",
"calling",
"g2_flush",
"function",
".",
"\\",
"param",
"dev",
"device",
"\\",
"param",
"on_off",
"1",
"-",
"on",
"0",
"-",
"off",
"\\",
"ingroup",
"device"
] | void g2_set_auto_flush(int dev, int on_off)
{
g2_device *devp;
int i;
if((devp=g2_get_device_pointer(dev))==NULL) {
g2_log(Error, "g2: Error! g2_set_auto_flush: No such device: %d\n", dev);
return;
}
switch(devp->t) {
case g2_PD:
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++) {
g2_set_auto_flush(devp->d.vd->dix[i], on_off);
}
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
devp->auto_flush=on_off;
__g2_last_device=dev;
} | [
"void",
"g2_set_auto_flush",
"(",
"int",
"dev",
",",
"int",
"on_off",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"g2_log",
"(",
"Error",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"{",
"g2_set_auto_flush",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"on_off",
")",
";",
"}",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"devp",
"->",
"auto_flush",
"=",
"on_off",
";",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Set auto flush mode for device \a dev. | [
"Set",
"auto",
"flush",
"mode",
"for",
"device",
"\\",
"a",
"dev",
"."
] | [
"/* set auto flush for all (vd and pd) devices */"
] | [
{
"param": "dev",
"type": "int"
},
{
"param": "on_off",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "on_off",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
418b4ed832a0ad42fe8237d6fd387b4be775ff0a | threadmapper/ViennaRNA | src/RNAforester/g2-0.72/src/g2_ui_device.c | [
"Python-2.0"
] | C | g2_set_coordinate_system | void | void g2_set_coordinate_system(int dev,
double x_origin, double y_origin,
double x_mul, double y_mul)
{
g2_device *devp;
int i;
if(x_mul==0.0 || y_mul==0.0) {
fprintf(stderr,
"g2_set_coordinate_system: Error! Multiplicator can not be 0.0");
return;
}
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr,
"g2_set_coordinate_system: Warning! No such device: %d\n",
dev);
return;
}
switch(devp->t) {
case g2_PD:
devp->d.pd->x_origin=x_origin;
devp->d.pd->y_origin=y_origin;
devp->d.pd->x_mul=x_mul;
devp->d.pd->y_mul=y_mul;
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_set_coordinate_system(devp->d.vd->dix[i],
x_origin, y_origin,
x_mul, y_mul);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | /**
*
* Set the user coordinate system.
*
* \param dev device
* \param x_origin x coordinate of the new origin (expressed in the default coordinate system)
* \param y_origin x coordinate of the new origin (expressed in the default coordinate system)
* \param x_mul x scaling factor
* \param y_mul y scaling factor
*
* \ingroup device
*/ | Set the user coordinate system.
\ingroup device | [
"Set",
"the",
"user",
"coordinate",
"system",
".",
"\\",
"ingroup",
"device"
] | void g2_set_coordinate_system(int dev,
double x_origin, double y_origin,
double x_mul, double y_mul)
{
g2_device *devp;
int i;
if(x_mul==0.0 || y_mul==0.0) {
fprintf(stderr,
"g2_set_coordinate_system: Error! Multiplicator can not be 0.0");
return;
}
if((devp=g2_get_device_pointer(dev))==NULL) {
fprintf(stderr,
"g2_set_coordinate_system: Warning! No such device: %d\n",
dev);
return;
}
switch(devp->t) {
case g2_PD:
devp->d.pd->x_origin=x_origin;
devp->d.pd->y_origin=y_origin;
devp->d.pd->x_mul=x_mul;
devp->d.pd->y_mul=y_mul;
break;
case g2_VD:
for(i=0;i<devp->d.vd->N;i++)
g2_set_coordinate_system(devp->d.vd->dix[i],
x_origin, y_origin,
x_mul, y_mul);
break;
case g2_ILLEGAL:
break;
case g2_NDEV:
break;
}
__g2_last_device=dev;
} | [
"void",
"g2_set_coordinate_system",
"(",
"int",
"dev",
",",
"double",
"x_origin",
",",
"double",
"y_origin",
",",
"double",
"x_mul",
",",
"double",
"y_mul",
")",
"{",
"g2_device",
"*",
"devp",
";",
"int",
"i",
";",
"if",
"(",
"x_mul",
"==",
"0.0",
"||",
"y_mul",
"==",
"0.0",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"(",
"devp",
"=",
"g2_get_device_pointer",
"(",
"dev",
")",
")",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"dev",
")",
";",
"return",
";",
"}",
"switch",
"(",
"devp",
"->",
"t",
")",
"{",
"case",
"g2_PD",
":",
"devp",
"->",
"d",
".",
"pd",
"->",
"x_origin",
"=",
"x_origin",
";",
"devp",
"->",
"d",
".",
"pd",
"->",
"y_origin",
"=",
"y_origin",
";",
"devp",
"->",
"d",
".",
"pd",
"->",
"x_mul",
"=",
"x_mul",
";",
"devp",
"->",
"d",
".",
"pd",
"->",
"y_mul",
"=",
"y_mul",
";",
"break",
";",
"case",
"g2_VD",
":",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"devp",
"->",
"d",
".",
"vd",
"->",
"N",
";",
"i",
"++",
")",
"g2_set_coordinate_system",
"(",
"devp",
"->",
"d",
".",
"vd",
"->",
"dix",
"[",
"i",
"]",
",",
"x_origin",
",",
"y_origin",
",",
"x_mul",
",",
"y_mul",
")",
";",
"break",
";",
"case",
"g2_ILLEGAL",
":",
"break",
";",
"case",
"g2_NDEV",
":",
"break",
";",
"}",
"__g2_last_device",
"=",
"dev",
";",
"}"
] | Set the user coordinate system. | [
"Set",
"the",
"user",
"coordinate",
"system",
"."
] | [] | [
{
"param": "dev",
"type": "int"
},
{
"param": "x_origin",
"type": "double"
},
{
"param": "y_origin",
"type": "double"
},
{
"param": "x_mul",
"type": "double"
},
{
"param": "y_mul",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x_origin",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y_origin",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x_mul",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y_mul",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c736dc04f2910d70db02134ca65ac213ad0df1b4 | codenamenadja/devs-practice_of_programming | 02_algor_dst/algorithm/src/2-1_binsearch.c | [
"MIT"
] | C | lookup | int | int lookup(char *name, Nameval tab[], int ntab)
{
int low, high, mid, cmp;
low = 0;
high = ntab - 1;
while (low <= high) {
mid = (low + high) / 2;
cmp = strcmp(name, tab[mid].name);
if (cmp < 0)
high = mid - 1;
else if (cmp > 0)
low = mid + 1;
else
return (mid);
}
return (-1);
} | /* lookup: binary search for name in tabs: return index */ | binary search for name in tabs: return index | [
"binary",
"search",
"for",
"name",
"in",
"tabs",
":",
"return",
"index"
] | int lookup(char *name, Nameval tab[], int ntab)
{
int low, high, mid, cmp;
low = 0;
high = ntab - 1;
while (low <= high) {
mid = (low + high) / 2;
cmp = strcmp(name, tab[mid].name);
if (cmp < 0)
high = mid - 1;
else if (cmp > 0)
low = mid + 1;
else
return (mid);
}
return (-1);
} | [
"int",
"lookup",
"(",
"char",
"*",
"name",
",",
"Nameval",
"tab",
"[",
"]",
",",
"int",
"ntab",
")",
"{",
"int",
"low",
",",
"high",
",",
"mid",
",",
"cmp",
";",
"low",
"=",
"0",
";",
"high",
"=",
"ntab",
"-",
"1",
";",
"while",
"(",
"low",
"<=",
"high",
")",
"{",
"mid",
"=",
"(",
"low",
"+",
"high",
")",
"/",
"2",
";",
"cmp",
"=",
"strcmp",
"(",
"name",
",",
"tab",
"[",
"mid",
"]",
".",
"name",
")",
";",
"if",
"(",
"cmp",
"<",
"0",
")",
"high",
"=",
"mid",
"-",
"1",
";",
"else",
"if",
"(",
"cmp",
">",
"0",
")",
"low",
"=",
"mid",
"+",
"1",
";",
"else",
"return",
"(",
"mid",
")",
";",
"}",
"return",
"(",
"-1",
")",
";",
"}"
] | lookup: binary search for name in tabs: return index | [
"lookup",
":",
"binary",
"search",
"for",
"name",
"in",
"tabs",
":",
"return",
"index"
] | [] | [
{
"param": "name",
"type": "char"
},
{
"param": "tab",
"type": "Nameval"
},
{
"param": "ntab",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tab",
"type": "Nameval",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ntab",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d7f9274c82ddce3defdf17cdcfaf7b6bf1b718c | jeptechnology/jude | src/core/c/jude_iterator.c | [
"MIT"
] | C | jude_iterator_go_to_index | bool | bool jude_iterator_go_to_index(jude_iterator_t *iter, jude_size_t index)
{
const jude_field_t *start = iter->current_field;
do
{
if (iter->field_index == index)
{
/* Found the wanted field */
return true;
}
(void) jude_iterator_next(iter);
} while (iter->current_field != start);
iter->field_index = JUDE_UNKNOWN_FIELD_INDEX;
/* Searched all the way back to start, and found nothing. */
return false;
} | /* Advance the iterator to the given field index.
* Returns false when the iterator wraps back to the first field. */ | Advance the iterator to the given field index.
Returns false when the iterator wraps back to the first field. | [
"Advance",
"the",
"iterator",
"to",
"the",
"given",
"field",
"index",
".",
"Returns",
"false",
"when",
"the",
"iterator",
"wraps",
"back",
"to",
"the",
"first",
"field",
"."
] | bool jude_iterator_go_to_index(jude_iterator_t *iter, jude_size_t index)
{
const jude_field_t *start = iter->current_field;
do
{
if (iter->field_index == index)
{
return true;
}
(void) jude_iterator_next(iter);
} while (iter->current_field != start);
iter->field_index = JUDE_UNKNOWN_FIELD_INDEX;
return false;
} | [
"bool",
"jude_iterator_go_to_index",
"(",
"jude_iterator_t",
"*",
"iter",
",",
"jude_size_t",
"index",
")",
"{",
"const",
"jude_field_t",
"*",
"start",
"=",
"iter",
"->",
"current_field",
";",
"do",
"{",
"if",
"(",
"iter",
"->",
"field_index",
"==",
"index",
")",
"{",
"return",
"true",
";",
"}",
"(",
"void",
")",
"jude_iterator_next",
"(",
"iter",
")",
";",
"}",
"while",
"(",
"iter",
"->",
"current_field",
"!=",
"start",
")",
";",
"iter",
"->",
"field_index",
"=",
"JUDE_UNKNOWN_FIELD_INDEX",
";",
"return",
"false",
";",
"}"
] | Advance the iterator to the given field index. | [
"Advance",
"the",
"iterator",
"to",
"the",
"given",
"field",
"index",
"."
] | [
"/* Found the wanted field */",
"/* Searched all the way back to start, and found nothing. */"
] | [
{
"param": "iter",
"type": "jude_iterator_t"
},
{
"param": "index",
"type": "jude_size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "iter",
"type": "jude_iterator_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "jude_size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d7f9274c82ddce3defdf17cdcfaf7b6bf1b718c | jeptechnology/jude | src/core/c/jude_iterator.c | [
"MIT"
] | C | jude_iterator_get_count_reference | jude_size_t | jude_size_t* jude_iterator_get_count_reference(jude_iterator_t *iter)
{
if (!iter) return NULL;
return jude_get_array_count_reference(iter->current_field, iter->details.data);
} | // get pointer to the "count" variable (if iterator not pointing at array field, returns NULL) | get pointer to the "count" variable (if iterator not pointing at array field, returns NULL) | [
"get",
"pointer",
"to",
"the",
"\"",
"count",
"\"",
"variable",
"(",
"if",
"iterator",
"not",
"pointing",
"at",
"array",
"field",
"returns",
"NULL",
")"
] | jude_size_t* jude_iterator_get_count_reference(jude_iterator_t *iter)
{
if (!iter) return NULL;
return jude_get_array_count_reference(iter->current_field, iter->details.data);
} | [
"jude_size_t",
"*",
"jude_iterator_get_count_reference",
"(",
"jude_iterator_t",
"*",
"iter",
")",
"{",
"if",
"(",
"!",
"iter",
")",
"return",
"NULL",
";",
"return",
"jude_get_array_count_reference",
"(",
"iter",
"->",
"current_field",
",",
"iter",
"->",
"details",
".",
"data",
")",
";",
"}"
] | get pointer to the "count" variable (if iterator not pointing at array field, returns NULL) | [
"get",
"pointer",
"to",
"the",
"\"",
"count",
"\"",
"variable",
"(",
"if",
"iterator",
"not",
"pointing",
"at",
"array",
"field",
"returns",
"NULL",
")"
] | [] | [
{
"param": "iter",
"type": "jude_iterator_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "iter",
"type": "jude_iterator_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a6c801ab64733d342b6b430529ecde93b9880148 | jeptechnology/jude | src/core/c/jude_object.c | [
"MIT"
] | C | jude_object_compare | int | int jude_object_compare(const jude_object_t *lhs_struct, const jude_object_t *rhs_struct)
{
static const int LhsGreaterThanRhs = 1;
static const int LhsLessThanRhs = -1;
static const int LhsEqualToRhs = 0;
// trivial cases
if (lhs_struct == rhs_struct) return LhsEqualToRhs;
if (lhs_struct == NULL) return LhsLessThanRhs;
if (rhs_struct == NULL) return LhsGreaterThanRhs;
int result;
jude_iterator_t lhs_iter = jude_iterator_begin(jude_remove_const(lhs_struct));
jude_iterator_t rhs_iter = jude_iterator_begin(jude_remove_const(rhs_struct));
// iteratre through the fields, use recursion on submessages (and arrays of sub messages!)
do
{
bool lhs_isset = jude_filter_is_touched(lhs_iter.object->__mask, lhs_iter.field_index);
bool rhs_isset = jude_filter_is_touched(rhs_iter.object->__mask, rhs_iter.field_index);
if (!lhs_isset && !rhs_isset)
{
// neither field set, skip test
continue;
}
else if (lhs_isset && !rhs_isset)
{
return LhsGreaterThanRhs;
}
else if (!lhs_isset && rhs_isset)
{
return LhsLessThanRhs;
}
if (lhs_iter.current_field->type == JUDE_TYPE_OBJECT)
{
// When comparing protobuf messages, we must treat submessages field in a special way
// they contain dirty flags that may differ but that should not affect equality
// Here, we recurse into each sub message (more complicated if it's an aray of submessages!)
if (!jude_iterator_is_array(&lhs_iter))
{
// Recurse into single sub message
result = jude_object_compare(lhs_iter.details.sub_object, rhs_iter.details.sub_object);
if (result != 0)
{
return result;
}
}
else
{
// Recurse into each sub message
jude_size_t index;
jude_size_t lhs_count = jude_get_array_count(lhs_iter.current_field, lhs_iter.details.data);
jude_size_t rhs_count = jude_get_array_count(rhs_iter.current_field, rhs_iter.details.data);
if (lhs_count < rhs_count)
{
return LhsLessThanRhs;
}
else if (lhs_count > rhs_count)
{
return LhsGreaterThanRhs;
}
for (index = 0; index < lhs_count; index++)
{
jude_object_t *lhs_subresource = (jude_object_t*) jude_iterator_get_data(&lhs_iter, index);
jude_object_t *rhs_subresource = (jude_object_t*) jude_iterator_get_data(&rhs_iter, index);
result = jude_object_compare(lhs_subresource, rhs_subresource);
if (result != 0)
{
return result;
}
}
}
}
else
{
jude_size_t lengthOfDataToCompare = lhs_iter.current_field->data_size;
if (jude_iterator_is_array(&lhs_iter))
{
jude_size_t lhs_count = jude_iterator_get_count(&lhs_iter);
jude_size_t rhs_count = jude_iterator_get_count(&rhs_iter);
if (lhs_count < rhs_count)
{
return LhsLessThanRhs;
}
else if (lhs_count > rhs_count)
{
return LhsGreaterThanRhs;
}
else
{
lengthOfDataToCompare = lhs_count * jude_field_get_size(lhs_iter.current_field);
}
}
result = memcmp(lhs_iter.details.data, rhs_iter.details.data, lengthOfDataToCompare);
if (result != 0)
{
return result;
}
}
} while (jude_iterator_next(&lhs_iter) && jude_iterator_next(&rhs_iter));
return LhsEqualToRhs;
} | /*
* Similar to memcmp but for messages. This is important because:
*
* - We need to ignore bitmask differences that just show different fields are dirty
* - We need to ignore memory differences in fields that are marked unset
* - We need to ignore memory differences in repeated fields where the data is not relevant
*/ | Similar to memcmp but for messages. This is important because:
- We need to ignore bitmask differences that just show different fields are dirty
- We need to ignore memory differences in fields that are marked unset
- We need to ignore memory differences in repeated fields where the data is not relevant | [
"Similar",
"to",
"memcmp",
"but",
"for",
"messages",
".",
"This",
"is",
"important",
"because",
":",
"-",
"We",
"need",
"to",
"ignore",
"bitmask",
"differences",
"that",
"just",
"show",
"different",
"fields",
"are",
"dirty",
"-",
"We",
"need",
"to",
"ignore",
"memory",
"differences",
"in",
"fields",
"that",
"are",
"marked",
"unset",
"-",
"We",
"need",
"to",
"ignore",
"memory",
"differences",
"in",
"repeated",
"fields",
"where",
"the",
"data",
"is",
"not",
"relevant"
] | int jude_object_compare(const jude_object_t *lhs_struct, const jude_object_t *rhs_struct)
{
static const int LhsGreaterThanRhs = 1;
static const int LhsLessThanRhs = -1;
static const int LhsEqualToRhs = 0;
if (lhs_struct == rhs_struct) return LhsEqualToRhs;
if (lhs_struct == NULL) return LhsLessThanRhs;
if (rhs_struct == NULL) return LhsGreaterThanRhs;
int result;
jude_iterator_t lhs_iter = jude_iterator_begin(jude_remove_const(lhs_struct));
jude_iterator_t rhs_iter = jude_iterator_begin(jude_remove_const(rhs_struct));
do
{
bool lhs_isset = jude_filter_is_touched(lhs_iter.object->__mask, lhs_iter.field_index);
bool rhs_isset = jude_filter_is_touched(rhs_iter.object->__mask, rhs_iter.field_index);
if (!lhs_isset && !rhs_isset)
{
continue;
}
else if (lhs_isset && !rhs_isset)
{
return LhsGreaterThanRhs;
}
else if (!lhs_isset && rhs_isset)
{
return LhsLessThanRhs;
}
if (lhs_iter.current_field->type == JUDE_TYPE_OBJECT)
{
if (!jude_iterator_is_array(&lhs_iter))
{
result = jude_object_compare(lhs_iter.details.sub_object, rhs_iter.details.sub_object);
if (result != 0)
{
return result;
}
}
else
{
jude_size_t index;
jude_size_t lhs_count = jude_get_array_count(lhs_iter.current_field, lhs_iter.details.data);
jude_size_t rhs_count = jude_get_array_count(rhs_iter.current_field, rhs_iter.details.data);
if (lhs_count < rhs_count)
{
return LhsLessThanRhs;
}
else if (lhs_count > rhs_count)
{
return LhsGreaterThanRhs;
}
for (index = 0; index < lhs_count; index++)
{
jude_object_t *lhs_subresource = (jude_object_t*) jude_iterator_get_data(&lhs_iter, index);
jude_object_t *rhs_subresource = (jude_object_t*) jude_iterator_get_data(&rhs_iter, index);
result = jude_object_compare(lhs_subresource, rhs_subresource);
if (result != 0)
{
return result;
}
}
}
}
else
{
jude_size_t lengthOfDataToCompare = lhs_iter.current_field->data_size;
if (jude_iterator_is_array(&lhs_iter))
{
jude_size_t lhs_count = jude_iterator_get_count(&lhs_iter);
jude_size_t rhs_count = jude_iterator_get_count(&rhs_iter);
if (lhs_count < rhs_count)
{
return LhsLessThanRhs;
}
else if (lhs_count > rhs_count)
{
return LhsGreaterThanRhs;
}
else
{
lengthOfDataToCompare = lhs_count * jude_field_get_size(lhs_iter.current_field);
}
}
result = memcmp(lhs_iter.details.data, rhs_iter.details.data, lengthOfDataToCompare);
if (result != 0)
{
return result;
}
}
} while (jude_iterator_next(&lhs_iter) && jude_iterator_next(&rhs_iter));
return LhsEqualToRhs;
} | [
"int",
"jude_object_compare",
"(",
"const",
"jude_object_t",
"*",
"lhs_struct",
",",
"const",
"jude_object_t",
"*",
"rhs_struct",
")",
"{",
"static",
"const",
"int",
"LhsGreaterThanRhs",
"=",
"1",
";",
"static",
"const",
"int",
"LhsLessThanRhs",
"=",
"-1",
";",
"static",
"const",
"int",
"LhsEqualToRhs",
"=",
"0",
";",
"if",
"(",
"lhs_struct",
"==",
"rhs_struct",
")",
"return",
"LhsEqualToRhs",
";",
"if",
"(",
"lhs_struct",
"==",
"NULL",
")",
"return",
"LhsLessThanRhs",
";",
"if",
"(",
"rhs_struct",
"==",
"NULL",
")",
"return",
"LhsGreaterThanRhs",
";",
"int",
"result",
";",
"jude_iterator_t",
"lhs_iter",
"=",
"jude_iterator_begin",
"(",
"jude_remove_const",
"(",
"lhs_struct",
")",
")",
";",
"jude_iterator_t",
"rhs_iter",
"=",
"jude_iterator_begin",
"(",
"jude_remove_const",
"(",
"rhs_struct",
")",
")",
";",
"do",
"{",
"bool",
"lhs_isset",
"=",
"jude_filter_is_touched",
"(",
"lhs_iter",
".",
"object",
"->",
"__mask",
",",
"lhs_iter",
".",
"field_index",
")",
";",
"bool",
"rhs_isset",
"=",
"jude_filter_is_touched",
"(",
"rhs_iter",
".",
"object",
"->",
"__mask",
",",
"rhs_iter",
".",
"field_index",
")",
";",
"if",
"(",
"!",
"lhs_isset",
"&&",
"!",
"rhs_isset",
")",
"{",
"continue",
";",
"}",
"else",
"if",
"(",
"lhs_isset",
"&&",
"!",
"rhs_isset",
")",
"{",
"return",
"LhsGreaterThanRhs",
";",
"}",
"else",
"if",
"(",
"!",
"lhs_isset",
"&&",
"rhs_isset",
")",
"{",
"return",
"LhsLessThanRhs",
";",
"}",
"if",
"(",
"lhs_iter",
".",
"current_field",
"->",
"type",
"==",
"JUDE_TYPE_OBJECT",
")",
"{",
"if",
"(",
"!",
"jude_iterator_is_array",
"(",
"&",
"lhs_iter",
")",
")",
"{",
"result",
"=",
"jude_object_compare",
"(",
"lhs_iter",
".",
"details",
".",
"sub_object",
",",
"rhs_iter",
".",
"details",
".",
"sub_object",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"{",
"return",
"result",
";",
"}",
"}",
"else",
"{",
"jude_size_t",
"index",
";",
"jude_size_t",
"lhs_count",
"=",
"jude_get_array_count",
"(",
"lhs_iter",
".",
"current_field",
",",
"lhs_iter",
".",
"details",
".",
"data",
")",
";",
"jude_size_t",
"rhs_count",
"=",
"jude_get_array_count",
"(",
"rhs_iter",
".",
"current_field",
",",
"rhs_iter",
".",
"details",
".",
"data",
")",
";",
"if",
"(",
"lhs_count",
"<",
"rhs_count",
")",
"{",
"return",
"LhsLessThanRhs",
";",
"}",
"else",
"if",
"(",
"lhs_count",
">",
"rhs_count",
")",
"{",
"return",
"LhsGreaterThanRhs",
";",
"}",
"for",
"(",
"index",
"=",
"0",
";",
"index",
"<",
"lhs_count",
";",
"index",
"++",
")",
"{",
"jude_object_t",
"*",
"lhs_subresource",
"=",
"(",
"jude_object_t",
"*",
")",
"jude_iterator_get_data",
"(",
"&",
"lhs_iter",
",",
"index",
")",
";",
"jude_object_t",
"*",
"rhs_subresource",
"=",
"(",
"jude_object_t",
"*",
")",
"jude_iterator_get_data",
"(",
"&",
"rhs_iter",
",",
"index",
")",
";",
"result",
"=",
"jude_object_compare",
"(",
"lhs_subresource",
",",
"rhs_subresource",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"jude_size_t",
"lengthOfDataToCompare",
"=",
"lhs_iter",
".",
"current_field",
"->",
"data_size",
";",
"if",
"(",
"jude_iterator_is_array",
"(",
"&",
"lhs_iter",
")",
")",
"{",
"jude_size_t",
"lhs_count",
"=",
"jude_iterator_get_count",
"(",
"&",
"lhs_iter",
")",
";",
"jude_size_t",
"rhs_count",
"=",
"jude_iterator_get_count",
"(",
"&",
"rhs_iter",
")",
";",
"if",
"(",
"lhs_count",
"<",
"rhs_count",
")",
"{",
"return",
"LhsLessThanRhs",
";",
"}",
"else",
"if",
"(",
"lhs_count",
">",
"rhs_count",
")",
"{",
"return",
"LhsGreaterThanRhs",
";",
"}",
"else",
"{",
"lengthOfDataToCompare",
"=",
"lhs_count",
"*",
"jude_field_get_size",
"(",
"lhs_iter",
".",
"current_field",
")",
";",
"}",
"}",
"result",
"=",
"memcmp",
"(",
"lhs_iter",
".",
"details",
".",
"data",
",",
"rhs_iter",
".",
"details",
".",
"data",
",",
"lengthOfDataToCompare",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"while",
"(",
"jude_iterator_next",
"(",
"&",
"lhs_iter",
")",
"&&",
"jude_iterator_next",
"(",
"&",
"rhs_iter",
")",
")",
";",
"return",
"LhsEqualToRhs",
";",
"}"
] | Similar to memcmp but for messages. | [
"Similar",
"to",
"memcmp",
"but",
"for",
"messages",
"."
] | [
"// trivial cases",
"// iteratre through the fields, use recursion on submessages (and arrays of sub messages!)",
"// neither field set, skip test",
"// When comparing protobuf messages, we must treat submessages field in a special way",
"// they contain dirty flags that may differ but that should not affect equality",
"// Here, we recurse into each sub message (more complicated if it's an aray of submessages!)",
"// Recurse into single sub message",
"// Recurse into each sub message"
] | [
{
"param": "lhs_struct",
"type": "jude_object_t"
},
{
"param": "rhs_struct",
"type": "jude_object_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lhs_struct",
"type": "jude_object_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhs_struct",
"type": "jude_object_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1c9f73192045397e3914835b8d17841d53f76c2c | jeptechnology/jude | src/core/c/jude_decode_binary.c | [
"MIT"
] | C | binary_context_substream_open | bool | static bool binary_context_substream_open(jude_context_type_t type, jude_istream_t *stream, jude_istream_t *substream)
{
switch (type)
{
case JUDE_CONTEXT_STRING:
case JUDE_CONTEXT_DELIMITED:
case JUDE_CONTEXT_REPEATED:
case JUDE_CONTEXT_SUBMESSAGE:
return jude_make_string_substream(stream, substream);
case JUDE_CONTEXT_MESSAGE:
memcpy(substream, stream, sizeof(jude_istream_t));
break;
}
return true;
} | /* Decode string length from stream and return a substream with limited length.
* Remember to close the substream using jude_close_context_substream().
*/ | Decode string length from stream and return a substream with limited length.
Remember to close the substream using jude_close_context_substream(). | [
"Decode",
"string",
"length",
"from",
"stream",
"and",
"return",
"a",
"substream",
"with",
"limited",
"length",
".",
"Remember",
"to",
"close",
"the",
"substream",
"using",
"jude_close_context_substream",
"()",
"."
] | static bool binary_context_substream_open(jude_context_type_t type, jude_istream_t *stream, jude_istream_t *substream)
{
switch (type)
{
case JUDE_CONTEXT_STRING:
case JUDE_CONTEXT_DELIMITED:
case JUDE_CONTEXT_REPEATED:
case JUDE_CONTEXT_SUBMESSAGE:
return jude_make_string_substream(stream, substream);
case JUDE_CONTEXT_MESSAGE:
memcpy(substream, stream, sizeof(jude_istream_t));
break;
}
return true;
} | [
"static",
"bool",
"binary_context_substream_open",
"(",
"jude_context_type_t",
"type",
",",
"jude_istream_t",
"*",
"stream",
",",
"jude_istream_t",
"*",
"substream",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"JUDE_CONTEXT_STRING",
":",
"case",
"JUDE_CONTEXT_DELIMITED",
":",
"case",
"JUDE_CONTEXT_REPEATED",
":",
"case",
"JUDE_CONTEXT_SUBMESSAGE",
":",
"return",
"jude_make_string_substream",
"(",
"stream",
",",
"substream",
")",
";",
"case",
"JUDE_CONTEXT_MESSAGE",
":",
"memcpy",
"(",
"substream",
",",
"stream",
",",
"sizeof",
"(",
"jude_istream_t",
")",
")",
";",
"break",
";",
"}",
"return",
"true",
";",
"}"
] | Decode string length from stream and return a substream with limited length. | [
"Decode",
"string",
"length",
"from",
"stream",
"and",
"return",
"a",
"substream",
"with",
"limited",
"length",
"."
] | [] | [
{
"param": "type",
"type": "jude_context_type_t"
},
{
"param": "stream",
"type": "jude_istream_t"
},
{
"param": "substream",
"type": "jude_istream_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "type",
"type": "jude_context_type_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stream",
"type": "jude_istream_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "substream",
"type": "jude_istream_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1c9f73192045397e3914835b8d17841d53f76c2c | jeptechnology/jude | src/core/c/jude_decode_binary.c | [
"MIT"
] | C | binary_context_substream_next_element | bool | static bool binary_context_substream_next_element(jude_context_type_t type, jude_istream_t *substream)
{
if (type == JUDE_CONTEXT_DELIMITED)
{
// delimited field stream...
}
return true;
} | /*
* Move to next element within a substream context
* - useful for traversing arrays in wiretypes like JSON
*/ | Move to next element within a substream context
- useful for traversing arrays in wiretypes like JSON | [
"Move",
"to",
"next",
"element",
"within",
"a",
"substream",
"context",
"-",
"useful",
"for",
"traversing",
"arrays",
"in",
"wiretypes",
"like",
"JSON"
] | static bool binary_context_substream_next_element(jude_context_type_t type, jude_istream_t *substream)
{
if (type == JUDE_CONTEXT_DELIMITED)
{
}
return true;
} | [
"static",
"bool",
"binary_context_substream_next_element",
"(",
"jude_context_type_t",
"type",
",",
"jude_istream_t",
"*",
"substream",
")",
"{",
"if",
"(",
"type",
"==",
"JUDE_CONTEXT_DELIMITED",
")",
"{",
"}",
"return",
"true",
";",
"}"
] | Move to next element within a substream context
- useful for traversing arrays in wiretypes like JSON | [
"Move",
"to",
"next",
"element",
"within",
"a",
"substream",
"context",
"-",
"useful",
"for",
"traversing",
"arrays",
"in",
"wiretypes",
"like",
"JSON"
] | [
"// delimited field stream..."
] | [
{
"param": "type",
"type": "jude_context_type_t"
},
{
"param": "substream",
"type": "jude_istream_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "type",
"type": "jude_context_type_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "substream",
"type": "jude_istream_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0efed9ff9cd0786d2ff47ba79bed92fd542042d9 | jeptechnology/jude | src/core/c/jude_decode.c | [
"MIT"
] | C | jude_field_set_to_default | void | static void jude_field_set_to_default(jude_iterator_t *iter)
{
jude_type_t type = iter->current_field->type;
bool init_data = true;
if (!jude_iterator_is_array(iter))
{
/* Set has_field to false. Still initialize the optional field itself also. */
jude_filter_set_touched(iter->object->__mask, iter->field_index, false);
}
else
{
/* REPEATED: Set array count to 0, no need to initialize contents.*/
*(jude_size_t*)jude_iterator_get_count_reference(iter) = 0;
init_data = false;
}
if (init_data)
{
if (jude_field_is_object(iter->current_field))
{
/* Initialize submessage to defaults */
jude_message_set_to_defaults(iter->details.sub_object);
}
else if ((iter->current_field->details.default_data != NULL) && (type != JUDE_TYPE_ENUM))
{
/* Initialize to default value */
memcpy(iter->details.data,
iter->current_field->details.default_data,
iter->current_field->data_size);
}
else
{
/* Initialize to zeros */
memset(iter->details.data, 0, iter->current_field->data_size);
}
}
} | /* Initialize message fields to default values, recursively */ | Initialize message fields to default values, recursively | [
"Initialize",
"message",
"fields",
"to",
"default",
"values",
"recursively"
] | static void jude_field_set_to_default(jude_iterator_t *iter)
{
jude_type_t type = iter->current_field->type;
bool init_data = true;
if (!jude_iterator_is_array(iter))
{
jude_filter_set_touched(iter->object->__mask, iter->field_index, false);
}
else
{
*(jude_size_t*)jude_iterator_get_count_reference(iter) = 0;
init_data = false;
}
if (init_data)
{
if (jude_field_is_object(iter->current_field))
{
jude_message_set_to_defaults(iter->details.sub_object);
}
else if ((iter->current_field->details.default_data != NULL) && (type != JUDE_TYPE_ENUM))
{
memcpy(iter->details.data,
iter->current_field->details.default_data,
iter->current_field->data_size);
}
else
{
memset(iter->details.data, 0, iter->current_field->data_size);
}
}
} | [
"static",
"void",
"jude_field_set_to_default",
"(",
"jude_iterator_t",
"*",
"iter",
")",
"{",
"jude_type_t",
"type",
"=",
"iter",
"->",
"current_field",
"->",
"type",
";",
"bool",
"init_data",
"=",
"true",
";",
"if",
"(",
"!",
"jude_iterator_is_array",
"(",
"iter",
")",
")",
"{",
"jude_filter_set_touched",
"(",
"iter",
"->",
"object",
"->",
"__mask",
",",
"iter",
"->",
"field_index",
",",
"false",
")",
";",
"}",
"else",
"{",
"*",
"(",
"jude_size_t",
"*",
")",
"jude_iterator_get_count_reference",
"(",
"iter",
")",
"=",
"0",
";",
"init_data",
"=",
"false",
";",
"}",
"if",
"(",
"init_data",
")",
"{",
"if",
"(",
"jude_field_is_object",
"(",
"iter",
"->",
"current_field",
")",
")",
"{",
"jude_message_set_to_defaults",
"(",
"iter",
"->",
"details",
".",
"sub_object",
")",
";",
"}",
"else",
"if",
"(",
"(",
"iter",
"->",
"current_field",
"->",
"details",
".",
"default_data",
"!=",
"NULL",
")",
"&&",
"(",
"type",
"!=",
"JUDE_TYPE_ENUM",
")",
")",
"{",
"memcpy",
"(",
"iter",
"->",
"details",
".",
"data",
",",
"iter",
"->",
"current_field",
"->",
"details",
".",
"default_data",
",",
"iter",
"->",
"current_field",
"->",
"data_size",
")",
";",
"}",
"else",
"{",
"memset",
"(",
"iter",
"->",
"details",
".",
"data",
",",
"0",
",",
"iter",
"->",
"current_field",
"->",
"data_size",
")",
";",
"}",
"}",
"}"
] | Initialize message fields to default values, recursively | [
"Initialize",
"message",
"fields",
"to",
"default",
"values",
"recursively"
] | [
"/* Set has_field to false. Still initialize the optional field itself also. */",
"/* REPEATED: Set array count to 0, no need to initialize contents.*/",
"/* Initialize submessage to defaults */",
"/* Initialize to default value */",
"/* Initialize to zeros */"
] | [
{
"param": "iter",
"type": "jude_iterator_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "iter",
"type": "jude_iterator_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nbcb_free | void | static void
gupcr_nbcb_free (gupcr_nbcb_p cb)
{
cb->next = gupcr_nbcb_cb_free;
gupcr_nbcb_cb_free = cb;
} | /**
* Place NB control block on the free list
*/ | Place NB control block on the free list | [
"Place",
"NB",
"control",
"block",
"on",
"the",
"free",
"list"
] | static void
gupcr_nbcb_free (gupcr_nbcb_p cb)
{
cb->next = gupcr_nbcb_cb_free;
gupcr_nbcb_cb_free = cb;
} | [
"static",
"void",
"gupcr_nbcb_free",
"(",
"gupcr_nbcb_p",
"cb",
")",
"{",
"cb",
"->",
"next",
"=",
"gupcr_nbcb_cb_free",
";",
"gupcr_nbcb_cb_free",
"=",
"cb",
";",
"}"
] | Place NB control block on the free list | [
"Place",
"NB",
"control",
"block",
"on",
"the",
"free",
"list"
] | [] | [
{
"param": "cb",
"type": "gupcr_nbcb_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cb",
"type": "gupcr_nbcb_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nbcb_active_insert | void | static void
gupcr_nbcb_active_insert (gupcr_nbcb_p cb)
{
cb->next = gupcr_nbcb_active;
gupcr_nbcb_active = cb;
} | /**
* Place NB control block on the active list
*/ | Place NB control block on the active list | [
"Place",
"NB",
"control",
"block",
"on",
"the",
"active",
"list"
] | static void
gupcr_nbcb_active_insert (gupcr_nbcb_p cb)
{
cb->next = gupcr_nbcb_active;
gupcr_nbcb_active = cb;
} | [
"static",
"void",
"gupcr_nbcb_active_insert",
"(",
"gupcr_nbcb_p",
"cb",
")",
"{",
"cb",
"->",
"next",
"=",
"gupcr_nbcb_active",
";",
"gupcr_nbcb_active",
"=",
"cb",
";",
"}"
] | Place NB control block on the active list | [
"Place",
"NB",
"control",
"block",
"on",
"the",
"active",
"list"
] | [] | [
{
"param": "cb",
"type": "gupcr_nbcb_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cb",
"type": "gupcr_nbcb_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nbcb_active_remove | void | static void
gupcr_nbcb_active_remove (gupcr_nbcb_p cb)
{
gupcr_nbcb_p acb = gupcr_nbcb_active;
gupcr_nbcb_p prev_acb = acb;
while (acb)
{
if (acb == cb)
{
if (acb == gupcr_nbcb_active)
gupcr_nbcb_active = acb->next;
else
prev_acb->next = acb->next;
return;
}
prev_acb = acb;
acb = acb->next;
}
} | /**
* Remove NB control block from the active list
*/ | Remove NB control block from the active list | [
"Remove",
"NB",
"control",
"block",
"from",
"the",
"active",
"list"
] | static void
gupcr_nbcb_active_remove (gupcr_nbcb_p cb)
{
gupcr_nbcb_p acb = gupcr_nbcb_active;
gupcr_nbcb_p prev_acb = acb;
while (acb)
{
if (acb == cb)
{
if (acb == gupcr_nbcb_active)
gupcr_nbcb_active = acb->next;
else
prev_acb->next = acb->next;
return;
}
prev_acb = acb;
acb = acb->next;
}
} | [
"static",
"void",
"gupcr_nbcb_active_remove",
"(",
"gupcr_nbcb_p",
"cb",
")",
"{",
"gupcr_nbcb_p",
"acb",
"=",
"gupcr_nbcb_active",
";",
"gupcr_nbcb_p",
"prev_acb",
"=",
"acb",
";",
"while",
"(",
"acb",
")",
"{",
"if",
"(",
"acb",
"==",
"cb",
")",
"{",
"if",
"(",
"acb",
"==",
"gupcr_nbcb_active",
")",
"gupcr_nbcb_active",
"=",
"acb",
"->",
"next",
";",
"else",
"prev_acb",
"->",
"next",
"=",
"acb",
"->",
"next",
";",
"return",
";",
"}",
"prev_acb",
"=",
"acb",
";",
"acb",
"=",
"acb",
"->",
"next",
";",
"}",
"}"
] | Remove NB control block from the active list | [
"Remove",
"NB",
"control",
"block",
"from",
"the",
"active",
"list"
] | [] | [
{
"param": "cb",
"type": "gupcr_nbcb_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cb",
"type": "gupcr_nbcb_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nbcb_find | gupcr_nbcb_p | static gupcr_nbcb_p
gupcr_nbcb_find (unsigned long id)
{
gupcr_nbcb_p cb = gupcr_nbcb_active;
while (cb)
{
if (cb->id == id)
return cb;
cb = cb->next;
}
return NULL;
} | /**
* Find NB control block on the active list
*/ | Find NB control block on the active list | [
"Find",
"NB",
"control",
"block",
"on",
"the",
"active",
"list"
] | static gupcr_nbcb_p
gupcr_nbcb_find (unsigned long id)
{
gupcr_nbcb_p cb = gupcr_nbcb_active;
while (cb)
{
if (cb->id == id)
return cb;
cb = cb->next;
}
return NULL;
} | [
"static",
"gupcr_nbcb_p",
"gupcr_nbcb_find",
"(",
"unsigned",
"long",
"id",
")",
"{",
"gupcr_nbcb_p",
"cb",
"=",
"gupcr_nbcb_active",
";",
"while",
"(",
"cb",
")",
"{",
"if",
"(",
"cb",
"->",
"id",
"==",
"id",
")",
"return",
"cb",
";",
"cb",
"=",
"cb",
"->",
"next",
";",
"}",
"return",
"NULL",
";",
"}"
] | Find NB control block on the active list | [
"Find",
"NB",
"control",
"block",
"on",
"the",
"active",
"list"
] | [] | [
{
"param": "id",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nb_check_outstanding | void | void
gupcr_nb_check_outstanding (void)
{
if (gupcr_nb_outstanding == GUPCR_NB_MAX_OUTSTANDING)
{
/* We have to wait for at least one to complete. */
ptl_event_t event;
gupcr_portals_call (PtlEQWait, (gupcr_nb_md_eq, &event));
/* Process only ACKs and REPLYs, */
if (event.type == PTL_EVENT_ACK || event.type == PTL_EVENT_REPLY)
{
gupcr_nbcb_p cb;
unsigned long id = (unsigned long) event.user_ptr;
gupcr_debug (FC_NB, "received event for handle %lu", id);
cb = gupcr_nbcb_find (id);
if (!cb || cb->status == NB_STATUS_COMPLETED)
{
gupcr_fatal_error
("received event for unexistent or already completed"
" NB handle");
}
cb->status = NB_STATUS_COMPLETED;
gupcr_nb_outstanding--;
}
else
{
gupcr_fatal_error ("received event of invalid type: %s",
gupcr_streqtype (event.type));
}
}
} | /**
* Check for the max number of outstanding non-blocking
* transfers with explicit handle
*
* We cannot allow for number of outstanding transfers
* to go over the event queue size. Otherwise, some ACK/REPLY
* can be dropped.
*/ | Check for the max number of outstanding non-blocking
transfers with explicit handle
We cannot allow for number of outstanding transfers
to go over the event queue size. Otherwise, some ACK/REPLY
can be dropped. | [
"Check",
"for",
"the",
"max",
"number",
"of",
"outstanding",
"non",
"-",
"blocking",
"transfers",
"with",
"explicit",
"handle",
"We",
"cannot",
"allow",
"for",
"number",
"of",
"outstanding",
"transfers",
"to",
"go",
"over",
"the",
"event",
"queue",
"size",
".",
"Otherwise",
"some",
"ACK",
"/",
"REPLY",
"can",
"be",
"dropped",
"."
] | void
gupcr_nb_check_outstanding (void)
{
if (gupcr_nb_outstanding == GUPCR_NB_MAX_OUTSTANDING)
{
ptl_event_t event;
gupcr_portals_call (PtlEQWait, (gupcr_nb_md_eq, &event));
if (event.type == PTL_EVENT_ACK || event.type == PTL_EVENT_REPLY)
{
gupcr_nbcb_p cb;
unsigned long id = (unsigned long) event.user_ptr;
gupcr_debug (FC_NB, "received event for handle %lu", id);
cb = gupcr_nbcb_find (id);
if (!cb || cb->status == NB_STATUS_COMPLETED)
{
gupcr_fatal_error
("received event for unexistent or already completed"
" NB handle");
}
cb->status = NB_STATUS_COMPLETED;
gupcr_nb_outstanding--;
}
else
{
gupcr_fatal_error ("received event of invalid type: %s",
gupcr_streqtype (event.type));
}
}
} | [
"void",
"gupcr_nb_check_outstanding",
"(",
"void",
")",
"{",
"if",
"(",
"gupcr_nb_outstanding",
"==",
"GUPCR_NB_MAX_OUTSTANDING",
")",
"{",
"ptl_event_t",
"event",
";",
"gupcr_portals_call",
"(",
"PtlEQWait",
",",
"(",
"gupcr_nb_md_eq",
",",
"&",
"event",
")",
")",
";",
"if",
"(",
"event",
".",
"type",
"==",
"PTL_EVENT_ACK",
"||",
"event",
".",
"type",
"==",
"PTL_EVENT_REPLY",
")",
"{",
"gupcr_nbcb_p",
"cb",
";",
"unsigned",
"long",
"id",
"=",
"(",
"unsigned",
"long",
")",
"event",
".",
"user_ptr",
";",
"gupcr_debug",
"(",
"FC_NB",
",",
"\"",
"\"",
",",
"id",
")",
";",
"cb",
"=",
"gupcr_nbcb_find",
"(",
"id",
")",
";",
"if",
"(",
"!",
"cb",
"||",
"cb",
"->",
"status",
"==",
"NB_STATUS_COMPLETED",
")",
"{",
"gupcr_fatal_error",
"(",
"\"",
"\"",
"\"",
"\"",
")",
";",
"}",
"cb",
"->",
"status",
"=",
"NB_STATUS_COMPLETED",
";",
"gupcr_nb_outstanding",
"--",
";",
"}",
"else",
"{",
"gupcr_fatal_error",
"(",
"\"",
"\"",
",",
"gupcr_streqtype",
"(",
"event",
".",
"type",
")",
")",
";",
"}",
"}",
"}"
] | Check for the max number of outstanding non-blocking
transfers with explicit handle | [
"Check",
"for",
"the",
"max",
"number",
"of",
"outstanding",
"non",
"-",
"blocking",
"transfers",
"with",
"explicit",
"handle"
] | [
"/* We have to wait for at least one to complete. */",
"/* Process only ACKs and REPLYs, */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nb_completed | int | int
gupcr_nb_completed (unsigned long handle)
{
ptl_event_t event;
int done = 0;
gupcr_nbcb_p cb;
/* Handle Portals completion events. */
while (!done)
{
int pstatus;
gupcr_portals_call_with_status (PtlEQGet, pstatus,
(gupcr_nb_md_eq, &event));
if (pstatus == PTL_OK)
{
/* There is something to process. */
if (event.type == PTL_EVENT_ACK || event.type == PTL_EVENT_REPLY)
{
unsigned long id = (unsigned long) event.user_ptr;
gupcr_debug (FC_NB, "received event for handle %lu", id);
cb = gupcr_nbcb_find (id);
if (!cb)
gupcr_fatal_error ("received event for invalid NB handle");
cb->status = NB_STATUS_COMPLETED;
gupcr_nb_outstanding--;
}
else
{
gupcr_fatal_error ("received event of invalid type: %s",
gupcr_streqtype (event.type));
}
}
else
done = 1;
}
/* Check if transfer is completed. */
cb = gupcr_nbcb_find (handle);
if (cb && cb->status == NB_STATUS_COMPLETED)
{
gupcr_nbcb_active_remove (cb);
gupcr_nbcb_free (cb);
return 1;
}
return 0;
} | /**
* Check for non-blocking transfer complete
*
* @param[in] handle Transfer handle
* @retval "1" if transfer completed
*/ | Check for non-blocking transfer complete
@param[in] handle Transfer handle
@retval "1" if transfer completed | [
"Check",
"for",
"non",
"-",
"blocking",
"transfer",
"complete",
"@param",
"[",
"in",
"]",
"handle",
"Transfer",
"handle",
"@retval",
"\"",
"1",
"\"",
"if",
"transfer",
"completed"
] | int
gupcr_nb_completed (unsigned long handle)
{
ptl_event_t event;
int done = 0;
gupcr_nbcb_p cb;
while (!done)
{
int pstatus;
gupcr_portals_call_with_status (PtlEQGet, pstatus,
(gupcr_nb_md_eq, &event));
if (pstatus == PTL_OK)
{
if (event.type == PTL_EVENT_ACK || event.type == PTL_EVENT_REPLY)
{
unsigned long id = (unsigned long) event.user_ptr;
gupcr_debug (FC_NB, "received event for handle %lu", id);
cb = gupcr_nbcb_find (id);
if (!cb)
gupcr_fatal_error ("received event for invalid NB handle");
cb->status = NB_STATUS_COMPLETED;
gupcr_nb_outstanding--;
}
else
{
gupcr_fatal_error ("received event of invalid type: %s",
gupcr_streqtype (event.type));
}
}
else
done = 1;
}
cb = gupcr_nbcb_find (handle);
if (cb && cb->status == NB_STATUS_COMPLETED)
{
gupcr_nbcb_active_remove (cb);
gupcr_nbcb_free (cb);
return 1;
}
return 0;
} | [
"int",
"gupcr_nb_completed",
"(",
"unsigned",
"long",
"handle",
")",
"{",
"ptl_event_t",
"event",
";",
"int",
"done",
"=",
"0",
";",
"gupcr_nbcb_p",
"cb",
";",
"while",
"(",
"!",
"done",
")",
"{",
"int",
"pstatus",
";",
"gupcr_portals_call_with_status",
"(",
"PtlEQGet",
",",
"pstatus",
",",
"(",
"gupcr_nb_md_eq",
",",
"&",
"event",
")",
")",
";",
"if",
"(",
"pstatus",
"==",
"PTL_OK",
")",
"{",
"if",
"(",
"event",
".",
"type",
"==",
"PTL_EVENT_ACK",
"||",
"event",
".",
"type",
"==",
"PTL_EVENT_REPLY",
")",
"{",
"unsigned",
"long",
"id",
"=",
"(",
"unsigned",
"long",
")",
"event",
".",
"user_ptr",
";",
"gupcr_debug",
"(",
"FC_NB",
",",
"\"",
"\"",
",",
"id",
")",
";",
"cb",
"=",
"gupcr_nbcb_find",
"(",
"id",
")",
";",
"if",
"(",
"!",
"cb",
")",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"cb",
"->",
"status",
"=",
"NB_STATUS_COMPLETED",
";",
"gupcr_nb_outstanding",
"--",
";",
"}",
"else",
"{",
"gupcr_fatal_error",
"(",
"\"",
"\"",
",",
"gupcr_streqtype",
"(",
"event",
".",
"type",
")",
")",
";",
"}",
"}",
"else",
"done",
"=",
"1",
";",
"}",
"cb",
"=",
"gupcr_nbcb_find",
"(",
"handle",
")",
";",
"if",
"(",
"cb",
"&&",
"cb",
"->",
"status",
"==",
"NB_STATUS_COMPLETED",
")",
"{",
"gupcr_nbcb_active_remove",
"(",
"cb",
")",
";",
"gupcr_nbcb_free",
"(",
"cb",
")",
";",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | Check for non-blocking transfer complete
@param[in] handle Transfer handle
@retval "1" if transfer completed | [
"Check",
"for",
"non",
"-",
"blocking",
"transfer",
"complete",
"@param",
"[",
"in",
"]",
"handle",
"Transfer",
"handle",
"@retval",
"\"",
"1",
"\"",
"if",
"transfer",
"completed"
] | [
"/* Handle Portals completion events. */",
"/* There is something to process. */",
"/* Check if transfer is completed. */"
] | [
{
"param": "handle",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_sync | void | void
gupcr_sync (unsigned long handle)
{
gupcr_nbcb_p cb;
gupcr_debug (FC_NB, "waiting for handle %lu", handle);
/* Check if transfer already completed. */
cb = gupcr_nbcb_find (handle);
if (!cb)
{
/* Handle does not exist. Assume it is a duplicate
sync request. */
return;
}
if (cb->status == NB_STATUS_COMPLETED)
{
/* Already completed. */
gupcr_nbcb_active_remove (cb);
gupcr_nbcb_free (cb);
}
else
{
int done = 0;
/* Must wait for portals to complete the transfer. */
while (!done)
{
ptl_event_t event;
int pstatus;
gupcr_portals_call_with_status (PtlEQGet, pstatus,
(gupcr_nb_md_eq, &event));
if (pstatus == PTL_OK)
{
/* Process only ACKs and REPLYs, */
gupcr_debug (FC_NB, "received event of type %s",
gupcr_streqtype (event.type));
if (event.type == PTL_EVENT_ACK
|| event.type == PTL_EVENT_REPLY)
{
unsigned long id = (unsigned long) event.user_ptr;
gupcr_debug (FC_NB, "received event for handle %lu", id);
cb = gupcr_nbcb_find (id);
if (!cb || cb->status == NB_STATUS_COMPLETED)
{
gupcr_fatal_error
("received event for unexistent or already completed"
" NB handle");
}
cb->status = NB_STATUS_COMPLETED;
gupcr_nb_outstanding--;
if (id == handle)
{
gupcr_nbcb_active_remove (cb);
gupcr_nbcb_free (cb);
done = 1;
}
}
else
{
gupcr_fatal_error ("received event of invalid type: %s",
gupcr_streqtype (event.type));
}
}
}
}
} | /**
* Complete non-blocking transfers with explicit handle
*
* Wait for outstanding request to complete.
*
* @param[in] handle Transfer handle
*/ | Complete non-blocking transfers with explicit handle
Wait for outstanding request to complete.
@param[in] handle Transfer handle | [
"Complete",
"non",
"-",
"blocking",
"transfers",
"with",
"explicit",
"handle",
"Wait",
"for",
"outstanding",
"request",
"to",
"complete",
".",
"@param",
"[",
"in",
"]",
"handle",
"Transfer",
"handle"
] | void
gupcr_sync (unsigned long handle)
{
gupcr_nbcb_p cb;
gupcr_debug (FC_NB, "waiting for handle %lu", handle);
cb = gupcr_nbcb_find (handle);
if (!cb)
{
return;
}
if (cb->status == NB_STATUS_COMPLETED)
{
gupcr_nbcb_active_remove (cb);
gupcr_nbcb_free (cb);
}
else
{
int done = 0;
while (!done)
{
ptl_event_t event;
int pstatus;
gupcr_portals_call_with_status (PtlEQGet, pstatus,
(gupcr_nb_md_eq, &event));
if (pstatus == PTL_OK)
{
gupcr_debug (FC_NB, "received event of type %s",
gupcr_streqtype (event.type));
if (event.type == PTL_EVENT_ACK
|| event.type == PTL_EVENT_REPLY)
{
unsigned long id = (unsigned long) event.user_ptr;
gupcr_debug (FC_NB, "received event for handle %lu", id);
cb = gupcr_nbcb_find (id);
if (!cb || cb->status == NB_STATUS_COMPLETED)
{
gupcr_fatal_error
("received event for unexistent or already completed"
" NB handle");
}
cb->status = NB_STATUS_COMPLETED;
gupcr_nb_outstanding--;
if (id == handle)
{
gupcr_nbcb_active_remove (cb);
gupcr_nbcb_free (cb);
done = 1;
}
}
else
{
gupcr_fatal_error ("received event of invalid type: %s",
gupcr_streqtype (event.type));
}
}
}
}
} | [
"void",
"gupcr_sync",
"(",
"unsigned",
"long",
"handle",
")",
"{",
"gupcr_nbcb_p",
"cb",
";",
"gupcr_debug",
"(",
"FC_NB",
",",
"\"",
"\"",
",",
"handle",
")",
";",
"cb",
"=",
"gupcr_nbcb_find",
"(",
"handle",
")",
";",
"if",
"(",
"!",
"cb",
")",
"{",
"return",
";",
"}",
"if",
"(",
"cb",
"->",
"status",
"==",
"NB_STATUS_COMPLETED",
")",
"{",
"gupcr_nbcb_active_remove",
"(",
"cb",
")",
";",
"gupcr_nbcb_free",
"(",
"cb",
")",
";",
"}",
"else",
"{",
"int",
"done",
"=",
"0",
";",
"while",
"(",
"!",
"done",
")",
"{",
"ptl_event_t",
"event",
";",
"int",
"pstatus",
";",
"gupcr_portals_call_with_status",
"(",
"PtlEQGet",
",",
"pstatus",
",",
"(",
"gupcr_nb_md_eq",
",",
"&",
"event",
")",
")",
";",
"if",
"(",
"pstatus",
"==",
"PTL_OK",
")",
"{",
"gupcr_debug",
"(",
"FC_NB",
",",
"\"",
"\"",
",",
"gupcr_streqtype",
"(",
"event",
".",
"type",
")",
")",
";",
"if",
"(",
"event",
".",
"type",
"==",
"PTL_EVENT_ACK",
"||",
"event",
".",
"type",
"==",
"PTL_EVENT_REPLY",
")",
"{",
"unsigned",
"long",
"id",
"=",
"(",
"unsigned",
"long",
")",
"event",
".",
"user_ptr",
";",
"gupcr_debug",
"(",
"FC_NB",
",",
"\"",
"\"",
",",
"id",
")",
";",
"cb",
"=",
"gupcr_nbcb_find",
"(",
"id",
")",
";",
"if",
"(",
"!",
"cb",
"||",
"cb",
"->",
"status",
"==",
"NB_STATUS_COMPLETED",
")",
"{",
"gupcr_fatal_error",
"(",
"\"",
"\"",
"\"",
"\"",
")",
";",
"}",
"cb",
"->",
"status",
"=",
"NB_STATUS_COMPLETED",
";",
"gupcr_nb_outstanding",
"--",
";",
"if",
"(",
"id",
"==",
"handle",
")",
"{",
"gupcr_nbcb_active_remove",
"(",
"cb",
")",
";",
"gupcr_nbcb_free",
"(",
"cb",
")",
";",
"done",
"=",
"1",
";",
"}",
"}",
"else",
"{",
"gupcr_fatal_error",
"(",
"\"",
"\"",
",",
"gupcr_streqtype",
"(",
"event",
".",
"type",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Complete non-blocking transfers with explicit handle
Wait for outstanding request to complete. | [
"Complete",
"non",
"-",
"blocking",
"transfers",
"with",
"explicit",
"handle",
"Wait",
"for",
"outstanding",
"request",
"to",
"complete",
"."
] | [
"/* Check if transfer already completed. */",
"/* Handle does not exist. Assume it is a duplicate\n sync request. */",
"/* Already completed. */",
"/* Must wait for portals to complete the transfer. */",
"/* Process only ACKs and REPLYs, */"
] | [
{
"param": "handle",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nbi_outstanding | int | int
gupcr_nbi_outstanding (void)
{
ptl_ct_event_t ct;
/* Check the number of completed transfers. */
gupcr_portals_call (PtlCTGet, (gupcr_nbi_md_ct, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_nbi_md_eq);
gupcr_fatal_error ("received an error on NBI MD");
}
return (int) (gupcr_nbi_md_count - ct.success);
} | /**
* Check for any outstanding implicit handle non-blocking transfer
*
* @retval Number of outstanding transfers
*/ | Check for any outstanding implicit handle non-blocking transfer
@retval Number of outstanding transfers | [
"Check",
"for",
"any",
"outstanding",
"implicit",
"handle",
"non",
"-",
"blocking",
"transfer",
"@retval",
"Number",
"of",
"outstanding",
"transfers"
] | int
gupcr_nbi_outstanding (void)
{
ptl_ct_event_t ct;
gupcr_portals_call (PtlCTGet, (gupcr_nbi_md_ct, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_nbi_md_eq);
gupcr_fatal_error ("received an error on NBI MD");
}
return (int) (gupcr_nbi_md_count - ct.success);
} | [
"int",
"gupcr_nbi_outstanding",
"(",
"void",
")",
"{",
"ptl_ct_event_t",
"ct",
";",
"gupcr_portals_call",
"(",
"PtlCTGet",
",",
"(",
"gupcr_nbi_md_ct",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_nbi_md_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"return",
"(",
"int",
")",
"(",
"gupcr_nbi_md_count",
"-",
"ct",
".",
"success",
")",
";",
"}"
] | Check for any outstanding implicit handle non-blocking transfer
@retval Number of outstanding transfers | [
"Check",
"for",
"any",
"outstanding",
"implicit",
"handle",
"non",
"-",
"blocking",
"transfer",
"@retval",
"Number",
"of",
"outstanding",
"transfers"
] | [
"/* Check the number of completed transfers. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nb_init | void | void
gupcr_nb_init (void)
{
ptl_md_t md;
ptl_pt_index_t pte;
ptl_le_t le;
gupcr_log (FC_NB, "non-blocking transfer init called");
/* Non-blocking transfers use their own PTE. */
gupcr_portals_call (PtlPTAlloc, (gupcr_ptl_ni, 0,
PTL_EQ_NONE, GUPCR_PTL_PTE_NB, &pte));
if (pte != GUPCR_PTL_PTE_NB)
gupcr_fatal_error ("cannot allocate PTE GUPCR_PTL_PTE_NB.");
gupcr_debug (FC_NB, "Non-blocking PTE allocated: %d", GUPCR_PTL_PTE_NB);
/* Allocate LE for non-blocking transfers. */
le.start = gupcr_gmem_base;
le.length = gupcr_gmem_size;
le.ct_handle = PTL_CT_NONE;
le.uid = PTL_UID_ANY;
le.options = PTL_LE_OP_PUT | PTL_LE_OP_GET;
gupcr_portals_call (PtlLEAppend,
(gupcr_ptl_ni, GUPCR_PTL_PTE_NB, &le,
PTL_PRIORITY_LIST, NULL, &gupcr_nb_le));
gupcr_debug (FC_NB,
"Non-blocking LE created at 0x%lx with size 0x%lx)",
(long unsigned) gupcr_gmem_base,
(long unsigned) gupcr_gmem_size);
/* Setup the Portals MD for local source/destination copying.
We need to map the whole user's space (same as gmem). */
/* Non-blocking transfers with explicit handles must use full events
there is no need for counting events. */
gupcr_portals_call (PtlEQAlloc,
(gupcr_ptl_ni, GUPCR_NB_MAX_OUTSTANDING,
&gupcr_nb_md_eq));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = PTL_MD_EVENT_SEND_DISABLE;
md.eq_handle = gupcr_nb_md_eq;
md.ct_handle = PTL_CT_NONE;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_nb_md));
gupcr_nb_md_start = md.start;
/* Non-blocking transfers with implicit handles use counting events. */
gupcr_portals_call (PtlEQAlloc, (gupcr_ptl_ni, 1, &gupcr_nbi_md_eq));
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_nbi_md_ct));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = PTL_MD_EVENT_CT_ACK | PTL_MD_EVENT_CT_REPLY |
PTL_MD_EVENT_SUCCESS_DISABLE;
md.eq_handle = gupcr_nbi_md_eq;
md.ct_handle = gupcr_nbi_md_ct;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_nbi_md));
gupcr_nbi_md_start = md.start;
/* Reset number of acknowledgments. */
gupcr_nbi_md_count = 0;
/* Initialize NB handle values. */
gupcr_nb_handle_next = 1;
/* Initialize number of outstanding transfers. */
gupcr_nb_outstanding = 0;
} | /**
* Initialize non-blocking transfer resources
* @ingroup INIT
*/ | Initialize non-blocking transfer resources
@ingroup INIT | [
"Initialize",
"non",
"-",
"blocking",
"transfer",
"resources",
"@ingroup",
"INIT"
] | void
gupcr_nb_init (void)
{
ptl_md_t md;
ptl_pt_index_t pte;
ptl_le_t le;
gupcr_log (FC_NB, "non-blocking transfer init called");
gupcr_portals_call (PtlPTAlloc, (gupcr_ptl_ni, 0,
PTL_EQ_NONE, GUPCR_PTL_PTE_NB, &pte));
if (pte != GUPCR_PTL_PTE_NB)
gupcr_fatal_error ("cannot allocate PTE GUPCR_PTL_PTE_NB.");
gupcr_debug (FC_NB, "Non-blocking PTE allocated: %d", GUPCR_PTL_PTE_NB);
le.start = gupcr_gmem_base;
le.length = gupcr_gmem_size;
le.ct_handle = PTL_CT_NONE;
le.uid = PTL_UID_ANY;
le.options = PTL_LE_OP_PUT | PTL_LE_OP_GET;
gupcr_portals_call (PtlLEAppend,
(gupcr_ptl_ni, GUPCR_PTL_PTE_NB, &le,
PTL_PRIORITY_LIST, NULL, &gupcr_nb_le));
gupcr_debug (FC_NB,
"Non-blocking LE created at 0x%lx with size 0x%lx)",
(long unsigned) gupcr_gmem_base,
(long unsigned) gupcr_gmem_size);
gupcr_portals_call (PtlEQAlloc,
(gupcr_ptl_ni, GUPCR_NB_MAX_OUTSTANDING,
&gupcr_nb_md_eq));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = PTL_MD_EVENT_SEND_DISABLE;
md.eq_handle = gupcr_nb_md_eq;
md.ct_handle = PTL_CT_NONE;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_nb_md));
gupcr_nb_md_start = md.start;
gupcr_portals_call (PtlEQAlloc, (gupcr_ptl_ni, 1, &gupcr_nbi_md_eq));
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_nbi_md_ct));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = PTL_MD_EVENT_CT_ACK | PTL_MD_EVENT_CT_REPLY |
PTL_MD_EVENT_SUCCESS_DISABLE;
md.eq_handle = gupcr_nbi_md_eq;
md.ct_handle = gupcr_nbi_md_ct;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_nbi_md));
gupcr_nbi_md_start = md.start;
gupcr_nbi_md_count = 0;
gupcr_nb_handle_next = 1;
gupcr_nb_outstanding = 0;
} | [
"void",
"gupcr_nb_init",
"(",
"void",
")",
"{",
"ptl_md_t",
"md",
";",
"ptl_pt_index_t",
"pte",
";",
"ptl_le_t",
"le",
";",
"gupcr_log",
"(",
"FC_NB",
",",
"\"",
"\"",
")",
";",
"gupcr_portals_call",
"(",
"PtlPTAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"0",
",",
"PTL_EQ_NONE",
",",
"GUPCR_PTL_PTE_NB",
",",
"&",
"pte",
")",
")",
";",
"if",
"(",
"pte",
"!=",
"GUPCR_PTL_PTE_NB",
")",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"gupcr_debug",
"(",
"FC_NB",
",",
"\"",
"\"",
",",
"GUPCR_PTL_PTE_NB",
")",
";",
"le",
".",
"start",
"=",
"gupcr_gmem_base",
";",
"le",
".",
"length",
"=",
"gupcr_gmem_size",
";",
"le",
".",
"ct_handle",
"=",
"PTL_CT_NONE",
";",
"le",
".",
"uid",
"=",
"PTL_UID_ANY",
";",
"le",
".",
"options",
"=",
"PTL_LE_OP_PUT",
"|",
"PTL_LE_OP_GET",
";",
"gupcr_portals_call",
"(",
"PtlLEAppend",
",",
"(",
"gupcr_ptl_ni",
",",
"GUPCR_PTL_PTE_NB",
",",
"&",
"le",
",",
"PTL_PRIORITY_LIST",
",",
"NULL",
",",
"&",
"gupcr_nb_le",
")",
")",
";",
"gupcr_debug",
"(",
"FC_NB",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"gupcr_gmem_base",
",",
"(",
"long",
"unsigned",
")",
"gupcr_gmem_size",
")",
";",
"gupcr_portals_call",
"(",
"PtlEQAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"GUPCR_NB_MAX_OUTSTANDING",
",",
"&",
"gupcr_nb_md_eq",
")",
")",
";",
"md",
".",
"length",
"=",
"(",
"ptl_size_t",
")",
"USER_PROG_MEM_SIZE",
";",
"md",
".",
"start",
"=",
"(",
"void",
"*",
")",
"USER_PROG_MEM_START",
";",
"md",
".",
"options",
"=",
"PTL_MD_EVENT_SEND_DISABLE",
";",
"md",
".",
"eq_handle",
"=",
"gupcr_nb_md_eq",
";",
"md",
".",
"ct_handle",
"=",
"PTL_CT_NONE",
";",
"gupcr_portals_call",
"(",
"PtlMDBind",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"md",
",",
"&",
"gupcr_nb_md",
")",
")",
";",
"gupcr_nb_md_start",
"=",
"md",
".",
"start",
";",
"gupcr_portals_call",
"(",
"PtlEQAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"1",
",",
"&",
"gupcr_nbi_md_eq",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"gupcr_nbi_md_ct",
")",
")",
";",
"md",
".",
"length",
"=",
"(",
"ptl_size_t",
")",
"USER_PROG_MEM_SIZE",
";",
"md",
".",
"start",
"=",
"(",
"void",
"*",
")",
"USER_PROG_MEM_START",
";",
"md",
".",
"options",
"=",
"PTL_MD_EVENT_CT_ACK",
"|",
"PTL_MD_EVENT_CT_REPLY",
"|",
"PTL_MD_EVENT_SUCCESS_DISABLE",
";",
"md",
".",
"eq_handle",
"=",
"gupcr_nbi_md_eq",
";",
"md",
".",
"ct_handle",
"=",
"gupcr_nbi_md_ct",
";",
"gupcr_portals_call",
"(",
"PtlMDBind",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"md",
",",
"&",
"gupcr_nbi_md",
")",
")",
";",
"gupcr_nbi_md_start",
"=",
"md",
".",
"start",
";",
"gupcr_nbi_md_count",
"=",
"0",
";",
"gupcr_nb_handle_next",
"=",
"1",
";",
"gupcr_nb_outstanding",
"=",
"0",
";",
"}"
] | Initialize non-blocking transfer resources
@ingroup INIT | [
"Initialize",
"non",
"-",
"blocking",
"transfer",
"resources",
"@ingroup",
"INIT"
] | [
"/* Non-blocking transfers use their own PTE. */",
"/* Allocate LE for non-blocking transfers. */",
"/* Setup the Portals MD for local source/destination copying.\n We need to map the whole user's space (same as gmem). */",
"/* Non-blocking transfers with explicit handles must use full events\n there is no need for counting events. */",
"/* Non-blocking transfers with implicit handles use counting events. */",
"/* Reset number of acknowledgments. */",
"/* Initialize NB handle values. */",
"/* Initialize number of outstanding transfers. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a41f194c1a6eed4798e6710cacb3b7d9d2681c2b | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_nb_sup.c | [
"Apache-2.0"
] | C | gupcr_nb_fini | void | void
gupcr_nb_fini (void)
{
gupcr_log (FC_NB, "non-blocking transfer fini called");
/* Release explicit handle NB MD and its resources. */
gupcr_portals_call (PtlMDRelease, (gupcr_nb_md));
gupcr_portals_call (PtlEQFree, (gupcr_nb_md_eq));
/* Release implicit handle NB MD and its resources. */
gupcr_portals_call (PtlMDRelease, (gupcr_nbi_md));
gupcr_portals_call (PtlEQFree, (gupcr_nbi_md_eq));
gupcr_portals_call (PtlCTFree, (gupcr_nbi_md_ct));
/* Release LE and PTE. */
gupcr_portals_call (PtlLEUnlink, (gupcr_nb_le));
gupcr_portals_call (PtlPTFree, (gupcr_ptl_ni, GUPCR_PTL_PTE_NB));
} | /**
* Release non-blocking transfer resources
* @ingroup INIT
*/ | Release non-blocking transfer resources
@ingroup INIT | [
"Release",
"non",
"-",
"blocking",
"transfer",
"resources",
"@ingroup",
"INIT"
] | void
gupcr_nb_fini (void)
{
gupcr_log (FC_NB, "non-blocking transfer fini called");
gupcr_portals_call (PtlMDRelease, (gupcr_nb_md));
gupcr_portals_call (PtlEQFree, (gupcr_nb_md_eq));
gupcr_portals_call (PtlMDRelease, (gupcr_nbi_md));
gupcr_portals_call (PtlEQFree, (gupcr_nbi_md_eq));
gupcr_portals_call (PtlCTFree, (gupcr_nbi_md_ct));
gupcr_portals_call (PtlLEUnlink, (gupcr_nb_le));
gupcr_portals_call (PtlPTFree, (gupcr_ptl_ni, GUPCR_PTL_PTE_NB));
} | [
"void",
"gupcr_nb_fini",
"(",
"void",
")",
"{",
"gupcr_log",
"(",
"FC_NB",
",",
"\"",
"\"",
")",
";",
"gupcr_portals_call",
"(",
"PtlMDRelease",
",",
"(",
"gupcr_nb_md",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlEQFree",
",",
"(",
"gupcr_nb_md_eq",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlMDRelease",
",",
"(",
"gupcr_nbi_md",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlEQFree",
",",
"(",
"gupcr_nbi_md_eq",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTFree",
",",
"(",
"gupcr_nbi_md_ct",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlLEUnlink",
",",
"(",
"gupcr_nb_le",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlPTFree",
",",
"(",
"gupcr_ptl_ni",
",",
"GUPCR_PTL_PTE_NB",
")",
")",
";",
"}"
] | Release non-blocking transfer resources
@ingroup INIT | [
"Release",
"non",
"-",
"blocking",
"transfer",
"resources",
"@ingroup",
"INIT"
] | [
"/* Release explicit handle NB MD and its resources. */",
"/* Release implicit handle NB MD and its resources. */",
"/* Release LE and PTE. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dee0b634ddd2c4a523ae03b8d93dfc864998858d | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_barrier.c | [
"Apache-2.0"
] | C | __upc_notify | void | void
__upc_notify (int barrier_id)
{
ptl_process_t rpid __attribute ((unused));
GUPCR_OMP_CHECK();
gupcr_trace (FC_BARRIER, "BARRIER NOTIFY ENTER %d", barrier_id);
if (gupcr_barrier_active)
gupcr_error ("two successive upc_notify statements executed "
"without an intervening upc_wait");
gupcr_barrier_active = 1;
gupcr_barrier_id = barrier_id;
/* The UPC shared memory consistency model requires all outstanding
read/write operations to complete on the thread's
current synchronization phase. */
gupcr_gmem_sync ();
#if GUPCR_USE_PORTALS4_TRIGGERED_OPS
if (THREADS == 1)
return;
/* Use barrier MAX number if barrier ID is "match all"
This effectively excludes the thread from setting the min ID
among the threads. */
gupcr_barrier_value = (barrier_id == BARRIER_ANONYMOUS) ?
BARRIER_ID_MAX : barrier_id;
if (gupcr_debug_enabled (FC_BARRIER))
{
ptl_ct_event_t ct;
gupcr_portals_call (PtlCTGet, (gupcr_wait_le_ct, &ct));
gupcr_debug (FC_BARRIER, "Wait LE counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_wait_le_count);
gupcr_portals_call (PtlCTGet, (gupcr_wait_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Wait MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_wait_md_count);
gupcr_portals_call (PtlCTGet, (gupcr_notify_le_ct, &ct));
gupcr_debug (FC_BARRIER, "Notify LE counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_notify_le_count);
gupcr_portals_call (PtlCTGet, (gupcr_notify_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Notify MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_notify_md_count);
gupcr_portals_call (PtlCTGet, (gupcr_barrier_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Barrier MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_barrier_md_count);
gupcr_portals_call (PtlCTGet, (gupcr_barrier_max_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Barrier max MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_barrier_max_md_count);
}
if (LEAF_THREAD)
{
/* Send the barrier ID to the parent - use atomic PTL_MIN to allow
parent to find the minimum barrier ID among itself and its
children. */
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_portals_call (PtlAtomic, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN,
PTL_INT32_T));
}
else
{
int i;
if (ROOT_THREAD)
{
/* The consensus MIN barrier ID derived in the notify (UP) phase
must be transferred to the wait LE for delivery to all children.
Trigger: Barrier ID received in the notify phase.
Action: Send the barrier ID to the wait buffer of the
barrier DOWN LE. */
rpid.rank = MYTHREAD;
gupcr_notify_le_count += gupcr_child_cnt + 1;
gupcr_portals_call (PtlTriggeredPut, (gupcr_notify_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_notify_le_ct,
gupcr_notify_le_count));
}
else
{
/* The consensus MIN barrier ID of the inner thread and its children
is sent to the parent UPC thread.
Trigger: All children and this thread execute an atomic PTL_MIN
using each thread's UP LE.
Action: Transfer the consensus minimum barrier ID to the
this thread's parent. */
rpid.rank = gupcr_parent_thread;
gupcr_notify_le_count += gupcr_child_cnt + 1;
gupcr_portals_call (PtlTriggeredAtomic, (gupcr_notify_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
PTL_MIN, PTL_INT32_T,
gupcr_notify_le_ct,
gupcr_notify_le_count));
}
/* Trigger: Barrier ID received in the wait buffer.
Action: Reinitialize the barrier UP ID to barrier MAX value
for the next call to upc_notify. */
rpid.rank = MYTHREAD;
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlTriggeredPut, (gupcr_barrier_max_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_wait_le_ct,
gupcr_wait_le_count));
/* Trigger: The barrier ID is reinitialized to MAX.
Action: Send the consensus barrier ID to all children. */
gupcr_notify_le_count += 1;
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_portals_call (PtlTriggeredPut, (gupcr_wait_md, 0,
BARRIER_ID_SIZE,
PTL_OC_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_notify_le_ct,
gupcr_notify_le_count));
}
/* Allow notify to proceed and to possibly complete the wait
phase on other threads. */
/* Find the minimum barrier ID among children and the root. */
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, MYTHREAD);
rpid.rank = MYTHREAD;
gupcr_portals_call (PtlAtomic, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN,
PTL_INT32_T));
}
#else
/* The UPC runtime barrier implementation that does not use
Portals triggered operations does not support split phase barriers.
In this case, all Portals actions related to the barrier
are performed in the __upc_wait() function. */
#endif
gupcr_trace (FC_BARRIER, "BARRIER NOTIFY EXIT %d", barrier_id);
} | /**
* @fn __upc_notify (int barrier_id)
* UPC <i>upc_notify<i> statement implementation
*
* This procedure sets the necessary Portals triggers to implement
* the pass that derives a consensus barrier ID value across all
* UPC threads. The inner threads use Portals triggered operations
* to pass the barrier ID negotiated among itself and its children
* up the tree its parent.
* @param [in] barrier_id Barrier ID
*/ |
This procedure sets the necessary Portals triggers to implement
the pass that derives a consensus barrier ID value across all
UPC threads. The inner threads use Portals triggered operations
to pass the barrier ID negotiated among itself and its children
up the tree its parent.
@param [in] barrier_id Barrier ID | [
"This",
"procedure",
"sets",
"the",
"necessary",
"Portals",
"triggers",
"to",
"implement",
"the",
"pass",
"that",
"derives",
"a",
"consensus",
"barrier",
"ID",
"value",
"across",
"all",
"UPC",
"threads",
".",
"The",
"inner",
"threads",
"use",
"Portals",
"triggered",
"operations",
"to",
"pass",
"the",
"barrier",
"ID",
"negotiated",
"among",
"itself",
"and",
"its",
"children",
"up",
"the",
"tree",
"its",
"parent",
".",
"@param",
"[",
"in",
"]",
"barrier_id",
"Barrier",
"ID"
] | void
__upc_notify (int barrier_id)
{
ptl_process_t rpid __attribute ((unused));
GUPCR_OMP_CHECK();
gupcr_trace (FC_BARRIER, "BARRIER NOTIFY ENTER %d", barrier_id);
if (gupcr_barrier_active)
gupcr_error ("two successive upc_notify statements executed "
"without an intervening upc_wait");
gupcr_barrier_active = 1;
gupcr_barrier_id = barrier_id;
gupcr_gmem_sync ();
#if GUPCR_USE_PORTALS4_TRIGGERED_OPS
if (THREADS == 1)
return;
gupcr_barrier_value = (barrier_id == BARRIER_ANONYMOUS) ?
BARRIER_ID_MAX : barrier_id;
if (gupcr_debug_enabled (FC_BARRIER))
{
ptl_ct_event_t ct;
gupcr_portals_call (PtlCTGet, (gupcr_wait_le_ct, &ct));
gupcr_debug (FC_BARRIER, "Wait LE counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_wait_le_count);
gupcr_portals_call (PtlCTGet, (gupcr_wait_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Wait MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_wait_md_count);
gupcr_portals_call (PtlCTGet, (gupcr_notify_le_ct, &ct));
gupcr_debug (FC_BARRIER, "Notify LE counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_notify_le_count);
gupcr_portals_call (PtlCTGet, (gupcr_notify_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Notify MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_notify_md_count);
gupcr_portals_call (PtlCTGet, (gupcr_barrier_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Barrier MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_barrier_md_count);
gupcr_portals_call (PtlCTGet, (gupcr_barrier_max_md_ct, &ct));
gupcr_debug (FC_BARRIER, "Barrier max MD counter: %lu (%lu)",
(long unsigned) ct.success,
(long unsigned) gupcr_barrier_max_md_count);
}
if (LEAF_THREAD)
{
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_portals_call (PtlAtomic, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN,
PTL_INT32_T));
}
else
{
int i;
if (ROOT_THREAD)
{
rpid.rank = MYTHREAD;
gupcr_notify_le_count += gupcr_child_cnt + 1;
gupcr_portals_call (PtlTriggeredPut, (gupcr_notify_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_notify_le_ct,
gupcr_notify_le_count));
}
else
{
rpid.rank = gupcr_parent_thread;
gupcr_notify_le_count += gupcr_child_cnt + 1;
gupcr_portals_call (PtlTriggeredAtomic, (gupcr_notify_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
PTL_MIN, PTL_INT32_T,
gupcr_notify_le_ct,
gupcr_notify_le_count));
}
rpid.rank = MYTHREAD;
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlTriggeredPut, (gupcr_barrier_max_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_wait_le_ct,
gupcr_wait_le_count));
gupcr_notify_le_count += 1;
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_portals_call (PtlTriggeredPut, (gupcr_wait_md, 0,
BARRIER_ID_SIZE,
PTL_OC_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_notify_le_ct,
gupcr_notify_le_count));
}
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, MYTHREAD);
rpid.rank = MYTHREAD;
gupcr_portals_call (PtlAtomic, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN,
PTL_INT32_T));
}
#else
#endif
gupcr_trace (FC_BARRIER, "BARRIER NOTIFY EXIT %d", barrier_id);
} | [
"void",
"__upc_notify",
"(",
"int",
"barrier_id",
")",
"{",
"ptl_process_t",
"rpid",
"",
"__attribute",
"(",
"(",
"unused",
")",
")",
";",
"GUPCR_OMP_CHECK",
"(",
")",
";",
"gupcr_trace",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"barrier_id",
")",
";",
"if",
"(",
"gupcr_barrier_active",
")",
"gupcr_error",
"(",
"\"",
"\"",
"\"",
"\"",
")",
";",
"gupcr_barrier_active",
"=",
"1",
";",
"gupcr_barrier_id",
"=",
"barrier_id",
";",
"gupcr_gmem_sync",
"(",
")",
";",
"#if",
"GUPCR_USE_PORTALS4_TRIGGERED_OPS",
"\n",
"if",
"(",
"THREADS",
"==",
"1",
")",
"return",
";",
"gupcr_barrier_value",
"=",
"(",
"barrier_id",
"==",
"BARRIER_ANONYMOUS",
")",
"?",
"BARRIER_ID_MAX",
":",
"barrier_id",
";",
"if",
"(",
"gupcr_debug_enabled",
"(",
"FC_BARRIER",
")",
")",
"{",
"ptl_ct_event_t",
"ct",
";",
"gupcr_portals_call",
"(",
"PtlCTGet",
",",
"(",
"gupcr_wait_le_ct",
",",
"&",
"ct",
")",
")",
";",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
",",
"(",
"long",
"unsigned",
")",
"gupcr_wait_le_count",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTGet",
",",
"(",
"gupcr_wait_md_ct",
",",
"&",
"ct",
")",
")",
";",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
",",
"(",
"long",
"unsigned",
")",
"gupcr_wait_md_count",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTGet",
",",
"(",
"gupcr_notify_le_ct",
",",
"&",
"ct",
")",
")",
";",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
",",
"(",
"long",
"unsigned",
")",
"gupcr_notify_le_count",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTGet",
",",
"(",
"gupcr_notify_md_ct",
",",
"&",
"ct",
")",
")",
";",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
",",
"(",
"long",
"unsigned",
")",
"gupcr_notify_md_count",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTGet",
",",
"(",
"gupcr_barrier_md_ct",
",",
"&",
"ct",
")",
")",
";",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
",",
"(",
"long",
"unsigned",
")",
"gupcr_barrier_md_count",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTGet",
",",
"(",
"gupcr_barrier_max_md_ct",
",",
"&",
"ct",
")",
")",
";",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
",",
"(",
"long",
"unsigned",
")",
"gupcr_barrier_max_md_count",
")",
";",
"}",
"if",
"(",
"LEAF_THREAD",
")",
"{",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"gupcr_barrier_value",
",",
"gupcr_parent_thread",
")",
";",
"rpid",
".",
"rank",
"=",
"gupcr_parent_thread",
";",
"gupcr_portals_call",
"(",
"PtlAtomic",
",",
"(",
"gupcr_barrier_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"PTL_MIN",
",",
"PTL_INT32_T",
")",
")",
";",
"}",
"else",
"{",
"int",
"i",
";",
"if",
"(",
"ROOT_THREAD",
")",
"{",
"rpid",
".",
"rank",
"=",
"MYTHREAD",
";",
"gupcr_notify_le_count",
"+=",
"gupcr_child_cnt",
"+",
"1",
";",
"gupcr_portals_call",
"(",
"PtlTriggeredPut",
",",
"(",
"gupcr_notify_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_DOWN",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"gupcr_notify_le_ct",
",",
"gupcr_notify_le_count",
")",
")",
";",
"}",
"else",
"{",
"rpid",
".",
"rank",
"=",
"gupcr_parent_thread",
";",
"gupcr_notify_le_count",
"+=",
"gupcr_child_cnt",
"+",
"1",
";",
"gupcr_portals_call",
"(",
"PtlTriggeredAtomic",
",",
"(",
"gupcr_notify_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"PTL_MIN",
",",
"PTL_INT32_T",
",",
"gupcr_notify_le_ct",
",",
"gupcr_notify_le_count",
")",
")",
";",
"}",
"rpid",
".",
"rank",
"=",
"MYTHREAD",
";",
"gupcr_wait_le_count",
"+=",
"1",
";",
"gupcr_portals_call",
"(",
"PtlTriggeredPut",
",",
"(",
"gupcr_barrier_max_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"gupcr_wait_le_ct",
",",
"gupcr_wait_le_count",
")",
")",
";",
"gupcr_notify_le_count",
"+=",
"1",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"gupcr_child_cnt",
";",
"i",
"++",
")",
"{",
"rpid",
".",
"rank",
"=",
"gupcr_child",
"[",
"i",
"]",
";",
"gupcr_portals_call",
"(",
"PtlTriggeredPut",
",",
"(",
"gupcr_wait_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_OC_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_DOWN",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"gupcr_notify_le_ct",
",",
"gupcr_notify_le_count",
")",
")",
";",
"}",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"gupcr_barrier_value",
",",
"MYTHREAD",
")",
";",
"rpid",
".",
"rank",
"=",
"MYTHREAD",
";",
"gupcr_portals_call",
"(",
"PtlAtomic",
",",
"(",
"gupcr_barrier_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"PTL_MIN",
",",
"PTL_INT32_T",
")",
")",
";",
"}",
"#else",
"#endif",
"gupcr_trace",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"barrier_id",
")",
";",
"}"
] | @fn __upc_notify (int barrier_id)
UPC <i>upc_notify<i> statement implementation | [
"@fn",
"__upc_notify",
"(",
"int",
"barrier_id",
")",
"UPC",
"<i",
">",
"upc_notify<i",
">",
"statement",
"implementation"
] | [
"/* The UPC shared memory consistency model requires all outstanding\n read/write operations to complete on the thread's\n current synchronization phase. */",
"/* Use barrier MAX number if barrier ID is \"match all\"\n This effectively excludes the thread from setting the min ID\n among the threads. */",
"/* Send the barrier ID to the parent - use atomic PTL_MIN to allow\n parent to find the minimum barrier ID among itself and its\n children. */",
"/* The consensus MIN barrier ID derived in the notify (UP) phase\n\t must be transferred to the wait LE for delivery to all children.\n\t Trigger: Barrier ID received in the notify phase.\n\t Action: Send the barrier ID to the wait buffer of the\n\t barrier DOWN LE. */",
"/* The consensus MIN barrier ID of the inner thread and its children\n\t is sent to the parent UPC thread.\n\t Trigger: All children and this thread execute an atomic PTL_MIN\n\t using each thread's UP LE.\n\t Action: Transfer the consensus minimum barrier ID to the\n\t this thread's parent. */",
"/* Trigger: Barrier ID received in the wait buffer.\n Action: Reinitialize the barrier UP ID to barrier MAX value\n for the next call to upc_notify. */",
"/* Trigger: The barrier ID is reinitialized to MAX.\n Action: Send the consensus barrier ID to all children. */",
"/* Allow notify to proceed and to possibly complete the wait\n phase on other threads. */",
"/* Find the minimum barrier ID among children and the root. */",
"/* The UPC runtime barrier implementation that does not use\n Portals triggered operations does not support split phase barriers.\n In this case, all Portals actions related to the barrier\n are performed in the __upc_wait() function. */"
] | [
{
"param": "barrier_id",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "barrier_id",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dee0b634ddd2c4a523ae03b8d93dfc864998858d | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_barrier.c | [
"Apache-2.0"
] | C | __upc_wait | void | void
__upc_wait (int barrier_id)
{
ptl_ct_event_t ct;
ptl_process_t rpid __attribute ((unused));
int received_barrier_id;
GUPCR_OMP_CHECK();
gupcr_trace (FC_BARRIER, "BARRIER WAIT ENTER %d", barrier_id);
if (!gupcr_barrier_active)
gupcr_error ("upc_wait statement executed without a "
"preceding upc_notify");
/* Check if notify/wait barrier IDs match.
BARRIER_ANONYMOUS matches any other barrier ID. */
if ((barrier_id != BARRIER_ANONYMOUS &&
gupcr_barrier_id != BARRIER_ANONYMOUS) &&
(gupcr_barrier_id != barrier_id))
{
gupcr_error ("UPC barrier identifier mismatch - notify %d, wait %d",
gupcr_barrier_id, barrier_id);
}
if (THREADS == 1)
{
gupcr_barrier_active = 0;
return;
}
#if GUPCR_USE_PORTALS4_TRIGGERED_OPS
/* Wait for the barrier ID to propagate down the tree. */
if (gupcr_child_cnt)
{
/* Wait for the barrier ID to flow down to the children. */
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
}
else
{
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
}
received_barrier_id = *gupcr_wait_ptr;
#else
/* UPC Barrier implementation without Portals Triggered Functions. */
/* NOTIFY - Propagate minimal barrier ID to the root thread. */
/* Use the barrier maximum ID number if the barrier ID is "match all".
This effectively excludes the thread from setting the minimum ID
among the threads. */
gupcr_barrier_value = (barrier_id == BARRIER_ANONYMOUS) ?
BARRIER_ID_MAX : barrier_id;
if (!LEAF_THREAD)
{
/* This step is performed by the root thread and inner threads. */
/* Find the minimal barrier ID among the thread and children.
Use the Portals PTL_MIN atomic operation on the value
in the notify LE. */
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, MYTHREAD);
rpid.rank = MYTHREAD;
gupcr_portals_call (PtlAtomic, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN,
PTL_INT32_T));
/* Wait for all children threads to report their barrier IDs.
Account for this thread's atomic PTL_MIN. */
gupcr_notify_le_count += gupcr_child_cnt + 1;
gupcr_portals_call (PtlCTWait,
(gupcr_notify_le_ct, gupcr_notify_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_notify_le_eq);
gupcr_fatal_error ("received an error on notify LE");
}
}
if (!ROOT_THREAD)
{
ptl_handle_md_t source_md;
/* This step is performed by leaf threads and inner threads. */
/* Send the barrier ID to the parent - use atomic PTL_MIN on the value
in the parents notify LE (derived minimal ID for the parent and its
children. */
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, gupcr_parent_thread);
if (LEAF_THREAD)
source_md = gupcr_barrier_md;
else
/* An inner thread uses the minimal barrier ID
derived from the parent thread and all its children. */
source_md = gupcr_notify_md;
rpid.rank = gupcr_parent_thread;
gupcr_portals_call (PtlAtomic,
(source_md, 0, BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN, PTL_INT32_T));
}
/* At this point, the derived minimal barrier ID among all threads
has arrived at the root thread. */
if (ROOT_THREAD)
{
*(int *) gupcr_wait_ptr = gupcr_notify_value;
}
else
{
/* Wait for the parent to send the derived agreed on barrier ID. */
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
}
received_barrier_id = gupcr_notify_value;
/* An inner thread sends the derived consensus
minimum barrier ID to its children. */
if (!LEAF_THREAD)
{
int i;
/* Re-initialize the barrier ID maximum range value. */
gupcr_notify_value = BARRIER_ID_MAX;
/* Send the derived consensus minimum barrier ID to
this thread's children. */
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_portals_call (PtlPut,
(gupcr_wait_md, 0, BARRIER_ID_SIZE,
PTL_OC_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN, PTL_NO_MATCH_BITS,
0, PTL_NULL_USER_PTR, PTL_NULL_HDR_DATA));
}
/* Wait until all children receive the consensus minimum
barrier ID that is propagated down the tree. */
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
}
#endif /* GUPCR_USE_PORTALS4_TRIGGERED_OPS */
/* Verify that the barrier ID matches. */
if (barrier_id != INT_MIN &&
barrier_id != received_barrier_id &&
received_barrier_id != BARRIER_ID_MAX)
gupcr_error ("thread %d: UPC barrier identifier mismatch among threads - "
"expected %d, received %d",
MYTHREAD, barrier_id, received_barrier_id);
/* UPC Shared Memory Consistency Model requires all outstanding
read/write operations to complete on the thread's enter
into the next synchronization phase. */
gupcr_gmem_sync ();
gupcr_barrier_active = 0;
gupcr_trace (FC_BARRIER, "BARRIER WAIT EXIT %d", barrier_id);
} | /**
* @fn __upc_wait (int barrier_id)
* UPC <i>upc_wait</i> statement implementation
*
* This procedure waits to receive the derived consensus
* barrier ID from the parent (leaf thread) or acknowledges that
* all children received the consensus barrier ID (inner
* and root threads). The consensus barrier ID is checked
* against the barrier ID passed in as an argument.
* @param [in] barrier_id Barrier ID
*/ |
This procedure waits to receive the derived consensus
barrier ID from the parent (leaf thread) or acknowledges that
all children received the consensus barrier ID (inner
and root threads). The consensus barrier ID is checked
against the barrier ID passed in as an argument.
@param [in] barrier_id Barrier ID | [
"This",
"procedure",
"waits",
"to",
"receive",
"the",
"derived",
"consensus",
"barrier",
"ID",
"from",
"the",
"parent",
"(",
"leaf",
"thread",
")",
"or",
"acknowledges",
"that",
"all",
"children",
"received",
"the",
"consensus",
"barrier",
"ID",
"(",
"inner",
"and",
"root",
"threads",
")",
".",
"The",
"consensus",
"barrier",
"ID",
"is",
"checked",
"against",
"the",
"barrier",
"ID",
"passed",
"in",
"as",
"an",
"argument",
".",
"@param",
"[",
"in",
"]",
"barrier_id",
"Barrier",
"ID"
] | void
__upc_wait (int barrier_id)
{
ptl_ct_event_t ct;
ptl_process_t rpid __attribute ((unused));
int received_barrier_id;
GUPCR_OMP_CHECK();
gupcr_trace (FC_BARRIER, "BARRIER WAIT ENTER %d", barrier_id);
if (!gupcr_barrier_active)
gupcr_error ("upc_wait statement executed without a "
"preceding upc_notify");
if ((barrier_id != BARRIER_ANONYMOUS &&
gupcr_barrier_id != BARRIER_ANONYMOUS) &&
(gupcr_barrier_id != barrier_id))
{
gupcr_error ("UPC barrier identifier mismatch - notify %d, wait %d",
gupcr_barrier_id, barrier_id);
}
if (THREADS == 1)
{
gupcr_barrier_active = 0;
return;
}
#if GUPCR_USE_PORTALS4_TRIGGERED_OPS
if (gupcr_child_cnt)
{
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
}
else
{
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
}
received_barrier_id = *gupcr_wait_ptr;
#else
gupcr_barrier_value = (barrier_id == BARRIER_ANONYMOUS) ?
BARRIER_ID_MAX : barrier_id;
if (!LEAF_THREAD)
{
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, MYTHREAD);
rpid.rank = MYTHREAD;
gupcr_portals_call (PtlAtomic, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN,
PTL_INT32_T));
gupcr_notify_le_count += gupcr_child_cnt + 1;
gupcr_portals_call (PtlCTWait,
(gupcr_notify_le_ct, gupcr_notify_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_notify_le_eq);
gupcr_fatal_error ("received an error on notify LE");
}
}
if (!ROOT_THREAD)
{
ptl_handle_md_t source_md;
gupcr_debug (FC_BARRIER, "Send atomic PTL_MIN %d to (%d)",
gupcr_barrier_value, gupcr_parent_thread);
if (LEAF_THREAD)
source_md = gupcr_barrier_md;
else
source_md = gupcr_notify_md;
rpid.rank = gupcr_parent_thread;
gupcr_portals_call (PtlAtomic,
(source_md, 0, BARRIER_ID_SIZE, PTL_NO_ACK_REQ,
rpid, GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA, PTL_MIN, PTL_INT32_T));
}
if (ROOT_THREAD)
{
*(int *) gupcr_wait_ptr = gupcr_notify_value;
}
else
{
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
}
received_barrier_id = gupcr_notify_value;
if (!LEAF_THREAD)
{
int i;
gupcr_notify_value = BARRIER_ID_MAX;
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_portals_call (PtlPut,
(gupcr_wait_md, 0, BARRIER_ID_SIZE,
PTL_OC_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN, PTL_NO_MATCH_BITS,
0, PTL_NULL_USER_PTR, PTL_NULL_HDR_DATA));
}
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
}
#endif
if (barrier_id != INT_MIN &&
barrier_id != received_barrier_id &&
received_barrier_id != BARRIER_ID_MAX)
gupcr_error ("thread %d: UPC barrier identifier mismatch among threads - "
"expected %d, received %d",
MYTHREAD, barrier_id, received_barrier_id);
gupcr_gmem_sync ();
gupcr_barrier_active = 0;
gupcr_trace (FC_BARRIER, "BARRIER WAIT EXIT %d", barrier_id);
} | [
"void",
"__upc_wait",
"(",
"int",
"barrier_id",
")",
"{",
"ptl_ct_event_t",
"ct",
";",
"ptl_process_t",
"rpid",
"",
"__attribute",
"(",
"(",
"unused",
")",
")",
";",
"int",
"received_barrier_id",
";",
"GUPCR_OMP_CHECK",
"(",
")",
";",
"gupcr_trace",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"barrier_id",
")",
";",
"if",
"(",
"!",
"gupcr_barrier_active",
")",
"gupcr_error",
"(",
"\"",
"\"",
"\"",
"\"",
")",
";",
"if",
"(",
"(",
"barrier_id",
"!=",
"BARRIER_ANONYMOUS",
"&&",
"gupcr_barrier_id",
"!=",
"BARRIER_ANONYMOUS",
")",
"&&",
"(",
"gupcr_barrier_id",
"!=",
"barrier_id",
")",
")",
"{",
"gupcr_error",
"(",
"\"",
"\"",
",",
"gupcr_barrier_id",
",",
"barrier_id",
")",
";",
"}",
"if",
"(",
"THREADS",
"==",
"1",
")",
"{",
"gupcr_barrier_active",
"=",
"0",
";",
"return",
";",
"}",
"#if",
"GUPCR_USE_PORTALS4_TRIGGERED_OPS",
"\n",
"if",
"(",
"gupcr_child_cnt",
")",
"{",
"gupcr_wait_md_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_md_ct",
",",
"gupcr_wait_md_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_md_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"else",
"{",
"gupcr_wait_le_count",
"+=",
"1",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_le_ct",
",",
"gupcr_wait_le_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_le_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"received_barrier_id",
"=",
"*",
"gupcr_wait_ptr",
";",
"#else",
"gupcr_barrier_value",
"=",
"(",
"barrier_id",
"==",
"BARRIER_ANONYMOUS",
")",
"?",
"BARRIER_ID_MAX",
":",
"barrier_id",
";",
"if",
"(",
"!",
"LEAF_THREAD",
")",
"{",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"gupcr_barrier_value",
",",
"MYTHREAD",
")",
";",
"rpid",
".",
"rank",
"=",
"MYTHREAD",
";",
"gupcr_portals_call",
"(",
"PtlAtomic",
",",
"(",
"gupcr_barrier_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"PTL_MIN",
",",
"PTL_INT32_T",
")",
")",
";",
"gupcr_notify_le_count",
"+=",
"gupcr_child_cnt",
"+",
"1",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_notify_le_ct",
",",
"gupcr_notify_le_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_notify_le_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"ROOT_THREAD",
")",
"{",
"ptl_handle_md_t",
"source_md",
";",
"gupcr_debug",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"gupcr_barrier_value",
",",
"gupcr_parent_thread",
")",
";",
"if",
"(",
"LEAF_THREAD",
")",
"source_md",
"=",
"gupcr_barrier_md",
";",
"else",
"source_md",
"=",
"gupcr_notify_md",
";",
"rpid",
".",
"rank",
"=",
"gupcr_parent_thread",
";",
"gupcr_portals_call",
"(",
"PtlAtomic",
",",
"(",
"source_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"PTL_MIN",
",",
"PTL_INT32_T",
")",
")",
";",
"}",
"if",
"(",
"ROOT_THREAD",
")",
"{",
"*",
"(",
"int",
"*",
")",
"gupcr_wait_ptr",
"=",
"gupcr_notify_value",
";",
"}",
"else",
"{",
"gupcr_wait_le_count",
"+=",
"1",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_le_ct",
",",
"gupcr_wait_le_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_le_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"received_barrier_id",
"=",
"gupcr_notify_value",
";",
"if",
"(",
"!",
"LEAF_THREAD",
")",
"{",
"int",
"i",
";",
"gupcr_notify_value",
"=",
"BARRIER_ID_MAX",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"gupcr_child_cnt",
";",
"i",
"++",
")",
"{",
"rpid",
".",
"rank",
"=",
"gupcr_child",
"[",
"i",
"]",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"gupcr_wait_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_OC_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_DOWN",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"}",
"gupcr_wait_md_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_md_ct",
",",
"gupcr_wait_md_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_md_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"#endif",
"if",
"(",
"barrier_id",
"!=",
"INT_MIN",
"&&",
"barrier_id",
"!=",
"received_barrier_id",
"&&",
"received_barrier_id",
"!=",
"BARRIER_ID_MAX",
")",
"gupcr_error",
"(",
"\"",
"\"",
"\"",
"\"",
",",
"MYTHREAD",
",",
"barrier_id",
",",
"received_barrier_id",
")",
";",
"gupcr_gmem_sync",
"(",
")",
";",
"gupcr_barrier_active",
"=",
"0",
";",
"gupcr_trace",
"(",
"FC_BARRIER",
",",
"\"",
"\"",
",",
"barrier_id",
")",
";",
"}"
] | @fn __upc_wait (int barrier_id)
UPC <i>upc_wait</i> statement implementation | [
"@fn",
"__upc_wait",
"(",
"int",
"barrier_id",
")",
"UPC",
"<i",
">",
"upc_wait<",
"/",
"i",
">",
"statement",
"implementation"
] | [
"/* Check if notify/wait barrier IDs match.\n BARRIER_ANONYMOUS matches any other barrier ID. */",
"/* Wait for the barrier ID to propagate down the tree. */",
"/* Wait for the barrier ID to flow down to the children. */",
"/* UPC Barrier implementation without Portals Triggered Functions. */",
"/* NOTIFY - Propagate minimal barrier ID to the root thread. */",
"/* Use the barrier maximum ID number if the barrier ID is \"match all\".\n This effectively excludes the thread from setting the minimum ID\n among the threads. */",
"/* This step is performed by the root thread and inner threads. */",
"/* Find the minimal barrier ID among the thread and children.\n Use the Portals PTL_MIN atomic operation on the value\n\t in the notify LE. */",
"/* Wait for all children threads to report their barrier IDs.\n Account for this thread's atomic PTL_MIN. */",
"/* This step is performed by leaf threads and inner threads. */",
"/* Send the barrier ID to the parent - use atomic PTL_MIN on the value\n in the parents notify LE (derived minimal ID for the parent and its\n children. */",
"/* An inner thread uses the minimal barrier ID\n\t derived from the parent thread and all its children. */",
"/* At this point, the derived minimal barrier ID among all threads\n has arrived at the root thread. */",
"/* Wait for the parent to send the derived agreed on barrier ID. */",
"/* An inner thread sends the derived consensus\n minimum barrier ID to its children. */",
"/* Re-initialize the barrier ID maximum range value. */",
"/* Send the derived consensus minimum barrier ID to\n this thread's children. */",
"/* Wait until all children receive the consensus minimum\n barrier ID that is propagated down the tree. */",
"/* GUPCR_USE_PORTALS4_TRIGGERED_OPS */",
"/* Verify that the barrier ID matches. */",
"/* UPC Shared Memory Consistency Model requires all outstanding\n read/write operations to complete on the thread's enter\n into the next synchronization phase. */"
] | [
{
"param": "barrier_id",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "barrier_id",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dee0b634ddd2c4a523ae03b8d93dfc864998858d | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_barrier.c | [
"Apache-2.0"
] | C | gupcr_bcast_send | void | void
gupcr_bcast_send (void *value, size_t nbytes)
{
int i;
ptl_process_t rpid;
ptl_ct_event_t ct;
gupcr_trace (FC_BROADCAST, "BROADCAST SEND ENTER 0x%lx %lu",
(long unsigned) value, (long unsigned) nbytes);
/* This broadcast operation is implemented a collective operation.
Before proceeding, complete all outstanding shared memory
read/write operations. */
gupcr_gmem_sync ();
/* Copy the message into the buffer used for delivery
to the children threads. */
memcpy (gupcr_wait_ptr, value, nbytes);
gupcr_notify_le_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_notify_le_ct, gupcr_notify_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_notify_le_eq);
gupcr_fatal_error ("received an error on notify LE");
}
/* Send broadcast to this thread's children. */
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_debug (FC_BROADCAST, "Send broadcast message to child (%d)",
gupcr_child[i]);
gupcr_portals_call (PtlPut, (gupcr_wait_md, 0,
nbytes, PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
}
/* Wait for message delivery to all children. This ensures that
the source buffer is not overwritten by back-to-back
broadcast operations. */
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
gupcr_trace (FC_BROADCAST, "BROADCAST SEND EXIT");
} | /**
* @fn gupcr_bcast_send (void *value, size_t nbytes)
* Send broadcast message to all thread's children.
*
* The broadcast is a collective operation where thread 0 (root thread)
* sends a message to all other threads. This function must be
* called by the thread 0 only from a public function
* "gupcr_broadcast_put".
*
* @param [in] value Pointer to send value
* @param [in] nbytes Number of bytes to send
* @ingroup BROADCAST
*/ | @fn gupcr_bcast_send (void *value, size_t nbytes)
Send broadcast message to all thread's children.
The broadcast is a collective operation where thread 0 (root thread)
sends a message to all other threads. This function must be
called by the thread 0 only from a public function
"gupcr_broadcast_put".
@param [in] value Pointer to send value
@param [in] nbytes Number of bytes to send
@ingroup BROADCAST | [
"@fn",
"gupcr_bcast_send",
"(",
"void",
"*",
"value",
"size_t",
"nbytes",
")",
"Send",
"broadcast",
"message",
"to",
"all",
"thread",
"'",
"s",
"children",
".",
"The",
"broadcast",
"is",
"a",
"collective",
"operation",
"where",
"thread",
"0",
"(",
"root",
"thread",
")",
"sends",
"a",
"message",
"to",
"all",
"other",
"threads",
".",
"This",
"function",
"must",
"be",
"called",
"by",
"the",
"thread",
"0",
"only",
"from",
"a",
"public",
"function",
"\"",
"gupcr_broadcast_put",
"\"",
".",
"@param",
"[",
"in",
"]",
"value",
"Pointer",
"to",
"send",
"value",
"@param",
"[",
"in",
"]",
"nbytes",
"Number",
"of",
"bytes",
"to",
"send",
"@ingroup",
"BROADCAST"
] | void
gupcr_bcast_send (void *value, size_t nbytes)
{
int i;
ptl_process_t rpid;
ptl_ct_event_t ct;
gupcr_trace (FC_BROADCAST, "BROADCAST SEND ENTER 0x%lx %lu",
(long unsigned) value, (long unsigned) nbytes);
gupcr_gmem_sync ();
memcpy (gupcr_wait_ptr, value, nbytes);
gupcr_notify_le_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_notify_le_ct, gupcr_notify_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_notify_le_eq);
gupcr_fatal_error ("received an error on notify LE");
}
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_debug (FC_BROADCAST, "Send broadcast message to child (%d)",
gupcr_child[i]);
gupcr_portals_call (PtlPut, (gupcr_wait_md, 0,
nbytes, PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
}
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
gupcr_trace (FC_BROADCAST, "BROADCAST SEND EXIT");
} | [
"void",
"gupcr_bcast_send",
"(",
"void",
"*",
"value",
",",
"size_t",
"nbytes",
")",
"{",
"int",
"i",
";",
"ptl_process_t",
"rpid",
";",
"ptl_ct_event_t",
"ct",
";",
"gupcr_trace",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"value",
",",
"(",
"long",
"unsigned",
")",
"nbytes",
")",
";",
"gupcr_gmem_sync",
"(",
")",
";",
"memcpy",
"(",
"gupcr_wait_ptr",
",",
"value",
",",
"nbytes",
")",
";",
"gupcr_notify_le_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_notify_le_ct",
",",
"gupcr_notify_le_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_notify_le_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"gupcr_child_cnt",
";",
"i",
"++",
")",
"{",
"rpid",
".",
"rank",
"=",
"gupcr_child",
"[",
"i",
"]",
";",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"gupcr_child",
"[",
"i",
"]",
")",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"gupcr_wait_md",
",",
"0",
",",
"nbytes",
",",
"PTL_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_DOWN",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"}",
"gupcr_wait_md_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_md_ct",
",",
"gupcr_wait_md_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_md_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"gupcr_trace",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
")",
";",
"}"
] | @fn gupcr_bcast_send (void *value, size_t nbytes)
Send broadcast message to all thread's children. | [
"@fn",
"gupcr_bcast_send",
"(",
"void",
"*",
"value",
"size_t",
"nbytes",
")",
"Send",
"broadcast",
"message",
"to",
"all",
"thread",
"'",
"s",
"children",
"."
] | [
"/* This broadcast operation is implemented a collective operation.\n Before proceeding, complete all outstanding shared memory\n read/write operations. */",
"/* Copy the message into the buffer used for delivery\n to the children threads. */",
"/* Send broadcast to this thread's children. */",
"/* Wait for message delivery to all children. This ensures that\n the source buffer is not overwritten by back-to-back\n broadcast operations. */"
] | [
{
"param": "value",
"type": "void"
},
{
"param": "nbytes",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nbytes",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dee0b634ddd2c4a523ae03b8d93dfc864998858d | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_barrier.c | [
"Apache-2.0"
] | C | gupcr_bcast_recv | void | void
gupcr_bcast_recv (void *value, size_t nbytes)
{
int i;
ptl_process_t rpid;
ptl_ct_event_t ct;
gupcr_trace (FC_BROADCAST, "BROADCAST RECV ENTER 0x%lx %lu",
(long unsigned) value, (long unsigned) nbytes);
gupcr_gmem_sync ();
#if GUPCR_USE_PORTALS4_TRIGGERED_OPS
if (INNER_THREAD)
{
/* Prepare triggers for message push to all children. */
gupcr_wait_le_count += 1;
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_debug (FC_BROADCAST,
"Set broadcast trigger to the child (%d)",
gupcr_child[i]);
/* Trigger: message received from the parent.
Action: send the message to the child. */
gupcr_portals_call (PtlTriggeredPut, (gupcr_wait_md, 0,
nbytes, PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_wait_le_ct,
gupcr_wait_le_count));
}
/* Prepare a trigger to send notification to the parent. */
gupcr_debug (FC_BROADCAST,
"Set notification trigger to the parent (%d)",
gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_barrier_value = BARRIER_ID_MAX;
/* Trigger: notification received from all children.
Action: send notification to the parent. */
gupcr_notify_le_count += gupcr_child_cnt;
gupcr_portals_call (PtlTriggeredPut, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_notify_le_ct,
gupcr_notify_le_count));
/* Wait for delivery to all children. */
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
gupcr_debug (FC_BROADCAST, "Received PtlPut acks: %lu",
(long unsigned) ct.success);
}
else
{
/* A leaf thread sends notification to its parent that
it is ready to receive the broadcast value. */
gupcr_debug (FC_BROADCAST, "Send notification to the parent (%d)",
gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_barrier_value = BARRIER_ID_MAX;
gupcr_portals_call (PtlPut, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
/* Wait to receive a message from the parent. */
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
}
memcpy (value, gupcr_wait_ptr, nbytes);
#else
/* Inner threads must wait for its children threads to arrive. */
if (INNER_THREAD)
{
gupcr_debug (FC_BROADCAST, "Waiting for %d notifications",
gupcr_child_cnt);
gupcr_notify_le_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_notify_le_ct, gupcr_child_cnt, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_notify_le_eq);
gupcr_fatal_error ("received an error on notify LE");
}
gupcr_debug (FC_BROADCAST, "Received %lu broadcast notifications",
(long unsigned) ct.success);
}
/* Inform the parent that this thread and all its children arrived.
Send barrier MAX value as we share PTEs with the barrier
implementation. */
gupcr_debug (FC_BROADCAST, "Send notification to the parent %d",
gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_barrier_value = BARRIER_ID_MAX;
gupcr_portals_call (PtlPut, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP, PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR, PTL_NULL_HDR_DATA));
/* Receive the broadcast message from the parent. */
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
/* Copy the received message. */
memcpy (value, gupcr_wait_ptr, nbytes);
if (INNER_THREAD)
{
/* An inner thread must pass the message to its children. */
for (i = 0; i < gupcr_child_cnt; i++)
{
gupcr_debug (FC_BROADCAST, "Sending a message to %d",
gupcr_child[i]);
rpid.rank = gupcr_child[i];
gupcr_portals_call (PtlPut, (gupcr_wait_md, 0,
nbytes, PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR, PTL_NULL_HDR_DATA));
}
/* Wait for delivery to all children. */
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait, (gupcr_wait_md_ct, gupcr_wait_md_count,
&ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
}
#endif
gupcr_trace (FC_BROADCAST, "BROADCAST RECV EXIT");
} | /**
* @fn gupcr_bcast_recv (void *value, size_t nbytes)
* Wait to receive the broadcast message and return its value.
*
* Broadcast is a collective operation where thread 0 (the root thread)
* sends a message to all other threads. This function must be
* called by every thread other then thread 0.
*
* @param [in] value Pointer to received value
* @param [in] nbytes Number of bytes to receive
* @ingroup BROADCAST
*/ | @fn gupcr_bcast_recv (void *value, size_t nbytes)
Wait to receive the broadcast message and return its value.
Broadcast is a collective operation where thread 0 (the root thread)
sends a message to all other threads. This function must be
called by every thread other then thread 0.
@param [in] value Pointer to received value
@param [in] nbytes Number of bytes to receive
@ingroup BROADCAST | [
"@fn",
"gupcr_bcast_recv",
"(",
"void",
"*",
"value",
"size_t",
"nbytes",
")",
"Wait",
"to",
"receive",
"the",
"broadcast",
"message",
"and",
"return",
"its",
"value",
".",
"Broadcast",
"is",
"a",
"collective",
"operation",
"where",
"thread",
"0",
"(",
"the",
"root",
"thread",
")",
"sends",
"a",
"message",
"to",
"all",
"other",
"threads",
".",
"This",
"function",
"must",
"be",
"called",
"by",
"every",
"thread",
"other",
"then",
"thread",
"0",
".",
"@param",
"[",
"in",
"]",
"value",
"Pointer",
"to",
"received",
"value",
"@param",
"[",
"in",
"]",
"nbytes",
"Number",
"of",
"bytes",
"to",
"receive",
"@ingroup",
"BROADCAST"
] | void
gupcr_bcast_recv (void *value, size_t nbytes)
{
int i;
ptl_process_t rpid;
ptl_ct_event_t ct;
gupcr_trace (FC_BROADCAST, "BROADCAST RECV ENTER 0x%lx %lu",
(long unsigned) value, (long unsigned) nbytes);
gupcr_gmem_sync ();
#if GUPCR_USE_PORTALS4_TRIGGERED_OPS
if (INNER_THREAD)
{
gupcr_wait_le_count += 1;
for (i = 0; i < gupcr_child_cnt; i++)
{
rpid.rank = gupcr_child[i];
gupcr_debug (FC_BROADCAST,
"Set broadcast trigger to the child (%d)",
gupcr_child[i]);
gupcr_portals_call (PtlTriggeredPut, (gupcr_wait_md, 0,
nbytes, PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_wait_le_ct,
gupcr_wait_le_count));
}
gupcr_debug (FC_BROADCAST,
"Set notification trigger to the parent (%d)",
gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_barrier_value = BARRIER_ID_MAX;
gupcr_notify_le_count += gupcr_child_cnt;
gupcr_portals_call (PtlTriggeredPut, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE,
PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA,
gupcr_notify_le_ct,
gupcr_notify_le_count));
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_md_ct, gupcr_wait_md_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
gupcr_debug (FC_BROADCAST, "Received PtlPut acks: %lu",
(long unsigned) ct.success);
}
else
{
gupcr_debug (FC_BROADCAST, "Send notification to the parent (%d)",
gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_barrier_value = BARRIER_ID_MAX;
gupcr_portals_call (PtlPut, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP,
PTL_NO_MATCH_BITS, 0, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
}
memcpy (value, gupcr_wait_ptr, nbytes);
#else
if (INNER_THREAD)
{
gupcr_debug (FC_BROADCAST, "Waiting for %d notifications",
gupcr_child_cnt);
gupcr_notify_le_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait,
(gupcr_notify_le_ct, gupcr_child_cnt, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_notify_le_eq);
gupcr_fatal_error ("received an error on notify LE");
}
gupcr_debug (FC_BROADCAST, "Received %lu broadcast notifications",
(long unsigned) ct.success);
}
gupcr_debug (FC_BROADCAST, "Send notification to the parent %d",
gupcr_parent_thread);
rpid.rank = gupcr_parent_thread;
gupcr_barrier_value = BARRIER_ID_MAX;
gupcr_portals_call (PtlPut, (gupcr_barrier_md, 0,
BARRIER_ID_SIZE, PTL_NO_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_UP, PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR, PTL_NULL_HDR_DATA));
gupcr_wait_le_count += 1;
gupcr_portals_call (PtlCTWait,
(gupcr_wait_le_ct, gupcr_wait_le_count, &ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_le_eq);
gupcr_fatal_error ("received an error on wait LE");
}
memcpy (value, gupcr_wait_ptr, nbytes);
if (INNER_THREAD)
{
for (i = 0; i < gupcr_child_cnt; i++)
{
gupcr_debug (FC_BROADCAST, "Sending a message to %d",
gupcr_child[i]);
rpid.rank = gupcr_child[i];
gupcr_portals_call (PtlPut, (gupcr_wait_md, 0,
nbytes, PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_BARRIER_DOWN,
PTL_NO_MATCH_BITS, 0,
PTL_NULL_USER_PTR, PTL_NULL_HDR_DATA));
}
gupcr_wait_md_count += gupcr_child_cnt;
gupcr_portals_call (PtlCTWait, (gupcr_wait_md_ct, gupcr_wait_md_count,
&ct));
if (ct.failure)
{
gupcr_process_fail_events (gupcr_wait_md_eq);
gupcr_fatal_error ("received an error on wait MD");
}
}
#endif
gupcr_trace (FC_BROADCAST, "BROADCAST RECV EXIT");
} | [
"void",
"gupcr_bcast_recv",
"(",
"void",
"*",
"value",
",",
"size_t",
"nbytes",
")",
"{",
"int",
"i",
";",
"ptl_process_t",
"rpid",
";",
"ptl_ct_event_t",
"ct",
";",
"gupcr_trace",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"value",
",",
"(",
"long",
"unsigned",
")",
"nbytes",
")",
";",
"gupcr_gmem_sync",
"(",
")",
";",
"#if",
"GUPCR_USE_PORTALS4_TRIGGERED_OPS",
"\n",
"if",
"(",
"INNER_THREAD",
")",
"{",
"gupcr_wait_le_count",
"+=",
"1",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"gupcr_child_cnt",
";",
"i",
"++",
")",
"{",
"rpid",
".",
"rank",
"=",
"gupcr_child",
"[",
"i",
"]",
";",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"gupcr_child",
"[",
"i",
"]",
")",
";",
"gupcr_portals_call",
"(",
"PtlTriggeredPut",
",",
"(",
"gupcr_wait_md",
",",
"0",
",",
"nbytes",
",",
"PTL_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_DOWN",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"gupcr_wait_le_ct",
",",
"gupcr_wait_le_count",
")",
")",
";",
"}",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"gupcr_parent_thread",
")",
";",
"rpid",
".",
"rank",
"=",
"gupcr_parent_thread",
";",
"gupcr_barrier_value",
"=",
"BARRIER_ID_MAX",
";",
"gupcr_notify_le_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlTriggeredPut",
",",
"(",
"gupcr_barrier_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
",",
"gupcr_notify_le_ct",
",",
"gupcr_notify_le_count",
")",
")",
";",
"gupcr_wait_md_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_md_ct",
",",
"gupcr_wait_md_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_md_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
")",
";",
"}",
"else",
"{",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"gupcr_parent_thread",
")",
";",
"rpid",
".",
"rank",
"=",
"gupcr_parent_thread",
";",
"gupcr_barrier_value",
"=",
"BARRIER_ID_MAX",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"gupcr_barrier_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"gupcr_wait_le_count",
"+=",
"1",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_le_ct",
",",
"gupcr_wait_le_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_le_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"memcpy",
"(",
"value",
",",
"gupcr_wait_ptr",
",",
"nbytes",
")",
";",
"#else",
"if",
"(",
"INNER_THREAD",
")",
"{",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"gupcr_child_cnt",
")",
";",
"gupcr_notify_le_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_notify_le_ct",
",",
"gupcr_child_cnt",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_notify_le_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"ct",
".",
"success",
")",
";",
"}",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"gupcr_parent_thread",
")",
";",
"rpid",
".",
"rank",
"=",
"gupcr_parent_thread",
";",
"gupcr_barrier_value",
"=",
"BARRIER_ID_MAX",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"gupcr_barrier_md",
",",
"0",
",",
"BARRIER_ID_SIZE",
",",
"PTL_NO_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_UP",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"gupcr_wait_le_count",
"+=",
"1",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_le_ct",
",",
"gupcr_wait_le_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_le_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"memcpy",
"(",
"value",
",",
"gupcr_wait_ptr",
",",
"nbytes",
")",
";",
"if",
"(",
"INNER_THREAD",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"gupcr_child_cnt",
";",
"i",
"++",
")",
"{",
"gupcr_debug",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
",",
"gupcr_child",
"[",
"i",
"]",
")",
";",
"rpid",
".",
"rank",
"=",
"gupcr_child",
"[",
"i",
"]",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"gupcr_wait_md",
",",
"0",
",",
"nbytes",
",",
"PTL_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_BARRIER_DOWN",
",",
"PTL_NO_MATCH_BITS",
",",
"0",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"}",
"gupcr_wait_md_count",
"+=",
"gupcr_child_cnt",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_wait_md_ct",
",",
"gupcr_wait_md_count",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_wait_md_eq",
")",
";",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"#endif",
"gupcr_trace",
"(",
"FC_BROADCAST",
",",
"\"",
"\"",
")",
";",
"}"
] | @fn gupcr_bcast_recv (void *value, size_t nbytes)
Wait to receive the broadcast message and return its value. | [
"@fn",
"gupcr_bcast_recv",
"(",
"void",
"*",
"value",
"size_t",
"nbytes",
")",
"Wait",
"to",
"receive",
"the",
"broadcast",
"message",
"and",
"return",
"its",
"value",
"."
] | [
"/* Prepare triggers for message push to all children. */",
"/* Trigger: message received from the parent.\n\t Action: send the message to the child. */",
"/* Prepare a trigger to send notification to the parent. */",
"/* Trigger: notification received from all children.\n Action: send notification to the parent. */",
"/* Wait for delivery to all children. */",
"/* A leaf thread sends notification to its parent that\n it is ready to receive the broadcast value. */",
"/* Wait to receive a message from the parent. */",
"/* Inner threads must wait for its children threads to arrive. */",
"/* Inform the parent that this thread and all its children arrived.\n Send barrier MAX value as we share PTEs with the barrier\n implementation. */",
"/* Receive the broadcast message from the parent. */",
"/* Copy the received message. */",
"/* An inner thread must pass the message to its children. */",
"/* Wait for delivery to all children. */"
] | [
{
"param": "value",
"type": "void"
},
{
"param": "nbytes",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nbytes",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dece33aa1623b34910f1bc58cb92a6732ec433d4 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_atomic_sup.c | [
"Apache-2.0"
] | C | gupcr_atomic_init | void | void
gupcr_atomic_init (void)
{
ptl_md_t md;
gupcr_log (FC_ATOMIC, "atomic init called");
/* Setup the Portals MD for local source/destination copying.
We need to map the whole user's space (same as gmem). */
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_atomic_md_ct));
gupcr_portals_call (PtlEQAlloc, (gupcr_ptl_ni, 1, &gupcr_atomic_md_eq));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = PTL_MD_EVENT_CT_ACK | PTL_MD_EVENT_CT_REPLY |
PTL_MD_EVENT_SUCCESS_DISABLE;
md.eq_handle = gupcr_atomic_md_eq;
md.ct_handle = gupcr_atomic_md_ct;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_atomic_md));
/* Reset number of acknowledgments. */
gupcr_atomic_md_count = 0;
} | /**
* Initialize atomics resources.
* @ingroup INIT
*/ | Initialize atomics resources.
@ingroup INIT | [
"Initialize",
"atomics",
"resources",
".",
"@ingroup",
"INIT"
] | void
gupcr_atomic_init (void)
{
ptl_md_t md;
gupcr_log (FC_ATOMIC, "atomic init called");
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_atomic_md_ct));
gupcr_portals_call (PtlEQAlloc, (gupcr_ptl_ni, 1, &gupcr_atomic_md_eq));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = PTL_MD_EVENT_CT_ACK | PTL_MD_EVENT_CT_REPLY |
PTL_MD_EVENT_SUCCESS_DISABLE;
md.eq_handle = gupcr_atomic_md_eq;
md.ct_handle = gupcr_atomic_md_ct;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_atomic_md));
gupcr_atomic_md_count = 0;
} | [
"void",
"gupcr_atomic_init",
"(",
"void",
")",
"{",
"ptl_md_t",
"md",
";",
"gupcr_log",
"(",
"FC_ATOMIC",
",",
"\"",
"\"",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"gupcr_atomic_md_ct",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlEQAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"1",
",",
"&",
"gupcr_atomic_md_eq",
")",
")",
";",
"md",
".",
"length",
"=",
"(",
"ptl_size_t",
")",
"USER_PROG_MEM_SIZE",
";",
"md",
".",
"start",
"=",
"(",
"void",
"*",
")",
"USER_PROG_MEM_START",
";",
"md",
".",
"options",
"=",
"PTL_MD_EVENT_CT_ACK",
"|",
"PTL_MD_EVENT_CT_REPLY",
"|",
"PTL_MD_EVENT_SUCCESS_DISABLE",
";",
"md",
".",
"eq_handle",
"=",
"gupcr_atomic_md_eq",
";",
"md",
".",
"ct_handle",
"=",
"gupcr_atomic_md_ct",
";",
"gupcr_portals_call",
"(",
"PtlMDBind",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"md",
",",
"&",
"gupcr_atomic_md",
")",
")",
";",
"gupcr_atomic_md_count",
"=",
"0",
";",
"}"
] | Initialize atomics resources. | [
"Initialize",
"atomics",
"resources",
"."
] | [
"/* Setup the Portals MD for local source/destination copying.\n We need to map the whole user's space (same as gmem). */",
"/* Reset number of acknowledgments. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dece33aa1623b34910f1bc58cb92a6732ec433d4 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_atomic_sup.c | [
"Apache-2.0"
] | C | gupcr_atomic_fini | void | void
gupcr_atomic_fini (void)
{
gupcr_log (FC_ATOMIC, "atomic fini called");
/* Release atomic MD and its resources. */
gupcr_portals_call (PtlMDRelease, (gupcr_atomic_md));
gupcr_portals_call (PtlCTFree, (gupcr_atomic_md_ct));
gupcr_portals_call (PtlEQFree, (gupcr_atomic_md_eq));
} | /**
* Release atomics resources.
* @ingroup INIT
*/ | Release atomics resources.
@ingroup INIT | [
"Release",
"atomics",
"resources",
".",
"@ingroup",
"INIT"
] | void
gupcr_atomic_fini (void)
{
gupcr_log (FC_ATOMIC, "atomic fini called");
gupcr_portals_call (PtlMDRelease, (gupcr_atomic_md));
gupcr_portals_call (PtlCTFree, (gupcr_atomic_md_ct));
gupcr_portals_call (PtlEQFree, (gupcr_atomic_md_eq));
} | [
"void",
"gupcr_atomic_fini",
"(",
"void",
")",
"{",
"gupcr_log",
"(",
"FC_ATOMIC",
",",
"\"",
"\"",
")",
";",
"gupcr_portals_call",
"(",
"PtlMDRelease",
",",
"(",
"gupcr_atomic_md",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTFree",
",",
"(",
"gupcr_atomic_md_ct",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlEQFree",
",",
"(",
"gupcr_atomic_md_eq",
")",
")",
";",
"}"
] | Release atomics resources. | [
"Release",
"atomics",
"resources",
"."
] | [
"/* Release atomic MD and its resources. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_alloc_shared | void | static void
gupcr_gmem_alloc_shared (void)
{
size_t heap_size = GUPCR_ROUND (gupcr_get_shared_heap_size (), C64K);
size_t data_size = GUPCR_ROUND (GUPCR_SHARED_SECTION_END -
GUPCR_SHARED_SECTION_START, C64K);
gupcr_gmem_heap_base_offset = data_size;
gupcr_gmem_heap_size = heap_size;
gupcr_gmem_size = heap_size + data_size;
/* Allocate this thread's shared space. */
gupcr_gmem_base = gupcr_node_local_alloc (gupcr_gmem_size);
} | /**
* Allocate memory for this thread's shared space contribution.
*
* Calculate needed memory size and let the node allocate
* shared memory and map other thread's shared memory into
* the current thread memory space.
*/ | Allocate memory for this thread's shared space contribution.
Calculate needed memory size and let the node allocate
shared memory and map other thread's shared memory into
the current thread memory space. | [
"Allocate",
"memory",
"for",
"this",
"thread",
"'",
"s",
"shared",
"space",
"contribution",
".",
"Calculate",
"needed",
"memory",
"size",
"and",
"let",
"the",
"node",
"allocate",
"shared",
"memory",
"and",
"map",
"other",
"thread",
"'",
"s",
"shared",
"memory",
"into",
"the",
"current",
"thread",
"memory",
"space",
"."
] | static void
gupcr_gmem_alloc_shared (void)
{
size_t heap_size = GUPCR_ROUND (gupcr_get_shared_heap_size (), C64K);
size_t data_size = GUPCR_ROUND (GUPCR_SHARED_SECTION_END -
GUPCR_SHARED_SECTION_START, C64K);
gupcr_gmem_heap_base_offset = data_size;
gupcr_gmem_heap_size = heap_size;
gupcr_gmem_size = heap_size + data_size;
gupcr_gmem_base = gupcr_node_local_alloc (gupcr_gmem_size);
} | [
"static",
"void",
"gupcr_gmem_alloc_shared",
"(",
"void",
")",
"{",
"size_t",
"heap_size",
"=",
"GUPCR_ROUND",
"(",
"gupcr_get_shared_heap_size",
"(",
")",
",",
"C64K",
")",
";",
"size_t",
"data_size",
"=",
"GUPCR_ROUND",
"(",
"GUPCR_SHARED_SECTION_END",
"-",
"GUPCR_SHARED_SECTION_START",
",",
"C64K",
")",
";",
"gupcr_gmem_heap_base_offset",
"=",
"data_size",
";",
"gupcr_gmem_heap_size",
"=",
"heap_size",
";",
"gupcr_gmem_size",
"=",
"heap_size",
"+",
"data_size",
";",
"gupcr_gmem_base",
"=",
"gupcr_node_local_alloc",
"(",
"gupcr_gmem_size",
")",
";",
"}"
] | Allocate memory for this thread's shared space contribution. | [
"Allocate",
"memory",
"for",
"this",
"thread",
"'",
"s",
"shared",
"space",
"contribution",
"."
] | [
"/* Allocate this thread's shared space. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_sync_gets | void | void
gupcr_gmem_sync_gets (void)
{
/* Sync all outstanding local accesses. */
GUPCR_MEM_BARRIER ();
/* Sync all outstanding remote get accesses. */
if (gupcr_gmem_gets.num_pending > 0)
{
ptl_size_t num_initiated =
gupcr_gmem_gets.num_completed + gupcr_gmem_gets.num_pending;
ptl_ct_event_t ct;
gupcr_debug (FC_MEM, "outstanding gets: %lu",
(long unsigned) gupcr_gmem_gets.num_pending);
gupcr_portals_call (PtlCTWait,
(gupcr_gmem_gets.ct_handle, num_initiated, &ct));
gupcr_gmem_gets.num_pending = 0;
gupcr_gmem_gets.num_completed = num_initiated;
if (ct.failure > 0)
{
gupcr_process_fail_events (gupcr_gmem_gets.eq_handle);
gupcr_abort ();
}
}
} | /**
* Complete all outstanding remote GET operations.
*
* This procedure waits for all outstanding GET operations
* to complete. If the wait on the Portals GET counting event returns
* a failure, a full event queue is checked for failure specifics
* and the program aborts.
*/ | Complete all outstanding remote GET operations.
This procedure waits for all outstanding GET operations
to complete. If the wait on the Portals GET counting event returns
a failure, a full event queue is checked for failure specifics
and the program aborts. | [
"Complete",
"all",
"outstanding",
"remote",
"GET",
"operations",
".",
"This",
"procedure",
"waits",
"for",
"all",
"outstanding",
"GET",
"operations",
"to",
"complete",
".",
"If",
"the",
"wait",
"on",
"the",
"Portals",
"GET",
"counting",
"event",
"returns",
"a",
"failure",
"a",
"full",
"event",
"queue",
"is",
"checked",
"for",
"failure",
"specifics",
"and",
"the",
"program",
"aborts",
"."
] | void
gupcr_gmem_sync_gets (void)
{
GUPCR_MEM_BARRIER ();
if (gupcr_gmem_gets.num_pending > 0)
{
ptl_size_t num_initiated =
gupcr_gmem_gets.num_completed + gupcr_gmem_gets.num_pending;
ptl_ct_event_t ct;
gupcr_debug (FC_MEM, "outstanding gets: %lu",
(long unsigned) gupcr_gmem_gets.num_pending);
gupcr_portals_call (PtlCTWait,
(gupcr_gmem_gets.ct_handle, num_initiated, &ct));
gupcr_gmem_gets.num_pending = 0;
gupcr_gmem_gets.num_completed = num_initiated;
if (ct.failure > 0)
{
gupcr_process_fail_events (gupcr_gmem_gets.eq_handle);
gupcr_abort ();
}
}
} | [
"void",
"gupcr_gmem_sync_gets",
"(",
"void",
")",
"{",
"GUPCR_MEM_BARRIER",
"(",
")",
";",
"if",
"(",
"gupcr_gmem_gets",
".",
"num_pending",
">",
"0",
")",
"{",
"ptl_size_t",
"num_initiated",
"=",
"gupcr_gmem_gets",
".",
"num_completed",
"+",
"gupcr_gmem_gets",
".",
"num_pending",
";",
"ptl_ct_event_t",
"ct",
";",
"gupcr_debug",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"gupcr_gmem_gets",
".",
"num_pending",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_gmem_gets",
".",
"ct_handle",
",",
"num_initiated",
",",
"&",
"ct",
")",
")",
";",
"gupcr_gmem_gets",
".",
"num_pending",
"=",
"0",
";",
"gupcr_gmem_gets",
".",
"num_completed",
"=",
"num_initiated",
";",
"if",
"(",
"ct",
".",
"failure",
">",
"0",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_gmem_gets",
".",
"eq_handle",
")",
";",
"gupcr_abort",
"(",
")",
";",
"}",
"}",
"}"
] | Complete all outstanding remote GET operations. | [
"Complete",
"all",
"outstanding",
"remote",
"GET",
"operations",
"."
] | [
"/* Sync all outstanding local accesses. */",
"/* Sync all outstanding remote get accesses. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_sync_puts | void | void
gupcr_gmem_sync_puts (void)
{
/* Sync all outstanding local accesses. */
GUPCR_MEM_BARRIER ();
/* Sync all outstanding remote put accesses. */
if (gupcr_gmem_puts.num_pending > 0)
{
ptl_size_t num_initiated =
gupcr_gmem_puts.num_completed + gupcr_gmem_puts.num_pending;
ptl_ct_event_t ct;
gupcr_debug (FC_MEM, "outstanding puts: %lu",
(long unsigned) gupcr_gmem_puts.num_pending);
gupcr_portals_call (PtlCTWait,
(gupcr_gmem_puts.ct_handle, num_initiated, &ct));
gupcr_gmem_puts.num_pending = 0;
gupcr_gmem_puts.num_completed = num_initiated;
gupcr_pending_strict_put = 0;
gupcr_gmem_put_bb_used = 0;
if (ct.failure > 0)
{
gupcr_process_fail_events (gupcr_gmem_puts.eq_handle);
gupcr_abort ();
}
}
} | /**
* Complete outstanding remote PUT operations.
*
* This procedure waits for all outstanding PUT operations
* to complete. If the wait on the Portals PUT counting event returns
* a failure, a full event queue is checked for failure specifics
* and the program aborts.
*/ | Complete outstanding remote PUT operations.
This procedure waits for all outstanding PUT operations
to complete. If the wait on the Portals PUT counting event returns
a failure, a full event queue is checked for failure specifics
and the program aborts. | [
"Complete",
"outstanding",
"remote",
"PUT",
"operations",
".",
"This",
"procedure",
"waits",
"for",
"all",
"outstanding",
"PUT",
"operations",
"to",
"complete",
".",
"If",
"the",
"wait",
"on",
"the",
"Portals",
"PUT",
"counting",
"event",
"returns",
"a",
"failure",
"a",
"full",
"event",
"queue",
"is",
"checked",
"for",
"failure",
"specifics",
"and",
"the",
"program",
"aborts",
"."
] | void
gupcr_gmem_sync_puts (void)
{
GUPCR_MEM_BARRIER ();
if (gupcr_gmem_puts.num_pending > 0)
{
ptl_size_t num_initiated =
gupcr_gmem_puts.num_completed + gupcr_gmem_puts.num_pending;
ptl_ct_event_t ct;
gupcr_debug (FC_MEM, "outstanding puts: %lu",
(long unsigned) gupcr_gmem_puts.num_pending);
gupcr_portals_call (PtlCTWait,
(gupcr_gmem_puts.ct_handle, num_initiated, &ct));
gupcr_gmem_puts.num_pending = 0;
gupcr_gmem_puts.num_completed = num_initiated;
gupcr_pending_strict_put = 0;
gupcr_gmem_put_bb_used = 0;
if (ct.failure > 0)
{
gupcr_process_fail_events (gupcr_gmem_puts.eq_handle);
gupcr_abort ();
}
}
} | [
"void",
"gupcr_gmem_sync_puts",
"(",
"void",
")",
"{",
"GUPCR_MEM_BARRIER",
"(",
")",
";",
"if",
"(",
"gupcr_gmem_puts",
".",
"num_pending",
">",
"0",
")",
"{",
"ptl_size_t",
"num_initiated",
"=",
"gupcr_gmem_puts",
".",
"num_completed",
"+",
"gupcr_gmem_puts",
".",
"num_pending",
";",
"ptl_ct_event_t",
"ct",
";",
"gupcr_debug",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"gupcr_gmem_puts",
".",
"num_pending",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_gmem_puts",
".",
"ct_handle",
",",
"num_initiated",
",",
"&",
"ct",
")",
")",
";",
"gupcr_gmem_puts",
".",
"num_pending",
"=",
"0",
";",
"gupcr_gmem_puts",
".",
"num_completed",
"=",
"num_initiated",
";",
"gupcr_pending_strict_put",
"=",
"0",
";",
"gupcr_gmem_put_bb_used",
"=",
"0",
";",
"if",
"(",
"ct",
".",
"failure",
">",
"0",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_gmem_puts",
".",
"eq_handle",
")",
";",
"gupcr_abort",
"(",
")",
";",
"}",
"}",
"}"
] | Complete outstanding remote PUT operations. | [
"Complete",
"outstanding",
"remote",
"PUT",
"operations",
"."
] | [
"/* Sync all outstanding local accesses. */",
"/* Sync all outstanding remote put accesses. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_sync | void | void
gupcr_gmem_sync (void)
{
gupcr_gmem_sync_gets ();
gupcr_gmem_sync_puts ();
} | /**
* Complete all outstanding remote operations.
*
* Check and wait for completion of all PUT/GET operations.
*/ | Complete all outstanding remote operations.
Check and wait for completion of all PUT/GET operations. | [
"Complete",
"all",
"outstanding",
"remote",
"operations",
".",
"Check",
"and",
"wait",
"for",
"completion",
"of",
"all",
"PUT",
"/",
"GET",
"operations",
"."
] | void
gupcr_gmem_sync (void)
{
gupcr_gmem_sync_gets ();
gupcr_gmem_sync_puts ();
} | [
"void",
"gupcr_gmem_sync",
"(",
"void",
")",
"{",
"gupcr_gmem_sync_gets",
"(",
")",
";",
"gupcr_gmem_sync_puts",
"(",
")",
";",
"}"
] | Complete all outstanding remote operations. | [
"Complete",
"all",
"outstanding",
"remote",
"operations",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_get | void | void
gupcr_gmem_get (void *dest, int thread, size_t offset, size_t n)
{
ptl_process_t rpid;
char *dest_addr = (char *)dest - (size_t) USER_PROG_MEM_START;
size_t rem_offset = offset;
size_t n_rem = n;
gupcr_debug (FC_MEM, "%d:0x%lx 0x%lx",
thread, (long unsigned) offset, (long unsigned) dest);
rpid.rank = thread;
while (n_rem > 0)
{
size_t n_xfer;
n_xfer = GUPCR_MIN (n_rem, (size_t) GUPCR_MAX_MSG_SIZE);
++gupcr_gmem_gets.num_pending;
gupcr_portals_call (PtlGet, (gupcr_gmem_gets.md,
(ptl_size_t) dest_addr, n_xfer, rpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
rem_offset, PTL_NULL_USER_PTR));
n_rem -= n_xfer;
dest_addr += n_xfer;
rem_offset += n_xfer;
}
} | /**
* Read data from remote shared memory.
*
* A GET request is broken into multiple PtlGet() requests
* if the number of requested bytes is greater then
* the configuration limited maximum message size.
*
* @param [in] dest Local memory to receive remote data
* @param [in] thread Remote thread to request data from
* @param [in] offset Remote address
* @param [in] n Number of bytes to transfer
*/ | Read data from remote shared memory.
A GET request is broken into multiple PtlGet() requests
if the number of requested bytes is greater then
the configuration limited maximum message size.
@param [in] dest Local memory to receive remote data
@param [in] thread Remote thread to request data from
@param [in] offset Remote address
@param [in] n Number of bytes to transfer | [
"Read",
"data",
"from",
"remote",
"shared",
"memory",
".",
"A",
"GET",
"request",
"is",
"broken",
"into",
"multiple",
"PtlGet",
"()",
"requests",
"if",
"the",
"number",
"of",
"requested",
"bytes",
"is",
"greater",
"then",
"the",
"configuration",
"limited",
"maximum",
"message",
"size",
".",
"@param",
"[",
"in",
"]",
"dest",
"Local",
"memory",
"to",
"receive",
"remote",
"data",
"@param",
"[",
"in",
"]",
"thread",
"Remote",
"thread",
"to",
"request",
"data",
"from",
"@param",
"[",
"in",
"]",
"offset",
"Remote",
"address",
"@param",
"[",
"in",
"]",
"n",
"Number",
"of",
"bytes",
"to",
"transfer"
] | void
gupcr_gmem_get (void *dest, int thread, size_t offset, size_t n)
{
ptl_process_t rpid;
char *dest_addr = (char *)dest - (size_t) USER_PROG_MEM_START;
size_t rem_offset = offset;
size_t n_rem = n;
gupcr_debug (FC_MEM, "%d:0x%lx 0x%lx",
thread, (long unsigned) offset, (long unsigned) dest);
rpid.rank = thread;
while (n_rem > 0)
{
size_t n_xfer;
n_xfer = GUPCR_MIN (n_rem, (size_t) GUPCR_MAX_MSG_SIZE);
++gupcr_gmem_gets.num_pending;
gupcr_portals_call (PtlGet, (gupcr_gmem_gets.md,
(ptl_size_t) dest_addr, n_xfer, rpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
rem_offset, PTL_NULL_USER_PTR));
n_rem -= n_xfer;
dest_addr += n_xfer;
rem_offset += n_xfer;
}
} | [
"void",
"gupcr_gmem_get",
"(",
"void",
"*",
"dest",
",",
"int",
"thread",
",",
"size_t",
"offset",
",",
"size_t",
"n",
")",
"{",
"ptl_process_t",
"rpid",
";",
"char",
"*",
"dest_addr",
"=",
"(",
"char",
"*",
")",
"dest",
"-",
"(",
"size_t",
")",
"USER_PROG_MEM_START",
";",
"size_t",
"rem_offset",
"=",
"offset",
";",
"size_t",
"n_rem",
"=",
"n",
";",
"gupcr_debug",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"thread",
",",
"(",
"long",
"unsigned",
")",
"offset",
",",
"(",
"long",
"unsigned",
")",
"dest",
")",
";",
"rpid",
".",
"rank",
"=",
"thread",
";",
"while",
"(",
"n_rem",
">",
"0",
")",
"{",
"size_t",
"n_xfer",
";",
"n_xfer",
"=",
"GUPCR_MIN",
"(",
"n_rem",
",",
"(",
"size_t",
")",
"GUPCR_MAX_MSG_SIZE",
")",
";",
"++",
"gupcr_gmem_gets",
".",
"num_pending",
";",
"gupcr_portals_call",
"(",
"PtlGet",
",",
"(",
"gupcr_gmem_gets",
".",
"md",
",",
"(",
"ptl_size_t",
")",
"dest_addr",
",",
"n_xfer",
",",
"rpid",
",",
"GUPCR_PTL_PTE_GMEM",
",",
"PTL_NO_MATCH_BITS",
",",
"rem_offset",
",",
"PTL_NULL_USER_PTR",
")",
")",
";",
"n_rem",
"-=",
"n_xfer",
";",
"dest_addr",
"+=",
"n_xfer",
";",
"rem_offset",
"+=",
"n_xfer",
";",
"}",
"}"
] | Read data from remote shared memory. | [
"Read",
"data",
"from",
"remote",
"shared",
"memory",
"."
] | [] | [
{
"param": "dest",
"type": "void"
},
{
"param": "thread",
"type": "int"
},
{
"param": "offset",
"type": "size_t"
},
{
"param": "n",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dest",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "thread",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_put | void | void
gupcr_gmem_put (int thread, size_t offset, const void *src, size_t n)
{
int must_sync = (n > GUPCR_GMEM_MAX_SAFE_PUT_SIZE);
char *src_addr = (char *) src;
size_t n_rem = n;
ptl_process_t rpid;
gupcr_debug (FC_MEM, "0x%lx %d:0x%lx",
(long unsigned) src, thread, (long unsigned) offset);
rpid.rank = thread;
/* Large puts must be synchronous, to ensure that it is
safe to re-use the source buffer upon return. */
while (n_rem > 0)
{
size_t n_xfer;
ptl_handle_md_t md_handle;
ptl_size_t local_offset;
n_xfer = GUPCR_MIN (n_rem, (size_t) GUPCR_MAX_MSG_SIZE);
if (must_sync)
{
local_offset = src_addr - (char *) USER_PROG_MEM_START;
md_handle = gupcr_gmem_puts.md;
}
else if (n_rem <= GUPCR_MAX_VOLATILE_SIZE)
{
local_offset = src_addr - (char *) USER_PROG_MEM_START;
md_handle = gupcr_gmem_puts.md_volatile;
}
else
{
char *bounce_buf;
/* If this transfer will overflow the bounce buffer,
then first wait for all outstanding puts to complete. */
if ((gupcr_gmem_put_bb_used + n_xfer) > GUPCR_BOUNCE_BUFFER_SIZE)
gupcr_gmem_sync_puts ();
bounce_buf = &gupcr_gmem_put_bb[gupcr_gmem_put_bb_used];
memcpy (bounce_buf, src_addr, n_xfer);
local_offset = bounce_buf - gupcr_gmem_put_bb;
gupcr_gmem_put_bb_used += n_xfer;
md_handle = gupcr_gmem_put_bb_md;
}
++gupcr_gmem_puts.num_pending;
gupcr_portals_call (PtlPut, (md_handle, local_offset, n_xfer,
PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
offset, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
n_rem -= n_xfer;
src_addr += n_xfer;
if (gupcr_gmem_puts.num_pending == gupcr_gmem_high_mark_puts)
{
ptl_ct_event_t ct;
size_t complete_cnt;
size_t wait_cnt = gupcr_gmem_puts.num_completed
+ gupcr_gmem_puts.num_pending
- gupcr_gmem_low_mark_puts;
gupcr_portals_call (PtlCTWait,
(gupcr_gmem_puts.ct_handle, wait_cnt, &ct));
if (ct.failure > 0)
{
gupcr_process_fail_events (gupcr_gmem_puts.eq_handle);
gupcr_abort ();
}
complete_cnt = ct.success - gupcr_gmem_puts.num_completed;
gupcr_gmem_puts.num_pending -= complete_cnt;
gupcr_gmem_puts.num_completed = ct.success;
}
}
if (must_sync)
gupcr_gmem_sync_puts ();
} | /**
* Write data to remote shared memory.
*
* For data requests smaller then maximum safe size, the data is first
* copied into a bounce buffer. In this way, the put operation
* can be non-blocking and there are no restrictions placed upon
* the caller's use of the source data buffer.
* Otherwise, a synchronous operation is performed
* and this function returns to the caller after the operation completes.
*
* @param [in] thread Destination thread
* @param [in] offset Destination offset
* @param [in] src Local source pointer to data
* @param [in] n Number of bytes to transfer
*/ | Write data to remote shared memory.
For data requests smaller then maximum safe size, the data is first
copied into a bounce buffer. In this way, the put operation
can be non-blocking and there are no restrictions placed upon
the caller's use of the source data buffer.
Otherwise, a synchronous operation is performed
and this function returns to the caller after the operation completes.
@param [in] thread Destination thread
@param [in] offset Destination offset
@param [in] src Local source pointer to data
@param [in] n Number of bytes to transfer | [
"Write",
"data",
"to",
"remote",
"shared",
"memory",
".",
"For",
"data",
"requests",
"smaller",
"then",
"maximum",
"safe",
"size",
"the",
"data",
"is",
"first",
"copied",
"into",
"a",
"bounce",
"buffer",
".",
"In",
"this",
"way",
"the",
"put",
"operation",
"can",
"be",
"non",
"-",
"blocking",
"and",
"there",
"are",
"no",
"restrictions",
"placed",
"upon",
"the",
"caller",
"'",
"s",
"use",
"of",
"the",
"source",
"data",
"buffer",
".",
"Otherwise",
"a",
"synchronous",
"operation",
"is",
"performed",
"and",
"this",
"function",
"returns",
"to",
"the",
"caller",
"after",
"the",
"operation",
"completes",
".",
"@param",
"[",
"in",
"]",
"thread",
"Destination",
"thread",
"@param",
"[",
"in",
"]",
"offset",
"Destination",
"offset",
"@param",
"[",
"in",
"]",
"src",
"Local",
"source",
"pointer",
"to",
"data",
"@param",
"[",
"in",
"]",
"n",
"Number",
"of",
"bytes",
"to",
"transfer"
] | void
gupcr_gmem_put (int thread, size_t offset, const void *src, size_t n)
{
int must_sync = (n > GUPCR_GMEM_MAX_SAFE_PUT_SIZE);
char *src_addr = (char *) src;
size_t n_rem = n;
ptl_process_t rpid;
gupcr_debug (FC_MEM, "0x%lx %d:0x%lx",
(long unsigned) src, thread, (long unsigned) offset);
rpid.rank = thread;
while (n_rem > 0)
{
size_t n_xfer;
ptl_handle_md_t md_handle;
ptl_size_t local_offset;
n_xfer = GUPCR_MIN (n_rem, (size_t) GUPCR_MAX_MSG_SIZE);
if (must_sync)
{
local_offset = src_addr - (char *) USER_PROG_MEM_START;
md_handle = gupcr_gmem_puts.md;
}
else if (n_rem <= GUPCR_MAX_VOLATILE_SIZE)
{
local_offset = src_addr - (char *) USER_PROG_MEM_START;
md_handle = gupcr_gmem_puts.md_volatile;
}
else
{
char *bounce_buf;
if ((gupcr_gmem_put_bb_used + n_xfer) > GUPCR_BOUNCE_BUFFER_SIZE)
gupcr_gmem_sync_puts ();
bounce_buf = &gupcr_gmem_put_bb[gupcr_gmem_put_bb_used];
memcpy (bounce_buf, src_addr, n_xfer);
local_offset = bounce_buf - gupcr_gmem_put_bb;
gupcr_gmem_put_bb_used += n_xfer;
md_handle = gupcr_gmem_put_bb_md;
}
++gupcr_gmem_puts.num_pending;
gupcr_portals_call (PtlPut, (md_handle, local_offset, n_xfer,
PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
offset, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
n_rem -= n_xfer;
src_addr += n_xfer;
if (gupcr_gmem_puts.num_pending == gupcr_gmem_high_mark_puts)
{
ptl_ct_event_t ct;
size_t complete_cnt;
size_t wait_cnt = gupcr_gmem_puts.num_completed
+ gupcr_gmem_puts.num_pending
- gupcr_gmem_low_mark_puts;
gupcr_portals_call (PtlCTWait,
(gupcr_gmem_puts.ct_handle, wait_cnt, &ct));
if (ct.failure > 0)
{
gupcr_process_fail_events (gupcr_gmem_puts.eq_handle);
gupcr_abort ();
}
complete_cnt = ct.success - gupcr_gmem_puts.num_completed;
gupcr_gmem_puts.num_pending -= complete_cnt;
gupcr_gmem_puts.num_completed = ct.success;
}
}
if (must_sync)
gupcr_gmem_sync_puts ();
} | [
"void",
"gupcr_gmem_put",
"(",
"int",
"thread",
",",
"size_t",
"offset",
",",
"const",
"void",
"*",
"src",
",",
"size_t",
"n",
")",
"{",
"int",
"must_sync",
"=",
"(",
"n",
">",
"GUPCR_GMEM_MAX_SAFE_PUT_SIZE",
")",
";",
"char",
"*",
"src_addr",
"=",
"(",
"char",
"*",
")",
"src",
";",
"size_t",
"n_rem",
"=",
"n",
";",
"ptl_process_t",
"rpid",
";",
"gupcr_debug",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"src",
",",
"thread",
",",
"(",
"long",
"unsigned",
")",
"offset",
")",
";",
"rpid",
".",
"rank",
"=",
"thread",
";",
"while",
"(",
"n_rem",
">",
"0",
")",
"{",
"size_t",
"n_xfer",
";",
"ptl_handle_md_t",
"md_handle",
";",
"ptl_size_t",
"local_offset",
";",
"n_xfer",
"=",
"GUPCR_MIN",
"(",
"n_rem",
",",
"(",
"size_t",
")",
"GUPCR_MAX_MSG_SIZE",
")",
";",
"if",
"(",
"must_sync",
")",
"{",
"local_offset",
"=",
"src_addr",
"-",
"(",
"char",
"*",
")",
"USER_PROG_MEM_START",
";",
"md_handle",
"=",
"gupcr_gmem_puts",
".",
"md",
";",
"}",
"else",
"if",
"(",
"n_rem",
"<=",
"GUPCR_MAX_VOLATILE_SIZE",
")",
"{",
"local_offset",
"=",
"src_addr",
"-",
"(",
"char",
"*",
")",
"USER_PROG_MEM_START",
";",
"md_handle",
"=",
"gupcr_gmem_puts",
".",
"md_volatile",
";",
"}",
"else",
"{",
"char",
"*",
"bounce_buf",
";",
"if",
"(",
"(",
"gupcr_gmem_put_bb_used",
"+",
"n_xfer",
")",
">",
"GUPCR_BOUNCE_BUFFER_SIZE",
")",
"gupcr_gmem_sync_puts",
"(",
")",
";",
"bounce_buf",
"=",
"&",
"gupcr_gmem_put_bb",
"[",
"gupcr_gmem_put_bb_used",
"]",
";",
"memcpy",
"(",
"bounce_buf",
",",
"src_addr",
",",
"n_xfer",
")",
";",
"local_offset",
"=",
"bounce_buf",
"-",
"gupcr_gmem_put_bb",
";",
"gupcr_gmem_put_bb_used",
"+=",
"n_xfer",
";",
"md_handle",
"=",
"gupcr_gmem_put_bb_md",
";",
"}",
"++",
"gupcr_gmem_puts",
".",
"num_pending",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"md_handle",
",",
"local_offset",
",",
"n_xfer",
",",
"PTL_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_GMEM",
",",
"PTL_NO_MATCH_BITS",
",",
"offset",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"n_rem",
"-=",
"n_xfer",
";",
"src_addr",
"+=",
"n_xfer",
";",
"if",
"(",
"gupcr_gmem_puts",
".",
"num_pending",
"==",
"gupcr_gmem_high_mark_puts",
")",
"{",
"ptl_ct_event_t",
"ct",
";",
"size_t",
"complete_cnt",
";",
"size_t",
"wait_cnt",
"=",
"gupcr_gmem_puts",
".",
"num_completed",
"+",
"gupcr_gmem_puts",
".",
"num_pending",
"-",
"gupcr_gmem_low_mark_puts",
";",
"gupcr_portals_call",
"(",
"PtlCTWait",
",",
"(",
"gupcr_gmem_puts",
".",
"ct_handle",
",",
"wait_cnt",
",",
"&",
"ct",
")",
")",
";",
"if",
"(",
"ct",
".",
"failure",
">",
"0",
")",
"{",
"gupcr_process_fail_events",
"(",
"gupcr_gmem_puts",
".",
"eq_handle",
")",
";",
"gupcr_abort",
"(",
")",
";",
"}",
"complete_cnt",
"=",
"ct",
".",
"success",
"-",
"gupcr_gmem_puts",
".",
"num_completed",
";",
"gupcr_gmem_puts",
".",
"num_pending",
"-=",
"complete_cnt",
";",
"gupcr_gmem_puts",
".",
"num_completed",
"=",
"ct",
".",
"success",
";",
"}",
"}",
"if",
"(",
"must_sync",
")",
"gupcr_gmem_sync_puts",
"(",
")",
";",
"}"
] | Write data to remote shared memory. | [
"Write",
"data",
"to",
"remote",
"shared",
"memory",
"."
] | [
"/* Large puts must be synchronous, to ensure that it is\n safe to re-use the source buffer upon return. */",
"/* If this transfer will overflow the bounce buffer,\n\t then first wait for all outstanding puts to complete. */"
] | [
{
"param": "thread",
"type": "int"
},
{
"param": "offset",
"type": "size_t"
},
{
"param": "src",
"type": "void"
},
{
"param": "n",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "thread",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_copy | void | void
gupcr_gmem_copy (int dthread, size_t doffset,
int sthread, size_t soffset, size_t n)
{
size_t n_rem = n;
ptl_size_t dest_addr = doffset;
ptl_size_t src_addr = soffset;
ptl_process_t dpid;
gupcr_debug (FC_MEM, "%d:0x%lx %d:0x%lx %lu",
sthread, (long unsigned) soffset,
dthread, (long unsigned) doffset,
(long unsigned) n);
dpid.rank = dthread;
while (n_rem > 0)
{
size_t n_xfer;
char *bounce_buf;
ptl_size_t local_offset;
/* Use the entire put "bounce buffer" if the transfer
count is sufficiently large. */
n_xfer = GUPCR_MIN (n_rem, GUPCR_BOUNCE_BUFFER_SIZE);
if ((gupcr_gmem_put_bb_used + n_xfer) > GUPCR_BOUNCE_BUFFER_SIZE)
gupcr_gmem_sync_puts ();
bounce_buf = &gupcr_gmem_put_bb[gupcr_gmem_put_bb_used];
gupcr_gmem_put_bb_used += n_xfer;
/* Read the source data into the bounce buffer. */
gupcr_gmem_get (bounce_buf, sthread, src_addr, n_xfer);
gupcr_gmem_sync_gets ();
local_offset = bounce_buf - gupcr_gmem_put_bb;
++gupcr_gmem_puts.num_pending;
gupcr_portals_call (PtlPut, (gupcr_gmem_put_bb_md, local_offset, n_xfer,
PTL_ACK_REQ, dpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
dest_addr, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
n_rem -= n_xfer;
src_addr += n_xfer;
dest_addr += n_xfer;
}
} | /**
* Copy remote shared memory from the source thread
* to the destination thread.
*
* Bulk copy from one thread to another.
* The put bounce buffer is used as an intermediate buffer.
* Caller assumes responsibility for checking the validity
* of the remote thread id's and/or shared memory offsets.
*
* @param [in] dthread Destination thread
* @param [in] doffset Destination offset
* @param [in] sthread Source thread
* @param [in] soffset Source offset
* @param [in] n Number of bytes to transfer
*/ | Copy remote shared memory from the source thread
to the destination thread.
Bulk copy from one thread to another.
The put bounce buffer is used as an intermediate buffer.
Caller assumes responsibility for checking the validity
of the remote thread id's and/or shared memory offsets.
| [
"Copy",
"remote",
"shared",
"memory",
"from",
"the",
"source",
"thread",
"to",
"the",
"destination",
"thread",
".",
"Bulk",
"copy",
"from",
"one",
"thread",
"to",
"another",
".",
"The",
"put",
"bounce",
"buffer",
"is",
"used",
"as",
"an",
"intermediate",
"buffer",
".",
"Caller",
"assumes",
"responsibility",
"for",
"checking",
"the",
"validity",
"of",
"the",
"remote",
"thread",
"id",
"'",
"s",
"and",
"/",
"or",
"shared",
"memory",
"offsets",
"."
] | void
gupcr_gmem_copy (int dthread, size_t doffset,
int sthread, size_t soffset, size_t n)
{
size_t n_rem = n;
ptl_size_t dest_addr = doffset;
ptl_size_t src_addr = soffset;
ptl_process_t dpid;
gupcr_debug (FC_MEM, "%d:0x%lx %d:0x%lx %lu",
sthread, (long unsigned) soffset,
dthread, (long unsigned) doffset,
(long unsigned) n);
dpid.rank = dthread;
while (n_rem > 0)
{
size_t n_xfer;
char *bounce_buf;
ptl_size_t local_offset;
n_xfer = GUPCR_MIN (n_rem, GUPCR_BOUNCE_BUFFER_SIZE);
if ((gupcr_gmem_put_bb_used + n_xfer) > GUPCR_BOUNCE_BUFFER_SIZE)
gupcr_gmem_sync_puts ();
bounce_buf = &gupcr_gmem_put_bb[gupcr_gmem_put_bb_used];
gupcr_gmem_put_bb_used += n_xfer;
gupcr_gmem_get (bounce_buf, sthread, src_addr, n_xfer);
gupcr_gmem_sync_gets ();
local_offset = bounce_buf - gupcr_gmem_put_bb;
++gupcr_gmem_puts.num_pending;
gupcr_portals_call (PtlPut, (gupcr_gmem_put_bb_md, local_offset, n_xfer,
PTL_ACK_REQ, dpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
dest_addr, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
n_rem -= n_xfer;
src_addr += n_xfer;
dest_addr += n_xfer;
}
} | [
"void",
"gupcr_gmem_copy",
"(",
"int",
"dthread",
",",
"size_t",
"doffset",
",",
"int",
"sthread",
",",
"size_t",
"soffset",
",",
"size_t",
"n",
")",
"{",
"size_t",
"n_rem",
"=",
"n",
";",
"ptl_size_t",
"dest_addr",
"=",
"doffset",
";",
"ptl_size_t",
"src_addr",
"=",
"soffset",
";",
"ptl_process_t",
"dpid",
";",
"gupcr_debug",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"sthread",
",",
"(",
"long",
"unsigned",
")",
"soffset",
",",
"dthread",
",",
"(",
"long",
"unsigned",
")",
"doffset",
",",
"(",
"long",
"unsigned",
")",
"n",
")",
";",
"dpid",
".",
"rank",
"=",
"dthread",
";",
"while",
"(",
"n_rem",
">",
"0",
")",
"{",
"size_t",
"n_xfer",
";",
"char",
"*",
"bounce_buf",
";",
"ptl_size_t",
"local_offset",
";",
"n_xfer",
"=",
"GUPCR_MIN",
"(",
"n_rem",
",",
"GUPCR_BOUNCE_BUFFER_SIZE",
")",
";",
"if",
"(",
"(",
"gupcr_gmem_put_bb_used",
"+",
"n_xfer",
")",
">",
"GUPCR_BOUNCE_BUFFER_SIZE",
")",
"gupcr_gmem_sync_puts",
"(",
")",
";",
"bounce_buf",
"=",
"&",
"gupcr_gmem_put_bb",
"[",
"gupcr_gmem_put_bb_used",
"]",
";",
"gupcr_gmem_put_bb_used",
"+=",
"n_xfer",
";",
"gupcr_gmem_get",
"(",
"bounce_buf",
",",
"sthread",
",",
"src_addr",
",",
"n_xfer",
")",
";",
"gupcr_gmem_sync_gets",
"(",
")",
";",
"local_offset",
"=",
"bounce_buf",
"-",
"gupcr_gmem_put_bb",
";",
"++",
"gupcr_gmem_puts",
".",
"num_pending",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"gupcr_gmem_put_bb_md",
",",
"local_offset",
",",
"n_xfer",
",",
"PTL_ACK_REQ",
",",
"dpid",
",",
"GUPCR_PTL_PTE_GMEM",
",",
"PTL_NO_MATCH_BITS",
",",
"dest_addr",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"n_rem",
"-=",
"n_xfer",
";",
"src_addr",
"+=",
"n_xfer",
";",
"dest_addr",
"+=",
"n_xfer",
";",
"}",
"}"
] | Copy remote shared memory from the source thread
to the destination thread. | [
"Copy",
"remote",
"shared",
"memory",
"from",
"the",
"source",
"thread",
"to",
"the",
"destination",
"thread",
"."
] | [
"/* Use the entire put \"bounce buffer\" if the transfer\n count is sufficiently large. */",
"/* Read the source data into the bounce buffer. */"
] | [
{
"param": "dthread",
"type": "int"
},
{
"param": "doffset",
"type": "size_t"
},
{
"param": "sthread",
"type": "int"
},
{
"param": "soffset",
"type": "size_t"
},
{
"param": "n",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dthread",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "doffset",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sthread",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "soffset",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_set | void | void
gupcr_gmem_set (int thread, size_t offset, int c, size_t n)
{
size_t n_rem = n;
int already_filled = 0;
ptl_size_t dest_addr = offset;
ptl_process_t rpid;
gupcr_debug (FC_MEM, "0x%x %d:0x%lx %lu", c, thread,
(long unsigned) offset, (long unsigned) n);
rpid.rank = thread;
while (n_rem > 0)
{
size_t n_xfer;
char *bounce_buf;
ptl_size_t local_offset;
/* Use the entire put "bounce buffer" if the transfer
count is sufficiently large. */
n_xfer = GUPCR_MIN (n_rem, (size_t) GUPCR_BOUNCE_BUFFER_SIZE);
if ((gupcr_gmem_put_bb_used + n_xfer) > GUPCR_BOUNCE_BUFFER_SIZE)
gupcr_gmem_sync_puts ();
bounce_buf = &gupcr_gmem_put_bb[gupcr_gmem_put_bb_used];
gupcr_gmem_put_bb_used += n_xfer;
/* Fill the bounce buffer, if we haven't already. */
if (!already_filled)
{
memset (bounce_buf, c, n_xfer);
already_filled = (bounce_buf == gupcr_gmem_put_bb
&& n_xfer == GUPCR_BOUNCE_BUFFER_SIZE);
}
local_offset = bounce_buf - gupcr_gmem_put_bb;
++gupcr_gmem_puts.num_pending;
gupcr_portals_call (PtlPut, (gupcr_gmem_put_bb_md, local_offset, n_xfer,
PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
dest_addr, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
n_rem -= n_xfer;
dest_addr += n_xfer;
}
} | /**
* Write the same byte value into the bytes of the
* destination thread's memory at the specified offset.
*
* The put bounce buffer is used as an intermediate buffer.
* The last write of a chunk of data is non-blocking.
* Caller assumes responsibility for checking the validity
* of the remote thread id's and/or shared memory offsets.
*
* @param [in] thread Destination thread
* @param [in] offset Destination offset
* @param [in] c Set value
* @param [in] n Number of bytes to transfer
*/ | Write the same byte value into the bytes of the
destination thread's memory at the specified offset.
The put bounce buffer is used as an intermediate buffer.
The last write of a chunk of data is non-blocking.
Caller assumes responsibility for checking the validity
of the remote thread id's and/or shared memory offsets.
@param [in] thread Destination thread
@param [in] offset Destination offset
@param [in] c Set value
@param [in] n Number of bytes to transfer | [
"Write",
"the",
"same",
"byte",
"value",
"into",
"the",
"bytes",
"of",
"the",
"destination",
"thread",
"'",
"s",
"memory",
"at",
"the",
"specified",
"offset",
".",
"The",
"put",
"bounce",
"buffer",
"is",
"used",
"as",
"an",
"intermediate",
"buffer",
".",
"The",
"last",
"write",
"of",
"a",
"chunk",
"of",
"data",
"is",
"non",
"-",
"blocking",
".",
"Caller",
"assumes",
"responsibility",
"for",
"checking",
"the",
"validity",
"of",
"the",
"remote",
"thread",
"id",
"'",
"s",
"and",
"/",
"or",
"shared",
"memory",
"offsets",
".",
"@param",
"[",
"in",
"]",
"thread",
"Destination",
"thread",
"@param",
"[",
"in",
"]",
"offset",
"Destination",
"offset",
"@param",
"[",
"in",
"]",
"c",
"Set",
"value",
"@param",
"[",
"in",
"]",
"n",
"Number",
"of",
"bytes",
"to",
"transfer"
] | void
gupcr_gmem_set (int thread, size_t offset, int c, size_t n)
{
size_t n_rem = n;
int already_filled = 0;
ptl_size_t dest_addr = offset;
ptl_process_t rpid;
gupcr_debug (FC_MEM, "0x%x %d:0x%lx %lu", c, thread,
(long unsigned) offset, (long unsigned) n);
rpid.rank = thread;
while (n_rem > 0)
{
size_t n_xfer;
char *bounce_buf;
ptl_size_t local_offset;
n_xfer = GUPCR_MIN (n_rem, (size_t) GUPCR_BOUNCE_BUFFER_SIZE);
if ((gupcr_gmem_put_bb_used + n_xfer) > GUPCR_BOUNCE_BUFFER_SIZE)
gupcr_gmem_sync_puts ();
bounce_buf = &gupcr_gmem_put_bb[gupcr_gmem_put_bb_used];
gupcr_gmem_put_bb_used += n_xfer;
if (!already_filled)
{
memset (bounce_buf, c, n_xfer);
already_filled = (bounce_buf == gupcr_gmem_put_bb
&& n_xfer == GUPCR_BOUNCE_BUFFER_SIZE);
}
local_offset = bounce_buf - gupcr_gmem_put_bb;
++gupcr_gmem_puts.num_pending;
gupcr_portals_call (PtlPut, (gupcr_gmem_put_bb_md, local_offset, n_xfer,
PTL_ACK_REQ, rpid,
GUPCR_PTL_PTE_GMEM, PTL_NO_MATCH_BITS,
dest_addr, PTL_NULL_USER_PTR,
PTL_NULL_HDR_DATA));
n_rem -= n_xfer;
dest_addr += n_xfer;
}
} | [
"void",
"gupcr_gmem_set",
"(",
"int",
"thread",
",",
"size_t",
"offset",
",",
"int",
"c",
",",
"size_t",
"n",
")",
"{",
"size_t",
"n_rem",
"=",
"n",
";",
"int",
"already_filled",
"=",
"0",
";",
"ptl_size_t",
"dest_addr",
"=",
"offset",
";",
"ptl_process_t",
"rpid",
";",
"gupcr_debug",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"c",
",",
"thread",
",",
"(",
"long",
"unsigned",
")",
"offset",
",",
"(",
"long",
"unsigned",
")",
"n",
")",
";",
"rpid",
".",
"rank",
"=",
"thread",
";",
"while",
"(",
"n_rem",
">",
"0",
")",
"{",
"size_t",
"n_xfer",
";",
"char",
"*",
"bounce_buf",
";",
"ptl_size_t",
"local_offset",
";",
"n_xfer",
"=",
"GUPCR_MIN",
"(",
"n_rem",
",",
"(",
"size_t",
")",
"GUPCR_BOUNCE_BUFFER_SIZE",
")",
";",
"if",
"(",
"(",
"gupcr_gmem_put_bb_used",
"+",
"n_xfer",
")",
">",
"GUPCR_BOUNCE_BUFFER_SIZE",
")",
"gupcr_gmem_sync_puts",
"(",
")",
";",
"bounce_buf",
"=",
"&",
"gupcr_gmem_put_bb",
"[",
"gupcr_gmem_put_bb_used",
"]",
";",
"gupcr_gmem_put_bb_used",
"+=",
"n_xfer",
";",
"if",
"(",
"!",
"already_filled",
")",
"{",
"memset",
"(",
"bounce_buf",
",",
"c",
",",
"n_xfer",
")",
";",
"already_filled",
"=",
"(",
"bounce_buf",
"==",
"gupcr_gmem_put_bb",
"&&",
"n_xfer",
"==",
"GUPCR_BOUNCE_BUFFER_SIZE",
")",
";",
"}",
"local_offset",
"=",
"bounce_buf",
"-",
"gupcr_gmem_put_bb",
";",
"++",
"gupcr_gmem_puts",
".",
"num_pending",
";",
"gupcr_portals_call",
"(",
"PtlPut",
",",
"(",
"gupcr_gmem_put_bb_md",
",",
"local_offset",
",",
"n_xfer",
",",
"PTL_ACK_REQ",
",",
"rpid",
",",
"GUPCR_PTL_PTE_GMEM",
",",
"PTL_NO_MATCH_BITS",
",",
"dest_addr",
",",
"PTL_NULL_USER_PTR",
",",
"PTL_NULL_HDR_DATA",
")",
")",
";",
"n_rem",
"-=",
"n_xfer",
";",
"dest_addr",
"+=",
"n_xfer",
";",
"}",
"}"
] | Write the same byte value into the bytes of the
destination thread's memory at the specified offset. | [
"Write",
"the",
"same",
"byte",
"value",
"into",
"the",
"bytes",
"of",
"the",
"destination",
"thread",
"'",
"s",
"memory",
"at",
"the",
"specified",
"offset",
"."
] | [
"/* Use the entire put \"bounce buffer\" if the transfer\n count is sufficiently large. */",
"/* Fill the bounce buffer, if we haven't already. */"
] | [
{
"param": "thread",
"type": "int"
},
{
"param": "offset",
"type": "size_t"
},
{
"param": "c",
"type": "int"
},
{
"param": "n",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "thread",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "c",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_init | void | void
gupcr_gmem_init (void)
{
ptl_md_t md, md_volatile;
ptl_le_t le;
ptl_pt_index_t pte;
gupcr_log (FC_MEM, "gmem init called");
/* Allocate memory for this thread's contribution to shared memory. */
gupcr_gmem_alloc_shared ();
gupcr_portals_call (PtlPTAlloc,
(gupcr_ptl_ni, 0,
PTL_EQ_NONE, GUPCR_PTL_PTE_GMEM, &pte));
if (pte != GUPCR_PTL_PTE_GMEM)
gupcr_fatal_error ("cannot allocate PTE GUPCR_PTL_PTE_GMEM");
gupcr_log (FC_MEM, "Gmem PTE allocated: %d", GUPCR_PTL_PTE_GMEM);
/* Setup Gmem LE. */
le.start = gupcr_gmem_base;
le.length = gupcr_gmem_size;
le.ct_handle = PTL_CT_NONE;
le.uid = PTL_UID_ANY;
le.options = PTL_LE_OP_PUT | PTL_LE_OP_GET;
gupcr_portals_call (PtlLEAppend,
(gupcr_ptl_ni,
GUPCR_PTL_PTE_GMEM, &le,
PTL_PRIORITY_LIST, NULL, &gupcr_gmem_le));
gupcr_debug (FC_MEM, "Gmem LE created at 0x%lx with size 0x%lx)",
(long unsigned) gupcr_gmem_base,
(long unsigned) gupcr_gmem_size);
/* Initialize GMEM get lists */
gupcr_gmem_gets.num_pending = 0;
gupcr_gmem_gets.num_completed = 0;
gupcr_gmem_gets.md_options =
PTL_MD_EVENT_CT_REPLY | PTL_MD_EVENT_SUCCESS_DISABLE;
/* Allocate at least THREADS number of EQ entries. */
gupcr_portals_call (PtlEQAlloc,
(gupcr_ptl_ni, THREADS, &gupcr_gmem_gets.eq_handle));
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_gmem_gets.ct_handle));
/* Map user's address space for GET operations. */
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = gupcr_gmem_gets.md_options;
md.eq_handle = gupcr_gmem_gets.eq_handle;
md.ct_handle = gupcr_gmem_gets.ct_handle;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_gmem_gets.md));
/* Initialize GMEM put lists. */
gupcr_gmem_puts.num_pending = 0;
gupcr_gmem_puts.num_completed = 0;
gupcr_gmem_puts.md_options =
PTL_MD_EVENT_CT_ACK | PTL_MD_EVENT_SUCCESS_DISABLE;
/* Allocate at least THREADS number of EQ entries. */
gupcr_portals_call (PtlEQAlloc,
(gupcr_ptl_ni, THREADS, &gupcr_gmem_puts.eq_handle));
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_gmem_puts.ct_handle));
/* Map user's address space for PUT operations. */
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = gupcr_gmem_puts.md_options;
md.eq_handle = gupcr_gmem_puts.eq_handle;
md.ct_handle = gupcr_gmem_puts.ct_handle;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_gmem_puts.md));
/* And map the same but with a volatile option. */
md_volatile = md;
md_volatile.options |= PTL_MD_VOLATILE;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md_volatile,
&gupcr_gmem_puts.md_volatile));
/* Initialize GMEM put bounce buffer. */
md.length = GUPCR_BOUNCE_BUFFER_SIZE;
md.start = gupcr_gmem_put_bb;
md.options = gupcr_gmem_puts.md_options;
md.eq_handle = gupcr_gmem_puts.eq_handle;
md.ct_handle = gupcr_gmem_puts.ct_handle;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_gmem_put_bb_md));
} | /**
* Initialize gmem resources.
* @ingroup INIT
*/ | Initialize gmem resources.
@ingroup INIT | [
"Initialize",
"gmem",
"resources",
".",
"@ingroup",
"INIT"
] | void
gupcr_gmem_init (void)
{
ptl_md_t md, md_volatile;
ptl_le_t le;
ptl_pt_index_t pte;
gupcr_log (FC_MEM, "gmem init called");
gupcr_gmem_alloc_shared ();
gupcr_portals_call (PtlPTAlloc,
(gupcr_ptl_ni, 0,
PTL_EQ_NONE, GUPCR_PTL_PTE_GMEM, &pte));
if (pte != GUPCR_PTL_PTE_GMEM)
gupcr_fatal_error ("cannot allocate PTE GUPCR_PTL_PTE_GMEM");
gupcr_log (FC_MEM, "Gmem PTE allocated: %d", GUPCR_PTL_PTE_GMEM);
le.start = gupcr_gmem_base;
le.length = gupcr_gmem_size;
le.ct_handle = PTL_CT_NONE;
le.uid = PTL_UID_ANY;
le.options = PTL_LE_OP_PUT | PTL_LE_OP_GET;
gupcr_portals_call (PtlLEAppend,
(gupcr_ptl_ni,
GUPCR_PTL_PTE_GMEM, &le,
PTL_PRIORITY_LIST, NULL, &gupcr_gmem_le));
gupcr_debug (FC_MEM, "Gmem LE created at 0x%lx with size 0x%lx)",
(long unsigned) gupcr_gmem_base,
(long unsigned) gupcr_gmem_size);
gupcr_gmem_gets.num_pending = 0;
gupcr_gmem_gets.num_completed = 0;
gupcr_gmem_gets.md_options =
PTL_MD_EVENT_CT_REPLY | PTL_MD_EVENT_SUCCESS_DISABLE;
gupcr_portals_call (PtlEQAlloc,
(gupcr_ptl_ni, THREADS, &gupcr_gmem_gets.eq_handle));
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_gmem_gets.ct_handle));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = gupcr_gmem_gets.md_options;
md.eq_handle = gupcr_gmem_gets.eq_handle;
md.ct_handle = gupcr_gmem_gets.ct_handle;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_gmem_gets.md));
gupcr_gmem_puts.num_pending = 0;
gupcr_gmem_puts.num_completed = 0;
gupcr_gmem_puts.md_options =
PTL_MD_EVENT_CT_ACK | PTL_MD_EVENT_SUCCESS_DISABLE;
gupcr_portals_call (PtlEQAlloc,
(gupcr_ptl_ni, THREADS, &gupcr_gmem_puts.eq_handle));
gupcr_portals_call (PtlCTAlloc, (gupcr_ptl_ni, &gupcr_gmem_puts.ct_handle));
md.length = (ptl_size_t) USER_PROG_MEM_SIZE;
md.start = (void *) USER_PROG_MEM_START;
md.options = gupcr_gmem_puts.md_options;
md.eq_handle = gupcr_gmem_puts.eq_handle;
md.ct_handle = gupcr_gmem_puts.ct_handle;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_gmem_puts.md));
md_volatile = md;
md_volatile.options |= PTL_MD_VOLATILE;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md_volatile,
&gupcr_gmem_puts.md_volatile));
md.length = GUPCR_BOUNCE_BUFFER_SIZE;
md.start = gupcr_gmem_put_bb;
md.options = gupcr_gmem_puts.md_options;
md.eq_handle = gupcr_gmem_puts.eq_handle;
md.ct_handle = gupcr_gmem_puts.ct_handle;
gupcr_portals_call (PtlMDBind, (gupcr_ptl_ni, &md, &gupcr_gmem_put_bb_md));
} | [
"void",
"gupcr_gmem_init",
"(",
"void",
")",
"{",
"ptl_md_t",
"md",
",",
"md_volatile",
";",
"ptl_le_t",
"le",
";",
"ptl_pt_index_t",
"pte",
";",
"gupcr_log",
"(",
"FC_MEM",
",",
"\"",
"\"",
")",
";",
"gupcr_gmem_alloc_shared",
"(",
")",
";",
"gupcr_portals_call",
"(",
"PtlPTAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"0",
",",
"PTL_EQ_NONE",
",",
"GUPCR_PTL_PTE_GMEM",
",",
"&",
"pte",
")",
")",
";",
"if",
"(",
"pte",
"!=",
"GUPCR_PTL_PTE_GMEM",
")",
"gupcr_fatal_error",
"(",
"\"",
"\"",
")",
";",
"gupcr_log",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"GUPCR_PTL_PTE_GMEM",
")",
";",
"le",
".",
"start",
"=",
"gupcr_gmem_base",
";",
"le",
".",
"length",
"=",
"gupcr_gmem_size",
";",
"le",
".",
"ct_handle",
"=",
"PTL_CT_NONE",
";",
"le",
".",
"uid",
"=",
"PTL_UID_ANY",
";",
"le",
".",
"options",
"=",
"PTL_LE_OP_PUT",
"|",
"PTL_LE_OP_GET",
";",
"gupcr_portals_call",
"(",
"PtlLEAppend",
",",
"(",
"gupcr_ptl_ni",
",",
"GUPCR_PTL_PTE_GMEM",
",",
"&",
"le",
",",
"PTL_PRIORITY_LIST",
",",
"NULL",
",",
"&",
"gupcr_gmem_le",
")",
")",
";",
"gupcr_debug",
"(",
"FC_MEM",
",",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
")",
"gupcr_gmem_base",
",",
"(",
"long",
"unsigned",
")",
"gupcr_gmem_size",
")",
";",
"gupcr_gmem_gets",
".",
"num_pending",
"=",
"0",
";",
"gupcr_gmem_gets",
".",
"num_completed",
"=",
"0",
";",
"gupcr_gmem_gets",
".",
"md_options",
"=",
"PTL_MD_EVENT_CT_REPLY",
"|",
"PTL_MD_EVENT_SUCCESS_DISABLE",
";",
"gupcr_portals_call",
"(",
"PtlEQAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"THREADS",
",",
"&",
"gupcr_gmem_gets",
".",
"eq_handle",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"gupcr_gmem_gets",
".",
"ct_handle",
")",
")",
";",
"md",
".",
"length",
"=",
"(",
"ptl_size_t",
")",
"USER_PROG_MEM_SIZE",
";",
"md",
".",
"start",
"=",
"(",
"void",
"*",
")",
"USER_PROG_MEM_START",
";",
"md",
".",
"options",
"=",
"gupcr_gmem_gets",
".",
"md_options",
";",
"md",
".",
"eq_handle",
"=",
"gupcr_gmem_gets",
".",
"eq_handle",
";",
"md",
".",
"ct_handle",
"=",
"gupcr_gmem_gets",
".",
"ct_handle",
";",
"gupcr_portals_call",
"(",
"PtlMDBind",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"md",
",",
"&",
"gupcr_gmem_gets",
".",
"md",
")",
")",
";",
"gupcr_gmem_puts",
".",
"num_pending",
"=",
"0",
";",
"gupcr_gmem_puts",
".",
"num_completed",
"=",
"0",
";",
"gupcr_gmem_puts",
".",
"md_options",
"=",
"PTL_MD_EVENT_CT_ACK",
"|",
"PTL_MD_EVENT_SUCCESS_DISABLE",
";",
"gupcr_portals_call",
"(",
"PtlEQAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"THREADS",
",",
"&",
"gupcr_gmem_puts",
".",
"eq_handle",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTAlloc",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"gupcr_gmem_puts",
".",
"ct_handle",
")",
")",
";",
"md",
".",
"length",
"=",
"(",
"ptl_size_t",
")",
"USER_PROG_MEM_SIZE",
";",
"md",
".",
"start",
"=",
"(",
"void",
"*",
")",
"USER_PROG_MEM_START",
";",
"md",
".",
"options",
"=",
"gupcr_gmem_puts",
".",
"md_options",
";",
"md",
".",
"eq_handle",
"=",
"gupcr_gmem_puts",
".",
"eq_handle",
";",
"md",
".",
"ct_handle",
"=",
"gupcr_gmem_puts",
".",
"ct_handle",
";",
"gupcr_portals_call",
"(",
"PtlMDBind",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"md",
",",
"&",
"gupcr_gmem_puts",
".",
"md",
")",
")",
";",
"md_volatile",
"=",
"md",
";",
"md_volatile",
".",
"options",
"|=",
"PTL_MD_VOLATILE",
";",
"gupcr_portals_call",
"(",
"PtlMDBind",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"md_volatile",
",",
"&",
"gupcr_gmem_puts",
".",
"md_volatile",
")",
")",
";",
"md",
".",
"length",
"=",
"GUPCR_BOUNCE_BUFFER_SIZE",
";",
"md",
".",
"start",
"=",
"gupcr_gmem_put_bb",
";",
"md",
".",
"options",
"=",
"gupcr_gmem_puts",
".",
"md_options",
";",
"md",
".",
"eq_handle",
"=",
"gupcr_gmem_puts",
".",
"eq_handle",
";",
"md",
".",
"ct_handle",
"=",
"gupcr_gmem_puts",
".",
"ct_handle",
";",
"gupcr_portals_call",
"(",
"PtlMDBind",
",",
"(",
"gupcr_ptl_ni",
",",
"&",
"md",
",",
"&",
"gupcr_gmem_put_bb_md",
")",
")",
";",
"}"
] | Initialize gmem resources. | [
"Initialize",
"gmem",
"resources",
"."
] | [
"/* Allocate memory for this thread's contribution to shared memory. */",
"/* Setup Gmem LE. */",
"/* Initialize GMEM get lists */",
"/* Allocate at least THREADS number of EQ entries. */",
"/* Map user's address space for GET operations. */",
"/* Initialize GMEM put lists. */",
"/* Allocate at least THREADS number of EQ entries. */",
"/* Map user's address space for PUT operations. */",
"/* And map the same but with a volatile option. */",
"/* Initialize GMEM put bounce buffer. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90aa8e502c6ae7964dc180457410d7233bc52c89 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_gmem.c | [
"Apache-2.0"
] | C | gupcr_gmem_fini | void | void
gupcr_gmem_fini (void)
{
gupcr_log (FC_MEM, "gmem fini called");
/* Release GET MD. */
gupcr_portals_call (PtlMDRelease, (gupcr_gmem_gets.md));
gupcr_portals_call (PtlCTFree, (gupcr_gmem_gets.ct_handle));
gupcr_portals_call (PtlEQFree, (gupcr_gmem_gets.eq_handle));
/* Release PUT MDs. */
gupcr_portals_call (PtlMDRelease, (gupcr_gmem_puts.md));
gupcr_portals_call (PtlMDRelease, (gupcr_gmem_put_bb_md));
gupcr_portals_call (PtlCTFree, (gupcr_gmem_puts.ct_handle));
gupcr_portals_call (PtlEQFree, (gupcr_gmem_puts.eq_handle));
/* Release LEs and PTEs. */
gupcr_portals_call (PtlLEUnlink, (gupcr_gmem_le));
gupcr_portals_call (PtlPTFree, (gupcr_ptl_ni, GUPCR_PTL_PTE_GMEM));
} | /**
* Release gmem resources.
* @ingroup INIT
*/ | Release gmem resources.
@ingroup INIT | [
"Release",
"gmem",
"resources",
".",
"@ingroup",
"INIT"
] | void
gupcr_gmem_fini (void)
{
gupcr_log (FC_MEM, "gmem fini called");
gupcr_portals_call (PtlMDRelease, (gupcr_gmem_gets.md));
gupcr_portals_call (PtlCTFree, (gupcr_gmem_gets.ct_handle));
gupcr_portals_call (PtlEQFree, (gupcr_gmem_gets.eq_handle));
gupcr_portals_call (PtlMDRelease, (gupcr_gmem_puts.md));
gupcr_portals_call (PtlMDRelease, (gupcr_gmem_put_bb_md));
gupcr_portals_call (PtlCTFree, (gupcr_gmem_puts.ct_handle));
gupcr_portals_call (PtlEQFree, (gupcr_gmem_puts.eq_handle));
gupcr_portals_call (PtlLEUnlink, (gupcr_gmem_le));
gupcr_portals_call (PtlPTFree, (gupcr_ptl_ni, GUPCR_PTL_PTE_GMEM));
} | [
"void",
"gupcr_gmem_fini",
"(",
"void",
")",
"{",
"gupcr_log",
"(",
"FC_MEM",
",",
"\"",
"\"",
")",
";",
"gupcr_portals_call",
"(",
"PtlMDRelease",
",",
"(",
"gupcr_gmem_gets",
".",
"md",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTFree",
",",
"(",
"gupcr_gmem_gets",
".",
"ct_handle",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlEQFree",
",",
"(",
"gupcr_gmem_gets",
".",
"eq_handle",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlMDRelease",
",",
"(",
"gupcr_gmem_puts",
".",
"md",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlMDRelease",
",",
"(",
"gupcr_gmem_put_bb_md",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlCTFree",
",",
"(",
"gupcr_gmem_puts",
".",
"ct_handle",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlEQFree",
",",
"(",
"gupcr_gmem_puts",
".",
"eq_handle",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlLEUnlink",
",",
"(",
"gupcr_gmem_le",
")",
")",
";",
"gupcr_portals_call",
"(",
"PtlPTFree",
",",
"(",
"gupcr_ptl_ni",
",",
"GUPCR_PTL_PTE_GMEM",
")",
")",
";",
"}"
] | Release gmem resources. | [
"Release",
"gmem",
"resources",
"."
] | [
"/* Release GET MD. */",
"/* Release PUT MDs. */",
"/* Release LEs and PTEs. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
401cce3cc12e9d763722feb42ddf2f81448036b0 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_node_mem_mmap.c | [
"Apache-2.0"
] | C | gupcr_mem_local_unlink | void | void
gupcr_mem_local_unlink (void)
{
unlink (gupcr_thread_local_name);
} | /**
* Remove the file used for mmap.
* On Unix systems, this removes the file name, but since
* the file is open, the underlying file storage will remain
* until the program terminates.
*/ | Remove the file used for mmap.
On Unix systems, this removes the file name, but since
the file is open, the underlying file storage will remain
until the program terminates. | [
"Remove",
"the",
"file",
"used",
"for",
"mmap",
".",
"On",
"Unix",
"systems",
"this",
"removes",
"the",
"file",
"name",
"but",
"since",
"the",
"file",
"is",
"open",
"the",
"underlying",
"file",
"storage",
"will",
"remain",
"until",
"the",
"program",
"terminates",
"."
] | void
gupcr_mem_local_unlink (void)
{
unlink (gupcr_thread_local_name);
} | [
"void",
"gupcr_mem_local_unlink",
"(",
"void",
")",
"{",
"unlink",
"(",
"gupcr_thread_local_name",
")",
";",
"}"
] | Remove the file used for mmap. | [
"Remove",
"the",
"file",
"used",
"for",
"mmap",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2b32d067dac486f2c8c20ee71e1dc85ac95d94e1 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_backtrace.c | [
"Apache-2.0"
] | C | gupcr_backtrace | void | void
gupcr_backtrace (void)
{
void *strace[GUPCR_BT_DEPTH_CNT];
size_t size,i;
char **strace_str;
char *file_env;
int under_upc_main = 1;
FILE *traceout = stderr;
file_env = getenv (GUPCR_BACKTRACE_FILE_ENV);
if (file_env)
{
#define MAX_INT_STRING ".2147483647"
char *tracefile;
int len, lenw;
/* Use default trace file name if one not specified by the user. */
if (!strlen (file_env))
file_env = (char *) UPC_BACKTRACE_PREFIX;
len = strlen (file_env) + strlen (MAX_INT_STRING) + 1;
tracefile = malloc (len);
if (!tracefile)
gupcr_fatal_error ("cannot allocate (%d) memory for backtrace file %s",
len, file_env);
lenw = snprintf (tracefile, len, "%s.%d", file_env, MYTHREAD);
if ((lenw >= len) || (lenw < 0))
gupcr_fatal_error ("cannot create backtrace file name: %s", file_env);
traceout = fopen (tracefile, "w");
if (!traceout)
gupcr_fatal_error ("cannot open backtrace file: %s", tracefile);
free (tracefile);
}
else
fprintf (traceout, "Thread %d backtrace:\n", MYTHREAD);
/* Use "backtrace" functionality of glibc to receive
backtrace addresses. */
size = backtrace (strace, GUPCR_BT_DEPTH_CNT);
/* Add symbolic information to each address
and print the stack trace. */
for (i = GUPCR_BT_SKIP_FRAME_CNT; i < size; i++)
{
if (under_upc_main)
{
# if HAVE_UPC_BACKTRACE_ADDR2LINE
/* Call addr2line to generate source files, line numbers,
and functions. In case of any error (malloc, snprintf)
do not abort the program. */
FILE *a2l;
#define CMD_TMPL "%s -f -e %s %p"
/* Allow space for addr2line, filename, command line options,
and address argument for addr2line. */
int cmd_size = strlen (GUPCR_BACKTRACE_ADDR2LINE) +
strlen (gupcr_abs_execname) +
strlen (CMD_TMPL) +
strlen ("0x1234567812345678");
int sz;
char *cmd = malloc (cmd_size);
/* Create an actual addr2line command. */
sz = snprintf (cmd, cmd_size, CMD_TMPL, GUPCR_BACKTRACE_ADDR2LINE,
gupcr_abs_execname, strace[i]);
if ((sz >= cmd_size) || (sz < 0))
{
fprintf (traceout, "unable to create addr2line "
"command line\n");
return;
}
/* Execute addr2line. */
a2l = popen (cmd, "r");
free (cmd);
if (a2l)
{
/* addr2line responds with two lines: procedure name and
the file name with line number. */
int max_rep = 2 * FILENAME_MAX;
/* Build a data structure that is identical to the
structure returned by the glibc backtrace_symbol(). */
struct back_trace {
char *addr;
char data[1];
};
struct back_trace *rep = malloc (max_rep);
int index = 0;
if (!rep)
{
fprintf (traceout, "unable to acquire memory "
"for backtracing\n");
return;
}
rep->data[0] = '\0';
/* Read addr2line response. */
while (fgets(&rep->data[index], max_rep-index, a2l))
{
/* Remove all the new lines, as addr2line returns
info in multiple lines. */
index = strlen (&rep->data[0]);
if (rep->data[index - 1] == '\n')
rep->data[index - 1] = ' ';
}
pclose (a2l);
rep->addr = &rep->data[0];
strace_str = &rep->addr;
}
else
{
/* Somehow we failed to invoke addr2line, fall back
to glibc. */
strace_str = backtrace_symbols (&strace[i], 1);
}
# else
strace_str = backtrace_symbols (&strace[i], 1);
# endif
fprintf (traceout, "[%4d][%lld] %s\n", MYTHREAD,
(long long int) (i - GUPCR_BT_SKIP_FRAME_CNT), *strace_str);
/* Extra info for the barrier. */
if (strstr( *strace_str, "__upc_wait"))
{
fprintf (traceout, "[%4d] BARRIER ID: %d\n", MYTHREAD,
gupcr_barrier_id);
}
if (strstr (*strace_str, "upc_main"))
under_upc_main = 0;
/* Symbol trace buffer must be released. */
free (strace_str);
}
}
fflush (traceout);
if (file_env)
fclose (traceout);
} | /**
* GLIBC backtrace.
*
* Show backtrace by using the GLIBC backtrace functionality.
* Backtrace is improved with the source file/line numbers if
* addr2line is available.
*
* By default backtrace lines are sent to the 'stderr' file
* descriptor. However, an environment variable
* UPC_BACKTRACEFILE can be used to redirect the backtrace
* to an actual file and it is used as a simple prefix for
* the backtrace file. For example, if it is set to "/tmp/trace-upc",
* the actual trace file is going to be "/tmp/trace-upc-PID.MYTHREAD".
* If empty environment variable is provided, a simple "trace" prefix
* is used.
*
*/ | GLIBC backtrace.
Show backtrace by using the GLIBC backtrace functionality.
Backtrace is improved with the source file/line numbers if
addr2line is available.
By default backtrace lines are sent to the 'stderr' file
descriptor. However, an environment variable
UPC_BACKTRACEFILE can be used to redirect the backtrace
to an actual file and it is used as a simple prefix for
the backtrace file. For example, if it is set to "/tmp/trace-upc",
the actual trace file is going to be "/tmp/trace-upc-PID.MYTHREAD".
If empty environment variable is provided, a simple "trace" prefix
is used. | [
"GLIBC",
"backtrace",
".",
"Show",
"backtrace",
"by",
"using",
"the",
"GLIBC",
"backtrace",
"functionality",
".",
"Backtrace",
"is",
"improved",
"with",
"the",
"source",
"file",
"/",
"line",
"numbers",
"if",
"addr2line",
"is",
"available",
".",
"By",
"default",
"backtrace",
"lines",
"are",
"sent",
"to",
"the",
"'",
"stderr",
"'",
"file",
"descriptor",
".",
"However",
"an",
"environment",
"variable",
"UPC_BACKTRACEFILE",
"can",
"be",
"used",
"to",
"redirect",
"the",
"backtrace",
"to",
"an",
"actual",
"file",
"and",
"it",
"is",
"used",
"as",
"a",
"simple",
"prefix",
"for",
"the",
"backtrace",
"file",
".",
"For",
"example",
"if",
"it",
"is",
"set",
"to",
"\"",
"/",
"tmp",
"/",
"trace",
"-",
"upc",
"\"",
"the",
"actual",
"trace",
"file",
"is",
"going",
"to",
"be",
"\"",
"/",
"tmp",
"/",
"trace",
"-",
"upc",
"-",
"PID",
".",
"MYTHREAD",
"\"",
".",
"If",
"empty",
"environment",
"variable",
"is",
"provided",
"a",
"simple",
"\"",
"trace",
"\"",
"prefix",
"is",
"used",
"."
] | void
gupcr_backtrace (void)
{
void *strace[GUPCR_BT_DEPTH_CNT];
size_t size,i;
char **strace_str;
char *file_env;
int under_upc_main = 1;
FILE *traceout = stderr;
file_env = getenv (GUPCR_BACKTRACE_FILE_ENV);
if (file_env)
{
#define MAX_INT_STRING ".2147483647"
char *tracefile;
int len, lenw;
if (!strlen (file_env))
file_env = (char *) UPC_BACKTRACE_PREFIX;
len = strlen (file_env) + strlen (MAX_INT_STRING) + 1;
tracefile = malloc (len);
if (!tracefile)
gupcr_fatal_error ("cannot allocate (%d) memory for backtrace file %s",
len, file_env);
lenw = snprintf (tracefile, len, "%s.%d", file_env, MYTHREAD);
if ((lenw >= len) || (lenw < 0))
gupcr_fatal_error ("cannot create backtrace file name: %s", file_env);
traceout = fopen (tracefile, "w");
if (!traceout)
gupcr_fatal_error ("cannot open backtrace file: %s", tracefile);
free (tracefile);
}
else
fprintf (traceout, "Thread %d backtrace:\n", MYTHREAD);
size = backtrace (strace, GUPCR_BT_DEPTH_CNT);
for (i = GUPCR_BT_SKIP_FRAME_CNT; i < size; i++)
{
if (under_upc_main)
{
# if HAVE_UPC_BACKTRACE_ADDR2LINE
FILE *a2l;
#define CMD_TMPL "%s -f -e %s %p"
int cmd_size = strlen (GUPCR_BACKTRACE_ADDR2LINE) +
strlen (gupcr_abs_execname) +
strlen (CMD_TMPL) +
strlen ("0x1234567812345678");
int sz;
char *cmd = malloc (cmd_size);
sz = snprintf (cmd, cmd_size, CMD_TMPL, GUPCR_BACKTRACE_ADDR2LINE,
gupcr_abs_execname, strace[i]);
if ((sz >= cmd_size) || (sz < 0))
{
fprintf (traceout, "unable to create addr2line "
"command line\n");
return;
}
a2l = popen (cmd, "r");
free (cmd);
if (a2l)
{
int max_rep = 2 * FILENAME_MAX;
struct back_trace {
char *addr;
char data[1];
};
struct back_trace *rep = malloc (max_rep);
int index = 0;
if (!rep)
{
fprintf (traceout, "unable to acquire memory "
"for backtracing\n");
return;
}
rep->data[0] = '\0';
while (fgets(&rep->data[index], max_rep-index, a2l))
{
index = strlen (&rep->data[0]);
if (rep->data[index - 1] == '\n')
rep->data[index - 1] = ' ';
}
pclose (a2l);
rep->addr = &rep->data[0];
strace_str = &rep->addr;
}
else
{
strace_str = backtrace_symbols (&strace[i], 1);
}
# else
strace_str = backtrace_symbols (&strace[i], 1);
# endif
fprintf (traceout, "[%4d][%lld] %s\n", MYTHREAD,
(long long int) (i - GUPCR_BT_SKIP_FRAME_CNT), *strace_str);
if (strstr( *strace_str, "__upc_wait"))
{
fprintf (traceout, "[%4d] BARRIER ID: %d\n", MYTHREAD,
gupcr_barrier_id);
}
if (strstr (*strace_str, "upc_main"))
under_upc_main = 0;
free (strace_str);
}
}
fflush (traceout);
if (file_env)
fclose (traceout);
} | [
"void",
"gupcr_backtrace",
"(",
"void",
")",
"{",
"void",
"*",
"strace",
"[",
"GUPCR_BT_DEPTH_CNT",
"]",
";",
"size_t",
"size",
",",
"i",
";",
"char",
"*",
"*",
"strace_str",
";",
"char",
"*",
"file_env",
";",
"int",
"under_upc_main",
"=",
"1",
";",
"FILE",
"*",
"traceout",
"=",
"stderr",
";",
"file_env",
"=",
"getenv",
"(",
"GUPCR_BACKTRACE_FILE_ENV",
")",
";",
"if",
"(",
"file_env",
")",
"{",
"#define",
"MAX_INT_STRING",
" \".2147483647\"",
"\n",
"char",
"*",
"tracefile",
";",
"int",
"len",
",",
"lenw",
";",
"if",
"(",
"!",
"strlen",
"(",
"file_env",
")",
")",
"file_env",
"=",
"(",
"char",
"*",
")",
"UPC_BACKTRACE_PREFIX",
";",
"len",
"=",
"strlen",
"(",
"file_env",
")",
"+",
"strlen",
"(",
"MAX_INT_STRING",
")",
"+",
"1",
";",
"tracefile",
"=",
"malloc",
"(",
"len",
")",
";",
"if",
"(",
"!",
"tracefile",
")",
"gupcr_fatal_error",
"(",
"\"",
"\"",
",",
"len",
",",
"file_env",
")",
";",
"lenw",
"=",
"snprintf",
"(",
"tracefile",
",",
"len",
",",
"\"",
"\"",
",",
"file_env",
",",
"MYTHREAD",
")",
";",
"if",
"(",
"(",
"lenw",
">=",
"len",
")",
"||",
"(",
"lenw",
"<",
"0",
")",
")",
"gupcr_fatal_error",
"(",
"\"",
"\"",
",",
"file_env",
")",
";",
"traceout",
"=",
"fopen",
"(",
"tracefile",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"!",
"traceout",
")",
"gupcr_fatal_error",
"(",
"\"",
"\"",
",",
"tracefile",
")",
";",
"free",
"(",
"tracefile",
")",
";",
"}",
"else",
"fprintf",
"(",
"traceout",
",",
"\"",
"\\n",
"\"",
",",
"MYTHREAD",
")",
";",
"size",
"=",
"backtrace",
"(",
"strace",
",",
"GUPCR_BT_DEPTH_CNT",
")",
";",
"for",
"(",
"i",
"=",
"GUPCR_BT_SKIP_FRAME_CNT",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"under_upc_main",
")",
"{",
"# if",
"HAVE_UPC_BACKTRACE_ADDR2LINE",
"\n",
"FILE",
"*",
"a2l",
";",
"#define",
"CMD_TMPL",
" \"%s -f -e %s %p\"",
"\n",
"int",
"cmd_size",
"=",
"strlen",
"(",
"GUPCR_BACKTRACE_ADDR2LINE",
")",
"+",
"strlen",
"(",
"gupcr_abs_execname",
")",
"+",
"strlen",
"(",
"CMD_TMPL",
")",
"+",
"strlen",
"(",
"\"",
"\"",
")",
";",
"int",
"sz",
";",
"char",
"*",
"cmd",
"=",
"malloc",
"(",
"cmd_size",
")",
";",
"sz",
"=",
"snprintf",
"(",
"cmd",
",",
"cmd_size",
",",
"CMD_TMPL",
",",
"GUPCR_BACKTRACE_ADDR2LINE",
",",
"gupcr_abs_execname",
",",
"strace",
"[",
"i",
"]",
")",
";",
"if",
"(",
"(",
"sz",
">=",
"cmd_size",
")",
"||",
"(",
"sz",
"<",
"0",
")",
")",
"{",
"fprintf",
"(",
"traceout",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
")",
";",
"return",
";",
"}",
"a2l",
"=",
"popen",
"(",
"cmd",
",",
"\"",
"\"",
")",
";",
"free",
"(",
"cmd",
")",
";",
"if",
"(",
"a2l",
")",
"{",
"int",
"max_rep",
"=",
"2",
"*",
"FILENAME_MAX",
";",
"struct",
"back_trace",
"{",
"char",
"*",
"addr",
";",
"char",
"data",
"[",
"1",
"]",
";",
"}",
";",
"struct",
"back_trace",
"*",
"rep",
"=",
"malloc",
"(",
"max_rep",
")",
";",
"int",
"index",
"=",
"0",
";",
"if",
"(",
"!",
"rep",
")",
"{",
"fprintf",
"(",
"traceout",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
")",
";",
"return",
";",
"}",
"rep",
"->",
"data",
"[",
"0",
"]",
"=",
"'",
"\\0",
"'",
";",
"while",
"(",
"fgets",
"(",
"&",
"rep",
"->",
"data",
"[",
"index",
"]",
",",
"max_rep",
"-",
"index",
",",
"a2l",
")",
")",
"{",
"index",
"=",
"strlen",
"(",
"&",
"rep",
"->",
"data",
"[",
"0",
"]",
")",
";",
"if",
"(",
"rep",
"->",
"data",
"[",
"index",
"-",
"1",
"]",
"==",
"'",
"\\n",
"'",
")",
"rep",
"->",
"data",
"[",
"index",
"-",
"1",
"]",
"=",
"'",
"'",
";",
"}",
"pclose",
"(",
"a2l",
")",
";",
"rep",
"->",
"addr",
"=",
"&",
"rep",
"->",
"data",
"[",
"0",
"]",
";",
"strace_str",
"=",
"&",
"rep",
"->",
"addr",
";",
"}",
"else",
"{",
"strace_str",
"=",
"backtrace_symbols",
"(",
"&",
"strace",
"[",
"i",
"]",
",",
"1",
")",
";",
"}",
"# else",
"strace_str",
"=",
"backtrace_symbols",
"(",
"&",
"strace",
"[",
"i",
"]",
",",
"1",
")",
";",
"# endif",
"fprintf",
"(",
"traceout",
",",
"\"",
"\\n",
"\"",
",",
"MYTHREAD",
",",
"(",
"long",
"long",
"int",
")",
"(",
"i",
"-",
"GUPCR_BT_SKIP_FRAME_CNT",
")",
",",
"*",
"strace_str",
")",
";",
"if",
"(",
"strstr",
"(",
"*",
"strace_str",
",",
"\"",
"\"",
")",
")",
"{",
"fprintf",
"(",
"traceout",
",",
"\"",
"\\n",
"\"",
",",
"MYTHREAD",
",",
"gupcr_barrier_id",
")",
";",
"}",
"if",
"(",
"strstr",
"(",
"*",
"strace_str",
",",
"\"",
"\"",
")",
")",
"under_upc_main",
"=",
"0",
";",
"free",
"(",
"strace_str",
")",
";",
"}",
"}",
"fflush",
"(",
"traceout",
")",
";",
"if",
"(",
"file_env",
")",
"fclose",
"(",
"traceout",
")",
";",
"}"
] | GLIBC backtrace. | [
"GLIBC",
"backtrace",
"."
] | [
"/* Use default trace file name if one not specified by the user. */",
"/* Use \"backtrace\" functionality of glibc to receive\n backtrace addresses. */",
"/* Add symbolic information to each address\n and print the stack trace. */",
"/* Call addr2line to generate source files, line numbers,\n\t and functions. In case of any error (malloc, snprintf)\n\t do not abort the program. */",
"/* Allow space for addr2line, filename, command line options,\n\t and address argument for addr2line. */",
"/* Create an actual addr2line command. */",
"/* Execute addr2line. */",
"/* addr2line responds with two lines: procedure name and\n\t\t the file name with line number. */",
"/* Build a data structure that is identical to the\n\t\t structure returned by the glibc backtrace_symbol(). */",
"/* Read addr2line response. */",
"/* Remove all the new lines, as addr2line returns\n\t\t info in multiple lines. */",
"/* Somehow we failed to invoke addr2line, fall back\n\t to glibc. */",
"/* Extra info for the barrier. */",
"/* Symbol trace buffer must be released. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2b32d067dac486f2c8c20ee71e1dc85ac95d94e1 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_backtrace.c | [
"Apache-2.0"
] | C | gupcr_fatal_error_backtrace | void | void
gupcr_fatal_error_backtrace (void)
{
if (bt_enabled)
{
#ifdef HAVE_UPC_BACKTRACE_GDB
{
char *env;
const char *gdb;
char pid_buf[GUPCR_BACKTRACE_PID_BUFLEN];
int child_pid;
/* Which gdb to use? */
env = getenv (GUPCR_BACKTRACE_GDB_ENV);
if (!env || (strlen (env) == 0))
gdb = GUPCR_BACKTRACE_GDB;
else
gdb = (const char *) env;
if (strcmp (gdb, "none"))
{
const char *err_msg = 0;
char tmpf[PATH_MAX];
int fbt;
const char *btcmd = "backtrace 30\n";
fprintf (stderr, "Thread %d GDB backtrace:\n", MYTHREAD);
/* Get pid and name of the running program. */
sprintf(pid_buf, "%d", getpid());
/* Create temp file for GDB commands. */
if ((fbt = gupcr_create_temp_file
("upc_bt_gdb.XXXXXX", tmpf, &err_msg)) == -1)
{
fprintf (stderr, "cannot open gdb command - %s\n", err_msg);
return;
}
if (write (fbt, btcmd, sizeof (btcmd)) == -1)
{
perror ("cannot write gdb command file for backtrace");
return;
}
if (close (fbt))
{
perror ("cannot close gdb command file for backtrace");
return;
}
child_pid = fork();
if (!child_pid)
{
dup2(2,1);
execlp(gdb, gdb, "-nx", "-batch", "-x", tmpf,
gupcr_abs_execname, pid_buf, NULL);
fprintf (stderr, "cannot start GDB - %s\n", gdb);
abort(); /* If gdb failed to start */
}
else
waitpid(child_pid,NULL,0);
unlink (tmpf);
return;
}
}
#endif /* GUPCR_BACKTRACE_GDB */
/* Simple backtrace only. */
gupcr_backtrace ();
}
} | /**
* Backtrace on fatal errors.
*
* Print backtrace (stack frames) on fatal errors: run-time
* fatal error or segmentation fault.
*
* Only print backtrace if environment variable UPC_BACKTRACE
* is set to 1. The following order of backtrace capabilities
* is searched and executed:
*
* (1) Use GDB for backtrace (if enabled)
* (2) Use GLIBC backtrace with source file/line display (if
* addr2line is available)
* (3) Use GLIBC backtrace with raw addresses (display is
* improved if -rdynamic option is supported by the linker)
*
*/ | Backtrace on fatal errors.
Print backtrace (stack frames) on fatal errors: run-time
fatal error or segmentation fault.
Only print backtrace if environment variable UPC_BACKTRACE
is set to 1. The following order of backtrace capabilities
is searched and executed.
(1) Use GDB for backtrace (if enabled)
(2) Use GLIBC backtrace with source file/line display (if
addr2line is available)
(3) Use GLIBC backtrace with raw addresses (display is
improved if -rdynamic option is supported by the linker) | [
"Backtrace",
"on",
"fatal",
"errors",
".",
"Print",
"backtrace",
"(",
"stack",
"frames",
")",
"on",
"fatal",
"errors",
":",
"run",
"-",
"time",
"fatal",
"error",
"or",
"segmentation",
"fault",
".",
"Only",
"print",
"backtrace",
"if",
"environment",
"variable",
"UPC_BACKTRACE",
"is",
"set",
"to",
"1",
".",
"The",
"following",
"order",
"of",
"backtrace",
"capabilities",
"is",
"searched",
"and",
"executed",
".",
"(",
"1",
")",
"Use",
"GDB",
"for",
"backtrace",
"(",
"if",
"enabled",
")",
"(",
"2",
")",
"Use",
"GLIBC",
"backtrace",
"with",
"source",
"file",
"/",
"line",
"display",
"(",
"if",
"addr2line",
"is",
"available",
")",
"(",
"3",
")",
"Use",
"GLIBC",
"backtrace",
"with",
"raw",
"addresses",
"(",
"display",
"is",
"improved",
"if",
"-",
"rdynamic",
"option",
"is",
"supported",
"by",
"the",
"linker",
")"
] | void
gupcr_fatal_error_backtrace (void)
{
if (bt_enabled)
{
#ifdef HAVE_UPC_BACKTRACE_GDB
{
char *env;
const char *gdb;
char pid_buf[GUPCR_BACKTRACE_PID_BUFLEN];
int child_pid;
env = getenv (GUPCR_BACKTRACE_GDB_ENV);
if (!env || (strlen (env) == 0))
gdb = GUPCR_BACKTRACE_GDB;
else
gdb = (const char *) env;
if (strcmp (gdb, "none"))
{
const char *err_msg = 0;
char tmpf[PATH_MAX];
int fbt;
const char *btcmd = "backtrace 30\n";
fprintf (stderr, "Thread %d GDB backtrace:\n", MYTHREAD);
sprintf(pid_buf, "%d", getpid());
if ((fbt = gupcr_create_temp_file
("upc_bt_gdb.XXXXXX", tmpf, &err_msg)) == -1)
{
fprintf (stderr, "cannot open gdb command - %s\n", err_msg);
return;
}
if (write (fbt, btcmd, sizeof (btcmd)) == -1)
{
perror ("cannot write gdb command file for backtrace");
return;
}
if (close (fbt))
{
perror ("cannot close gdb command file for backtrace");
return;
}
child_pid = fork();
if (!child_pid)
{
dup2(2,1);
execlp(gdb, gdb, "-nx", "-batch", "-x", tmpf,
gupcr_abs_execname, pid_buf, NULL);
fprintf (stderr, "cannot start GDB - %s\n", gdb);
abort();
}
else
waitpid(child_pid,NULL,0);
unlink (tmpf);
return;
}
}
#endif
gupcr_backtrace ();
}
} | [
"void",
"gupcr_fatal_error_backtrace",
"(",
"void",
")",
"{",
"if",
"(",
"bt_enabled",
")",
"{",
"#ifdef",
"HAVE_UPC_BACKTRACE_GDB",
"{",
"char",
"*",
"env",
";",
"const",
"char",
"*",
"gdb",
";",
"char",
"pid_buf",
"[",
"GUPCR_BACKTRACE_PID_BUFLEN",
"]",
";",
"int",
"child_pid",
";",
"env",
"=",
"getenv",
"(",
"GUPCR_BACKTRACE_GDB_ENV",
")",
";",
"if",
"(",
"!",
"env",
"||",
"(",
"strlen",
"(",
"env",
")",
"==",
"0",
")",
")",
"gdb",
"=",
"GUPCR_BACKTRACE_GDB",
";",
"else",
"gdb",
"=",
"(",
"const",
"char",
"*",
")",
"env",
";",
"if",
"(",
"strcmp",
"(",
"gdb",
",",
"\"",
"\"",
")",
")",
"{",
"const",
"char",
"*",
"err_msg",
"=",
"0",
";",
"char",
"tmpf",
"[",
"PATH_MAX",
"]",
";",
"int",
"fbt",
";",
"const",
"char",
"*",
"btcmd",
"=",
"\"",
"\\n",
"\"",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"MYTHREAD",
")",
";",
"sprintf",
"(",
"pid_buf",
",",
"\"",
"\"",
",",
"getpid",
"(",
")",
")",
";",
"if",
"(",
"(",
"fbt",
"=",
"gupcr_create_temp_file",
"(",
"\"",
"\"",
",",
"tmpf",
",",
"&",
"err_msg",
")",
")",
"==",
"-1",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"err_msg",
")",
";",
"return",
";",
"}",
"if",
"(",
"write",
"(",
"fbt",
",",
"btcmd",
",",
"sizeof",
"(",
"btcmd",
")",
")",
"==",
"-1",
")",
"{",
"perror",
"(",
"\"",
"\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"close",
"(",
"fbt",
")",
")",
"{",
"perror",
"(",
"\"",
"\"",
")",
";",
"return",
";",
"}",
"child_pid",
"=",
"fork",
"(",
")",
";",
"if",
"(",
"!",
"child_pid",
")",
"{",
"dup2",
"(",
"2",
",",
"1",
")",
";",
"execlp",
"(",
"gdb",
",",
"gdb",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"tmpf",
",",
"gupcr_abs_execname",
",",
"pid_buf",
",",
"NULL",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"gdb",
")",
";",
"abort",
"(",
")",
";",
"}",
"else",
"waitpid",
"(",
"child_pid",
",",
"NULL",
",",
"0",
")",
";",
"unlink",
"(",
"tmpf",
")",
";",
"return",
";",
"}",
"}",
"#endif",
"gupcr_backtrace",
"(",
")",
";",
"}",
"}"
] | Backtrace on fatal errors. | [
"Backtrace",
"on",
"fatal",
"errors",
"."
] | [
"/* Which gdb to use? */",
"/* Get pid and name of the running program. */",
"/* Create temp file for GDB commands. */",
"/* If gdb failed to start */",
"/* GUPCR_BACKTRACE_GDB */",
"/* Simple backtrace only. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2b32d067dac486f2c8c20ee71e1dc85ac95d94e1 | tactcomplabs/clang-upc | runtime/libupc/portals4/gupcr_backtrace.c | [
"Apache-2.0"
] | C | gupcr_backtrace_restore_handlers | void | void
gupcr_backtrace_restore_handlers (void)
{
/* Don't handle any signals with backtrace code. Install
default handlers. */
signal (SIGABRT, SIG_DFL);
signal (SIGILL, SIG_DFL);
signal (SIGSEGV, SIG_DFL);
signal (SIGBUS, SIG_DFL);
signal (SIGFPE, SIG_DFL);
} | /**
* Restore default handlers.
*
* Has to be called once the run-time discovered
* a fatal error.
*/ | Restore default handlers.
Has to be called once the run-time discovered
a fatal error. | [
"Restore",
"default",
"handlers",
".",
"Has",
"to",
"be",
"called",
"once",
"the",
"run",
"-",
"time",
"discovered",
"a",
"fatal",
"error",
"."
] | void
gupcr_backtrace_restore_handlers (void)
{
signal (SIGABRT, SIG_DFL);
signal (SIGILL, SIG_DFL);
signal (SIGSEGV, SIG_DFL);
signal (SIGBUS, SIG_DFL);
signal (SIGFPE, SIG_DFL);
} | [
"void",
"gupcr_backtrace_restore_handlers",
"(",
"void",
")",
"{",
"signal",
"(",
"SIGABRT",
",",
"SIG_DFL",
")",
";",
"signal",
"(",
"SIGILL",
",",
"SIG_DFL",
")",
";",
"signal",
"(",
"SIGSEGV",
",",
"SIG_DFL",
")",
";",
"signal",
"(",
"SIGBUS",
",",
"SIG_DFL",
")",
";",
"signal",
"(",
"SIGFPE",
",",
"SIG_DFL",
")",
";",
"}"
] | Restore default handlers. | [
"Restore",
"default",
"handlers",
"."
] | [
"/* Don't handle any signals with backtrace code. Install\n default handlers. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.