def writeMetaData(SOS, frame, adios_group, fd): global config global prog_names global comm_ranks global value_names global threads global metadata_keys # Get the frame-specific metadata... # (there might not be any after frame 0) start = time.time() sqlValsToColByRank = "select prog_name, comm_rank, value_name, value from viewCombined where value_name like 'TAU_METADATA:%' and frame = " + str( frame) + " order by prog_name, comm_rank, value_name;" results, col_names = queryAllAggregators(sqlValsToColByRank) end = time.time() print(end - start), "seconds for metadata query" for r in results: prog_name = str(r[0]) comm_rank = str(r[1]) value_name = str(r[2]) value = str(r[3]) if value == "": print "skipping", value_name continue if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the metadata name. tokens = value_name.split(":", 2) thread = tokens[1] metadata_key = tokens[2] if thread not in threads: threads[thread] = len(threads) attr_name = "MetaData:" + str( prog_names[prog_name] ) + ":" + comm_rank + ":" + thread + ":" + metadata_key ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, value, "") return
def writeCounterData(SOS, frame, adios_group, fd): global config global prog_names global comm_ranks global value_names global threads global counters # Get the frame-specific counter data... start = time.time() sqlValsToColByRank = "select value_name, coalesce(value,0.0), prog_name, comm_rank from viewCombined where value_name like 'TAU_COUNTER:%' and frame = " + str( frame) + " order by prog_name, comm_rank, value_name;" results, col_names = queryAllAggregators(sqlValsToColByRank) end = time.time() print(end - start), "seconds for counter query" values_array = np.zeros(shape=(len(results), 5), dtype=np.float) index = 0 for r in results: value_name = str(r[0]) value = float(r[1]) prog_name = str(r[2]) comm_rank = str(r[3]) if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the counter name. tokens = value_name.split(":", 2) thread = tokens[1] counter = tokens[2] if thread not in threads: threads[thread] = len(threads) if counter not in counters: attr_name = "counter " + str(len(counters)) counters[counter] = len(counters) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, counter, "") values_array[index][0] = int(prog_names[prog_name]) values_array[index][1] = int(comm_ranks[comm_rank]) values_array[index][2] = int(threads[thread]) values_array[index][3] = counters[counter] values_array[index][4] = float(value) index = index + 1 # now that the data is queried and in arrays, write it out to the file # initialize the ADIOS data if config["output_adios"]: # write the adios ad.write_int(fd, "program_count", len(prog_names)) ad.write_int(fd, "comm_rank_count", len(comm_ranks)) ad.write_int(fd, "thread_count", len(threads)) ad.write_int(fd, "metric_count", len(metrics)) ad.write_int(fd, "counter_count", len(counters)) ad.write_int(fd, "counter_value_count", len(results)) ad.write(fd, "counter_values", values_array) return
def writeTimerData(SOS, frame, adios_group, fd): global config global prog_names global comm_ranks global value_names global threads global groups global timers global event_types global validation # Get the frame-specific timer data... start = time.time() #sqlValsToColByRank = "select prog_name, comm_rank, value, value_name from viewCombined where (value_name like 'TAU_EVENT_ENTRY%' or value_name like 'TAU_EVENT_EXIT%') and frame = " + str(frame) + " order by value;" #results, col_names = queryAllAggregators(sqlValsToColByRank) pub_filter = "" val_filter = "TAU_EVENT" frame_start = frame frame_depth = 1 results, col_names = queryAllAggregatorsCache(pub_filter, val_filter, frame_start, frame_depth) end = time.time() print((end - start), "seconds for event query") timer_values_array = np.zeros(shape=(len(results), 6), dtype=np.uint64) counter_values_array = np.zeros(shape=(len(results), 6), dtype=np.uint64) comm_values_array = np.zeros(shape=(len(results), 8), dtype=np.uint64) timer_index = 0 counter_index = 0 comm_index = 0 prog_name_index = column_map["prog_name"] comm_rank_index = column_map["comm_rank"] value_name_index = column_map["val_name"] value_index = column_map["val"] frame_index = column_map["frame"] time_index = column_map["time_pack"] results = sorted(results, key=itemgetter(value_index)) total_valid = len(results) for r in results: prog_name = str(r[prog_name_index]) comm_rank = str(r[comm_rank_index]) value = int(r[value_index]) value_name = str(r[value_name_index]) row_frame = str(r[frame_index]) #print row_frame, prog_name, comm_rank, value_name if int(row_frame) != frame: total_valid = total_valid - 1 continue if prog_name not in validation: validation[prog_name] = {} if comm_rank not in validation[prog_name]: validation[prog_name][comm_rank] = {} if "TAU_EVENT_ENTRY" in value_name or "TAU_EVENT_EXIT" in value_name: if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the event name tokens = value_name.split(":", 2) event_type = tokens[0].replace("TAU_EVENT_", "") if event_type not in event_types: attr_name = "event_type " + str(len(event_types)) event_types[event_type] = len(event_types) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, event_type, "") thread = int(tokens[1]) if thread not in validation[prog_name][comm_rank]: validation[prog_name][comm_rank][thread] = [] timer = tokens[2] if thread not in threads: threads[thread] = len(threads) if timer not in timers: attr_name = "timer " + str(len(timers)) timers[timer] = len(timers) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, timer, "") if "MPI_Send" in value_name: print(value_name, thread) if "MPI_Recv" in value_name: print(value_name, thread) timer_values_array[timer_index][0] = int(prog_names[prog_name]) timer_values_array[timer_index][1] = int(comm_ranks[comm_rank]) timer_values_array[timer_index][2] = int(thread) timer_values_array[timer_index][3] = int(event_types[event_type]) timer_values_array[timer_index][4] = int(timers[timer]) timer_values_array[timer_index][5] = int(value) timer_index = timer_index + 1 if "TAU_EVENT_ENTRY" in value_name: validation[prog_name][comm_rank][thread].append(timer) else: if len(validation[prog_name][comm_rank][thread]) == 0: print("VALIDATION ERROR! empty stack", prog_name, comm_rank, thread, timer) #sys.exit() else: current_timer = validation[prog_name][comm_rank][ thread].pop() if current_timer != timer: print("VALIDATION ERROR!", value, prog_names[prog_name], comm_rank, thread, timers[timer], "!= current: ", timers[current_timer]) elif "TAU_EVENT_COUNTER" in value_name: # convert the timestamp from seconds to usec timestamp = float(r[time_index]) * 1000000 if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the event name tokens = value_name.split(":", 2) thread = tokens[1] counter = tokens[2] if thread not in threads: threads[thread] = len(threads) if counter not in counters: attr_name = "counter " + str(len(counters)) counters[counter] = len(counters) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, counter, "") counter_values_array[counter_index][0] = int(prog_names[prog_name]) counter_values_array[counter_index][1] = int(comm_ranks[comm_rank]) counter_values_array[counter_index][2] = int(thread) counter_values_array[counter_index][3] = int(counters[counter]) counter_values_array[counter_index][4] = int(value) counter_values_array[counter_index][5] = int(timestamp) counter_index = counter_index + 1 elif "TAU_EVENT_SEND" in value_name or "TAU_EVENT_RECV" in value_name: if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the event name tokens = value_name.split(":", 2) event_type = tokens[0].replace("TAU_EVENT_", "") if event_type not in event_types: attr_name = "event_type " + str(len(event_types)) event_types[event_type] = len(event_types) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, event_type, "") tokens = value_name.split(":", 4) thread = tokens[1] tag = tokens[2] partner = tokens[3] num_bytes = tokens[4] if thread not in threads: threads[thread] = len(threads) comm_values_array[comm_index][0] = int(prog_names[prog_name]) comm_values_array[comm_index][1] = int(comm_ranks[comm_rank]) comm_values_array[comm_index][2] = int(thread) comm_values_array[comm_index][3] = int(event_types[event_type]) comm_values_array[comm_index][4] = int(tag) comm_values_array[comm_index][5] = int(partner) comm_values_array[comm_index][6] = int(num_bytes) comm_values_array[comm_index][7] = int(value) comm_index = comm_index + 1 else: print("ERROR! unknown event:", prog_name, comm_rank, value_name) # now that the data is queried and in arrays, write it out to the file # initialize the ADIOS data if config["output_adios"] and (timer_index > 0 or counter_index > 0 or comm_index > 0): #if config["output_adios"]: # write the adios ad.write_int(fd, "program_count", len(prog_names)) ad.write_int(fd, "comm_rank_count", len(comm_ranks)) ad.write_int(fd, "thread_count", len(threads)) ad.write_int(fd, "timer_count", len(timers)) ad.write_int(fd, "event_type_count", len(event_types)) ad.write_int(fd, "timer_event_count", timer_index) ad.write_int(fd, "counter_count", len(counters)) ad.write_int(fd, "counter_event_count", counter_index) ad.write_int(fd, "comm_count", comm_index) np.resize(timer_values_array, (timer_index, 6)) np.resize(counter_values_array, (counter_index, 6)) np.resize(comm_values_array, (comm_index, 8)) ad.write(fd, "event_timestamps", timer_values_array) ad.write(fd, "counter_values", counter_values_array) ad.write(fd, "comm_timestamps", comm_values_array) return total_valid
def writeMetaData(SOS, frame, adios_group, fd): global config global prog_names global comm_ranks global value_names global threads global metadata_keys global column_map # Get the frame-specific metadata... # (there might not be any after frame 0) start = time.time() # sqlValsToColByRank = "select prog_name, comm_rank, value_name, value from viewCombined where value_name like 'TAU_METADATA:%' and frame = " + str(frame) + " order by prog_name, comm_rank, value_name;" #results, col_names = queryAllAggregators(sqlValsToColByRank) pub_filter = "" val_filter = "TAU_Metadata" frame_start = frame frame_depth = 1 results, col_names = queryAllAggregatorsCache(pub_filter, val_filter, frame_start, frame_depth) end = time.time() print((end - start), "seconds for metadata query") prog_name_index = column_map["prog_name"] comm_rank_index = column_map["comm_rank"] value_name_index = column_map["val_name"] value_index = column_map["val"] frame_index = column_map["frame"] total_valid = len(results) for r in results: prog_name = str(r[prog_name_index]) comm_rank = str(r[comm_rank_index]) value_name = str(r[value_name_index]) value = str(r[value_index]) this_frame = int(r[frame_index]) if this_frame != frame: total_valid = total_valid - 1 continue if value == "": #print "skipping", value_name continue if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the metadata name. tokens = value_name.split(":", 2) thread = tokens[1] metadata_key = tokens[2] if thread not in threads: threads[thread] = len(threads) attr_name = "MetaData:" + str( prog_names[prog_name] ) + ":" + comm_rank + ":" + thread + ":" + metadata_key #print attr_name,value ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, value, "") return total_valid
if len(sys.argv) > 1: method = sys.argv[1] if len(sys.argv) > 2: init = sys.argv[2] ## Init ad.allocate_buffer(ad.BUFFER_ALLOC_WHEN.NOW, 10) ad.init_noxml(MPI.COMM_WORLD) g = ad.declare_group("temperature", "", 1) ad.define_var(g, "NX", "", ad.DATATYPE.integer, "", "", "") ad.define_var(g, "size", "", ad.DATATYPE.integer, "", "", "") ad.define_var(g, "temperature", "", ad.DATATYPE.double, "size,NX", "size,NX", "0,0") msg = str(datetime.datetime.now()) ad.define_attribute(g, "datetime", "", ad.DATATYPE.string, msg, "") print ">>> Method:", method, init ad.select_method(g, method, init, "") ## Writing for i in range(5): print ">>> step:", i fd = ad.open("temperature", "temp.bp", "a") NX = 10 size = 2 groupsize = 4 + 4 + 8 * size * NX t = np.array(range(NX * size), dtype=np.float64) + 100 * i tt = t.reshape((size, NX)) ad.set_group_size(fd, groupsize) ad.write_int(fd, "NX", NX)
def writeCommData(SOS, frame, adios_group, fd): global config global prog_names global comm_ranks global value_names global threads global groups global timers global event_types # Get the frame-specific timer data... start = time.time() sqlValsToColByRank = "select prog_name, comm_rank, value, value_name from viewCombined where (value_name like 'TAU_EVENT_SEND%' or value_name like 'TAU_EVENT_RECV%') and frame = " + str( frame) + " order by value;" results, col_names = queryAllAggregators(sqlValsToColByRank) end = time.time() print(end - start), "seconds for communication query" values_array = np.zeros(shape=(len(results), 8), dtype=np.uint64) index = 0 for r in results: prog_name = str(r[0]) comm_rank = str(r[1]) value = long(r[2]) value_name = str(r[3]) if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the event name tokens = value_name.split(":", 2) event_type = tokens[0].replace("TAU_EVENT_", "") if event_type not in event_types: attr_name = "event_type " + str(len(event_types)) event_types[event_type] = len(event_types) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, event_type, "") tokens = value_name.split(":", 4) thread = tokens[1] tag = tokens[2] partner = tokens[3] num_bytes = tokens[4] if thread not in threads: threads[thread] = len(threads) values_array[index][0] = long(prog_names[prog_name]) values_array[index][1] = long(comm_ranks[comm_rank]) values_array[index][2] = long(threads[thread]) values_array[index][3] = long(event_types[event_type]) values_array[index][4] = long(tag) values_array[index][5] = long(partner) values_array[index][6] = long(num_bytes) values_array[index][7] = long(value) index = index + 1 # now that the data is queried and in arrays, write it out to the file # initialize the ADIOS data if config["output_adios"]: # write the adios ad.write_int(fd, "program_count", len(prog_names)) ad.write_int(fd, "comm_rank_count", len(comm_ranks)) ad.write_int(fd, "thread_count", len(threads)) ad.write_int(fd, "comm_count", len(results)) if len(results) > 0: ad.write(fd, "comm_timestamps", values_array) return
def writeCounterData(SOS, frame, adios_group, fd): global config global prog_names global comm_ranks global value_names global threads global counters # Get the frame-specific counter data... start = time.time() sqlValsToColByRank = "select prog_name, comm_rank, value, value_name, time_pack from viewCombined where (value_name like 'TAU_EVENT_COUNTER%') and frame = " + str( frame) + " order by time_pack;" results, col_names = queryAllAggregators(sqlValsToColByRank) end = time.time() print(end - start), "seconds for event query" values_array = np.zeros(shape=(len(results), 6), dtype=np.uint64) index = 0 for r in results: prog_name = str(r[0]) comm_rank = str(r[1]) value = long(r[2]) value_name = str(r[3]) # convert the timestamp from seconds to usec timestamp = float(r[4]) * 1000000 if prog_name not in prog_names: attr_name = "program_name " + str(len(prog_names)) prog_names[prog_name] = len(prog_names) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, prog_name, "") # may not be necessary... if comm_rank not in comm_ranks: comm_ranks[comm_rank] = len(comm_ranks) # tease apart the event name tokens = value_name.split(":", 2) thread = tokens[1] counter = tokens[2] if thread not in threads: threads[thread] = len(threads) if counter not in counters: attr_name = "counter " + str(len(counters)) counters[counter] = len(counters) ad.define_attribute(adios_group, attr_name, "", ad.DATATYPE.string, counter, "") values_array[index][0] = long(prog_names[prog_name]) values_array[index][1] = long(comm_ranks[comm_rank]) values_array[index][2] = long(threads[thread]) values_array[index][3] = long(counters[counter]) values_array[index][4] = long(value) values_array[index][5] = long(timestamp) index = index + 1 # now that the data is queried and in arrays, write it out to the file # initialize the ADIOS data if config["output_adios"]: # write the adios # these get written when the comm data is written # ad.write_int(fd, "program_count", len(prog_names)) # ad.write_int(fd, "comm_rank_count", len(comm_ranks)) # ad.write_int(fd, "thread_count", len(threads)) ad.write_int(fd, "counter_count", len(counters)) ad.write_int(fd, "counter_event_count", len(results)) if len(results) > 0: ad.write(fd, "counter_values", values_array) return
if len(sys.argv) > 1: method = sys.argv[1] if len(sys.argv) > 2: init = sys.argv[2] ## Init ad.allocate_buffer (ad.BUFFER_ALLOC_WHEN.NOW, 10); ad.init_noxml(MPI.COMM_WORLD) g = ad.declare_group("temperature", "", 1) ad.define_var(g, "NX", "", ad.DATATYPE.integer, "", "", "") ad.define_var(g, "size", "", ad.DATATYPE.integer, "", "", "") ad.define_var(g, "temperature", "", ad.DATATYPE.double, "size,NX", "size,NX", "0,0") msg = str(datetime.datetime.now()) ad.define_attribute(g, "datetime", "", ad.DATATYPE.string, msg, "") print ">>> Method:", method, init ad.select_method(g, method, init, "") ## Writing for i in range(5): print ">>> step:", i fd = ad.open("temperature", "temp.bp", "a") NX = 10 size = 2 groupsize = 4 + 4 + 8 * size * NX t = np.array(range(NX*size), dtype=np.float64) + 100*i tt = t.reshape((size, NX)) ad.set_group_size(fd, groupsize) ad.write_int(fd, "NX", NX)