void jag_store::setup_testing() { setup_conduit(); setup_binary(); }
void jag_store::setup( data_reader_jag_conduit_hdf5 *reader, bool num_stores, int my_rank) { double tm1 = get_time(); m_master = m_comm->am_world_master(); options *opts = options::get(); m_reader = reader; m_max_samples = INT_MAX; if (opts->has_int("max_samples")) { m_max_samples = (size_t)opts->get_int("max_samples"); } bool has_conduit_filenames = false; if (opts->has_string("conduit_filelist")) { std::string f = opts->get_string("conduit_filelist"); std::ifstream in(f.c_str()); if (!in) { throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: failed to open " + f + " for reading"); } std::string line; while (getline(in, line)) { m_conduit_filenames.push_back(line); } in.close(); if (m_max_samples < m_conduit_filenames.size()) { m_conduit_filenames.resize(m_max_samples); } has_conduit_filenames = true; } if (m_image_size == 0) { throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: image_size = 0; probably set_image_size() has not been called"); } // optionally build an index file, then exit. Each line of the file will // contain a conduit filename, followed by the valid sample_ids in // the conduit file if (opts->has_string("build_conduit_index")) { if (! has_conduit_filenames) { throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --conduit_filenames=<string> on the cmd line when building a conduit index"); } build_conduit_index(m_conduit_filenames); exit(0); } load_variable_names(); build_data_sizes(); report_linearized_sizes(); allocate_memory(); load_normalization_values(); if (!opts->has_int("mode")) { throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --mode=<int> on cmd line, where <int> is 1 (to use conduit files) or 2 or 3 (for testing) (to use binary files)"); } m_mode = opts->get_int("mode"); if (! (m_mode == 1 || m_mode == 2 || m_mode == 3)) { throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --mode=<int> on cmd line, where <int> is 1 (to use conduit files) or 2 (to use binary files); or 4 (for testing) you passed: " + std::to_string(m_mode)); } if (m_master) std::cerr << "Running in mode: " << m_mode << "\n"; // optionally convert conduit files to our binary format, then exit if (opts->has_string("convert_conduit")) { if (! has_conduit_filenames) { throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --conduit_filenames=<string> on the cmd line when converting conduit filenames to binary"); } setup_conduit(); convert_conduit_to_binary(m_conduit_filenames); exit(0); } if (m_mode == 1) { setup_conduit(); } else if (m_mode == 2) { setup_binary(); } else { setup_testing(); } if (m_master) { std::cerr << "jag_store::setup time: " << get_time() - tm1 << "; num samples: " << m_num_samples << std::endl; } if (m_mode == 3) { test_converted_files(); m_comm->global_barrier(); exit(0); } // optionally compute min/max values, then exit. // This is only needed for one-time computation of normalization values if (opts->has_string("compute_min_max")) { compute_min_max(); exit(0); } // optionally check bandwidth (sort of), then exit if (opts->has_int("bandwidth")) { if (m_mode == 0) { compute_bandwidth(); } else { compute_bandwidth_binary(); } exit(0); } }
enum ia_css_err sh_css_load_firmware(const char *fw_data, unsigned int fw_size) { unsigned i; struct ia_css_fw_info *binaries; struct sh_css_fw_bi_file_h *file_header; bool valid_firmware = false; firmware_header = (struct firmware_header *)fw_data; file_header = &firmware_header->file_header; binaries = &firmware_header->binary_header; strncpy(FW_rel_ver_name, file_header->version, min(sizeof(FW_rel_ver_name), sizeof(file_header->version)) - 1); valid_firmware = sh_css_check_firmware_version(fw_data); if (!valid_firmware) { #if !defined(HRT_RTL) IA_CSS_ERROR("CSS code version (%s) and firmware version (%s) mismatch!", file_header->version, release_version); return IA_CSS_ERR_VERSION_MISMATCH; #endif } else { IA_CSS_LOG("successfully load firmware version %s", release_version); } /* some sanity checks */ if (!fw_data || fw_size < sizeof(struct sh_css_fw_bi_file_h)) return IA_CSS_ERR_INTERNAL_ERROR; if (file_header->h_size != sizeof(struct sh_css_fw_bi_file_h)) return IA_CSS_ERR_INTERNAL_ERROR; sh_css_num_binaries = file_header->binary_nr; /* Only allocate memory for ISP blob info */ if (sh_css_num_binaries > NUM_OF_SPS) { sh_css_blob_info = kmalloc( (sh_css_num_binaries - NUM_OF_SPS) * sizeof(*sh_css_blob_info), GFP_KERNEL); if (sh_css_blob_info == NULL) return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; } else { sh_css_blob_info = NULL; } fw_minibuffer = kzalloc(sh_css_num_binaries * sizeof(struct fw_param), GFP_KERNEL); if (fw_minibuffer == NULL) return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; for (i = 0; i < sh_css_num_binaries; i++) { struct ia_css_fw_info *bi = &binaries[i]; /* note: the var below is made static as it is quite large; if it is not static it ends up on the stack which could cause issues for drivers */ static struct ia_css_blob_descr bd; enum ia_css_err err; err = sh_css_load_blob_info(fw_data, bi, &bd, i); if (err != IA_CSS_SUCCESS) return IA_CSS_ERR_INTERNAL_ERROR; if (bi->blob.offset + bi->blob.size > fw_size) return IA_CSS_ERR_INTERNAL_ERROR; if (bi->type == ia_css_sp_firmware) { if (i != SP_FIRMWARE) return IA_CSS_ERR_INTERNAL_ERROR; err = setup_binary(bi, fw_data, &sh_css_sp_fw, i); if (err != IA_CSS_SUCCESS) return err; } else { /* All subsequent binaries (including bootloaders) (i>NUM_OF_SPS) are ISP firmware */ if (i < NUM_OF_SPS) return IA_CSS_ERR_INTERNAL_ERROR; if (bi->type != ia_css_isp_firmware) return IA_CSS_ERR_INTERNAL_ERROR; if (sh_css_blob_info == NULL) /* cannot happen but KW does not see this */ return IA_CSS_ERR_INTERNAL_ERROR; sh_css_blob_info[i - NUM_OF_SPS] = bd; } } return IA_CSS_SUCCESS; }