Ejemplo n.º 1
0
static int
run_subcommand(const char *command,
	       const struct ratbag_cmd *cmd,
	       struct ratbag *ratbag,
	       struct ratbag_cmd_options *options,
	       int argc, char **argv)
{
	const struct ratbag_cmd *sub = cmd->subcommands[0];
	int i = 0;
	int rc;

	while (sub) {
		if (streq(command, sub->name)) {
			rc = fill_options(ratbag, options,
					  sub->flags,
					  &argc,
					  argv);
			if (rc != SUCCESS)
				return rc;

			argc--;
			argv++;
			return sub->cmd(sub, ratbag, options, argc, argv);
		}
		sub = cmd->subcommands[i++];
	}

	error("Invalid subcommand '%s'\n", command);
	return ERR_USAGE;
}
Ejemplo n.º 2
0
CubinResult ptx_to_cubin(const std::string& ptx,
                         const unsigned block_size,
                         const CudaMgr_Namespace::CudaMgr* cuda_mgr) {
  CHECK(!ptx.empty());
  CHECK(cuda_mgr->getDeviceCount() > 0);
  static_cast<const CudaMgr_Namespace::CudaMgr*>(cuda_mgr)->setContext(0);
  std::vector<CUjit_option> option_keys;
  std::vector<void*> option_values;
  fill_options(option_keys, option_values, block_size);
  CHECK_EQ(option_values.size(), option_keys.size());
  unsigned num_options = option_keys.size();
  CUlinkState link_state;
  checkCudaErrors(cuLinkCreate(num_options, &option_keys[0], &option_values[0], &link_state));

  boost::filesystem::path gpu_rt_path{mapd_root_abs_path()};
  gpu_rt_path /= "QueryEngine";
  gpu_rt_path /= "cuda_mapd_rt.a";
  if (!boost::filesystem::exists(gpu_rt_path)) {
    throw std::runtime_error("MapD GPU runtime library not found at " + gpu_rt_path.string());
  }

  if (!gpu_rt_path.empty()) {
    // How to create a static CUDA library:
    // 1. nvcc -std=c++11 -arch=sm_30 --device-link -c [list of .cu files]
    // 2. nvcc -std=c++11 -arch=sm_30 -lib [list of .o files generated by step 1] -o [library_name.a]
    checkCudaErrors(cuLinkAddFile(
        link_state, CU_JIT_INPUT_LIBRARY, gpu_rt_path.c_str(), num_options, &option_keys[0], &option_values[0]));
  }
  checkCudaErrors(cuLinkAddData(link_state,
                                CU_JIT_INPUT_PTX,
                                static_cast<void*>(const_cast<char*>(ptx.c_str())),
                                ptx.length() + 1,
                                0,
                                num_options,
                                &option_keys[0],
                                &option_values[0]));
  void* cubin{nullptr};
  size_t cubinSize{0};
  checkCudaErrors(cuLinkComplete(link_state, &cubin, &cubinSize));
  CHECK(cubin);
  CHECK_GT(cubinSize, size_t(0));
  return {cubin, option_keys, option_values, link_state};
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	options_t options;
	fill_options(options);

	test_cuda test_cuda_instance(options);

	//std::cout << "-- test1 : Source FFT --" << std::endl;
	//test_cuda_instance.test1();

    //std::cout << "-- test2 : Frequency domain correlation --" << std::endl;

	wsgc_complex *signal_samples;
    GoldCodeGenerator gc_generator(options.gc_nb_stages, options.nb_message_symbols, options.nb_service_symbols, 0, options.g1_poly_powers, options.g2_poly_powers);
    SimulatedSource message_source(gc_generator, options.prn_list, options.f_sampling, options.f_chip, options.f_tx, options.code_shift);
    CodeModulator_BPSK code_modulator;
    message_source.set_code_modulator(&code_modulator);
    message_source.create_samples(&signal_samples);

    //test_cuda_instance.test2(message_source.get_samples(), gc_generator, code_modulator);

    //std::cout << "-- test3 : mul_ifft algo --" << std::endl;
    //test_cuda_instance.test3(message_source.get_samples(), gc_generator, code_modulator);

    //std::cout << "-- test4 : FFT correlation --" << std::endl;
    //test_cuda_instance.test4(message_source.get_samples(), gc_generator, code_modulator);

    //std::cout << "-- test repeat range : repeat iterator --" << std::endl;
    //test_cuda_instance.test_repeat_range();

    std::cout << "-- test repeat values: repeat values iterator --" << std::endl;
    test_cuda_instance.test_repeat_values();

    //std::cout << "-- test shifted range: shifted range iterator --" << std::endl;
    //test_cuda_instance.test_shift_range();

    std::cout << "-- test strided shifted range: shifted range iterator --" << std::endl;
    test_cuda_instance.test_strided_shifted_range();

    //std::cout << "-- test shifted by segments range: shifted by segments range iterator --" << std::endl;
    //test_cuda_instance.test_shifted_by_segments_range();

    //std::cout << "-- test strided folded range --" << std::endl;
    //test_cuda_instance.test_strided_folded_range();

    std::cout << "-- test repeated incremental range --" << std::endl;
    test_cuda_instance.test_repeat_incremental_range();

    std::cout << "-- test repeated shifted range --" << std::endl;
    test_cuda_instance.test_repeat_shifted_range();

    std::cout << "-- test repeating repeated shifted range --" << std::endl;
    test_cuda_instance.test_repeat_2_shifted_range();

    std::cout << "-- test ifft averaging range --" << std::endl;
    test_cuda_instance.test_ifft_averaging_range();

    std::cout << "-- test ifft averaged range --" << std::endl;
    test_cuda_instance.test_ifft_averaged_range();

    //std::cout << "-- test5 : simple time correlation --" << std::endl;
    //test_cuda_instance.test_simple_time_correlation(message_source.get_samples(), gc_generator, code_modulator);

    //std::cout << "-- test6 : multiple time correlation --" << std::endl;
    //options.prn_list.push_back(1);
    //options.prn_list.push_back(2);
    //test_cuda_instance.test_multiple_time_correlation(message_source.get_samples(), gc_generator, code_modulator);

    WSGC_FFTW_FREE(signal_samples);

    return 0;
}