int main(int argc, char* argv[]) { int size; int i, j; /* loop counters */ if (argc < 2) { fprintf(stderr, "usage: mandelzoom <size>\n"); exit(1); } size = atoi(argv[1]); fprintf(stdout, "got size %s, converted to %d.\n", argv[1], size); pic = make_pic(size); acorner = .26; bcorner = 0; extent = .01; gap = extent / size; for (i=0; i<size; i++) for (j=0; j<size; j++) pic[i][j] = compute_value((gap * i) + acorner, (gap * j) + bcorner); for (i=0; i<size; i++) for (j=0; j<size; j++) if (pic[i][j] != 1000) printf("pic[%3d][%3d] = %d\n", i, j, pic[i][j]); return 0; }
slice_byrange_iterator( iterator_type first, iterator_type last, byrng_function f, slicer s) : m_f( f), m_slicer( s), m_first( first), m_last( last), m_val( result_type() ), m_processed_last( first == last) { compute_value(); }
slice_byeach_iterator( iterator first, iterator last, byeach_function f, slicer s, dest_value_type init) : m_f( f), m_slicer( s), m_first( first), m_last( last), m_init( init), m_val( init), m_processed_last( first == last) { compute_value(); }
multi_byeach_iterator( iterator first, iterator last, multirange_function f) : m_f( f), m_first( first), m_last( last), m_val(), m_idx( 0), m_processed_last( first == last) { compute_value(); }
self_type& operator++() { compute_value(); return *this; }
void myinit(int argc, char **argv) { int status, i; char * p; char * p_dbg; char * cmdline; char * v; const char * rankA[] = {"PMI_RANK", "OMPI_COMM_WORLD_RANK", "MV2_COMM_WORLD_RANK", NULL}; const char * sizeA[] = {"PMI_SIZE", "OMPI_COMM_WORLD_SIZE", "MV2_COMM_WORLD_SIZE", NULL}; struct timeval tv; struct utsname u; uuid_t uuid; unsetenv("LD_PRELOAD"); /* Stop tracking if XALT is turned off */ p_dbg = getenv("XALT_TRACING"); if (p_dbg && strcmp(p_dbg,"yes") == 0) { xalt_tracing = 1; errfd = dup(STDERR_FILENO); } v = getenv("XALT_EXECUTABLE_TRACKING"); if (xalt_tracing) { abspath(path,sizeof(path)); FULL_DEBUG3(stderr,"myinit(%s,%s):\n Test for XALT_EXECUTABLE_TRACKING: \"%s\"\n", STR(STATE),path,(v != NULL) ? v : "(NULL)"); } if (!v || strcmp(v,"yes") != 0) { FULL_DEBUG0(stderr," XALT_EXECUTABLE_TRACKING is off -> exiting\n\n"); return; } v = getenv("__XALT_INITIAL_STATE__"); FULL_DEBUG2(stderr," Test for __XALT_INITIAL_STATE__: \"%s\", STATE: \"%s\"\n", (v != NULL) ? v : "(NULL)", STR(STATE)); /* Stop tracking if any myinit routine has been called */ if (v && (strcmp(v,STR(STATE)) != 0)) { FULL_DEBUG2(stderr," __XALT_INITIAL_STATE__ has a value: \"%s\" -> and it is different from STATE: \"%s\" exiting\n\n",v,STR(STATE)); return; } /* Stop tracking if my mpi rank is not zero */ my_rank = compute_value(rankA); FULL_DEBUG1(stderr," Test for rank == 0, rank: %ld\n",my_rank); if (my_rank > 0L) { FULL_DEBUG0(stderr," MPI Rank is not zero -> exiting\n\n"); return; } my_size = compute_value(sizeA); if (my_size < 1L) my_size = 1L; errno = 0; if (uname(&u) != 0) { perror("uname"); exit(EXIT_FAILURE); } /* Get full absolute path to executable */ abspath(path,sizeof(path)); reject_flag = reject(path, u.nodename); FULL_DEBUG3(stderr," Test for path and hostname, hostname: %s, path: %s, reject: %d\n", u.nodename, path, reject_flag); if (reject_flag) { FULL_DEBUG0(stderr," reject_flag is true -> exiting\n\n"); return; } setenv("__XALT_INITIAL_STATE__",STR(STATE),1); errfd = dup(STDERR_FILENO); syshost = xalt_syshost(); /* Build a json version of the user's command line. */ /* Calculate size of buffer*/ int sz = 0; for (i = 0; i < argc; ++i) sz += strlen(argv[i]); /* this size formula uses 3 facts: * 1) if every character was a utf-16 character that is four bytes converts to 12 (sz*3) * 2) Each entry has two quotes and a comma (argc*3) * 3) There are two square brackets and a null byte (+3) */ sz = sz*3 + argc*3 + 3; usr_cmdline = (char *) malloc(sz); p = &usr_cmdline[0]; *p++ = '['; for (i = 0; i < argc; ++i) { *p++ = '"'; const char* qs = xalt_quotestring(argv[i]); int len = strlen(qs); memcpy(p,qs,len); p += len; *p++= '"'; *p++= ','; } *--p = ']'; *++p = '\0'; if (p > &usr_cmdline[sz]) { fprintf(stderr,"XALT: Failure in building user command line json string!\n"); reject_flag = 1; return; } uuid_generate(uuid); uuid_unparse_lower(uuid,uuid_str); gettimeofday(&tv,NULL); start_time = tv.tv_sec + 1.e-6*tv.tv_usec; asprintf(&cmdline, "LD_LIBRARY_PATH=%s PATH=/usr/bin:/bin %s --syshost \"%s\" --start \"%.3f\" --end 0 --exec \"%s\" --ntasks %ld --uuid \"%s\" '%s'", SYS_LD_LIB_PATH, PREFIX "/libexec/xalt_run_submission", syshost, start_time, path, my_size, uuid_str, usr_cmdline); DEBUG1(stderr, " Start Tracking: %s\nEnd myinit()\n",cmdline); system(cmdline); free(cmdline); }