18 #if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32)) 19 #ifdef BUILD_CROCK_DLL 20 #define CROCK_API __declspec(dllexport) 22 #define CROCK_API __declspec(dllimport) 24 #elif defined(__GNUC__) 25 #define CROCK_API __attribute__((__visibility__("default"))) 28 #ifdef CROCK_SUPPRESS_API 36 #define ROCK_MALLOC __attribute__((__malloc__)) 37 #define ROCK_PURE __attribute__((__pure__)) 38 #define ROCK_CONST __attribute__((__const__)) 39 #define ROCK_NODISCARD __attribute__((__warn_unused_result__)) 40 #define ROCK_UNUSED __attribute__((__unused__)) 45 #define ROCK_NODISCARD 50 #define ROCK_MASK_BLT_VAR_UZ 0x00000001 51 #define ROCK_MASK_BLT_TAYLOR 0x00000002 53 #define ROCK_MASK_BLT_CALI_CYC_PHASE 0x00000004 56 #define ROCK_MASK_BLT_CALI_GC_AZI 0x00000008 60 #define ROCK_MASK_BLT_CALI_GC_R 0x00000010 63 #define ROCK_MASK_BLT_B_RF_PERP 0x00000020 66 #define ROCK_MASK_BLT_DOPPLER ROCK_MASK_BLT_B_RF_PERP 68 #define ROCK_MASK_BLT_TREAT_BEAM_INIT_AS_RAW_IMPORT 0x00010000 79 #define ROCK_MASK_BLT_SRC_MONOHARM 0x40000000 86 #define ROCK_MASK_BLT_MONOGC 0x80000000 89 #define ROCK_MASK_BLT_DEBUG ROCK_MASK_BLT_MONOGC 94 #define ROCK_MASK_BLT_ALL_FEATURES \ 95 (ROCK_MASK_BLT_VAR_UZ | ROCK_MASK_BLT_TAYLOR \ 96 | ROCK_MASK_BLT_CALI_CYC_PHASE | ROCK_MASK_BLT_CALI_GC_AZI \ 97 | ROCK_MASK_BLT_CALI_GC_R | ROCK_MASK_BLT_B_RF_PERP) 107 #define ROCK_FOREACH(X) for (size_t i##X = 0; i##X < (dim_##X); ++i##X) 110 #define ROCK_FOREACH_1(X) for (size_t i##X = 1; i##X < (dim_##X); ++i##X) 113 #define ROCK_IF_RETURN(IF_VAL, RET_VAL) \ 130 const size_t *restrict shape
134 #define CR_NUMA_BLESS(type, buf, ...) \ 136 (buf), (size_t)sizeof(type), \ 137 (size_t)(sizeof((size_t[]){__VA_ARGS__}) / sizeof(size_t)), \ 138 (size_t[]){__VA_ARGS__} \ 237 const real *restrict z_min,
238 const real *restrict z_max,
239 const real *restrict r_min,
240 const real *restrict r_max,
241 const real *restrict ampere_turns,
243 const real *restrict vn_z,
244 real *restrict vn_mag_axis
269 const int16_t *restrict vm_num,
271 const real *restrict vn_geo_rout,
272 real *restrict mvn_mod
284 const int16_t *restrict vm_num,
286 const real *restrict vn_geo_rout,
287 const real *restrict vn_geo_rin,
288 real *restrict mvn_mod
300 const int16_t *restrict vm_num,
302 const real *restrict vn_geo_rout,
303 const real *restrict vn_geo_rin,
304 const real *restrict vn_geo_rel_w,
305 const real *restrict vn_geo_depth,
306 real *restrict mvn_mod
317 const int16_t *restrict vm_num,
319 const real *restrict vn_geo_rout,
320 const real *restrict vn_geo_rel_w,
321 const real *restrict vn_geo_depth,
322 real *restrict mvn_mod
336 const real *restrict vn_z,
337 const cplx *restrict mvn_env,
338 real *restrict opt_vm_energy
353 const real *restrict vn_z,
354 const cplx *restrict mvn_env_new,
355 const cplx *restrict mvn_env_old,
356 real *restrict opt_vm_energy_diff
377 const real *restrict opt_ptr_ref_z,
380 const real *restrict vn_z,
381 const real *restrict mvn_mod,
382 cplx *restrict vm_freq
403 const real *restrict opt_vm_freq_init,
405 size_t opt_iz_min_fcut,
406 const real *restrict vn_z,
407 const real *restrict mvn_mod,
408 const real *restrict tdm_c,
409 const real *restrict mv_tdm_zk,
410 cplx *restrict vm_cfreq
426 size_t opt_iz_min_fcut,
427 const real *restrict vn_z,
428 const real *restrict vn_mod,
429 const real *restrict tdm_c,
430 const real *restrict tdm_zk,
432 size_t *restrict out_dim_freq,
433 cplx *restrict out_cfreq
449 const cplx *restrict vm_rfc,
451 const real *restrict vn_z,
452 const real *restrict mvn_mod,
453 cplx *restrict mvn_env
462 size_t dim_z,
const real *restrict vn_z,
const real *restrict vn_mod
474 const real *restrict vn_z,
475 const real *restrict vn_mod,
493 const real *restrict vn_z,
494 const real *restrict vn_mod,
495 const real *restrict tdm_c,
496 const real *restrict tdm_zk,
512 const real *restrict vn_z,
513 const real *restrict mvn_mod,
514 real *restrict tdm_c,
515 real *restrict mv_tdm_zk
536 const real *restrict vm_cf,
537 const cplx *restrict vm_bc,
539 const real *restrict tdm_c,
540 const real *restrict mv_tdm_zk,
541 const cplx *restrict mvn_src,
542 const real *restrict opt_mvn_losscoef,
543 cplx *restrict vm_bd,
544 cplx *restrict mvn_env,
545 real *restrict opt_vm_cp,
546 real *restrict opt_vm_df,
547 struct cr_cache *restrict *restrict opt_pp_cache
556 const real *restrict vm_freq,
558 const real *restrict mvn_mod,
567 const cplx *restrict mvn_env,
578 const real *restrict vm_cf,
580 const real *restrict mvn_mod,
581 const cplx *restrict mvn_env,
582 real *restrict vm_bp,
601 const cplx *restrict vm_bc,
603 const cplx *restrict mvn_env,
625 const real *restrict beam_init,
627 const real *restrict vn_mag_axis,
628 const real *restrict vn_rhocd,
629 const real *restrict vn_r_outer,
630 const real *restrict opt_vn_r_inner,
631 real *restrict vn_pot
654 const int16_t *restrict vm_num,
656 const real *restrict vn_mag_axis,
657 const real *restrict mvn_mod,
659 real *restrict nvmh_bcc
700 const real *restrict beam_init,
702 const int16_t *restrict vm_num,
703 const real *restrict vm_cf,
704 const real *restrict vm_cp,
706 const real *restrict vn_z,
707 const real *restrict vn_pot,
708 const real *restrict vn_mag_axis,
709 const real *restrict mvn_mod,
710 const cplx *restrict mvn_env,
715 const real *restrict nvmh_bcc,
717 real *restrict vn_rhocd,
718 cplx *restrict mvn_src,
719 real *restrict opt_vn_mrs,
720 real *restrict opt_vn_blt_avg,
721 real *restrict opt_bvn_blt_trj,
722 struct cr_cache *restrict *restrict opt_pp_cache
735 const real *restrict vm_cf,
737 const real *restrict mvn_mod,
738 const cplx *restrict mvn_env,
739 real *restrict opt_vm_pout_left,
740 real *restrict opt_vm_pout_right
764 real *restrict opt_array_chi
788 real *restrict opt_array_chi
799 const cplx *restrict mvn_env,
800 const real *restrict mvn_uuload,
801 real *restrict vn_uload
814 const int16_t *restrict vm_num,
815 const real *restrict vm_freq,
817 const real *restrict vn_radius,
818 const real *restrict mvn_mod,
819 real *restrict mvn_uuload
829 const cplx *restrict multi_mat,
830 const cplx *restrict multi_vec,
831 cplx *restrict multi_x
844 const cplx *restrict mvn_new_env,
845 real *restrict mvn_old_env_phase,
860 const real *restrict vn_z,
861 const real *restrict vn_mrs,
863 real *restrict vn_z_new
873 const cplx *restrict multi_mat,
874 const cplx *restrict multi_vec,
875 cplx *restrict multi_x
883 const real *restrict vm_cf,
884 const cplx *restrict vm_bc,
886 const real *restrict tdm_c,
887 const real *restrict mv_tdm_zk,
888 const cplx *restrict mvn_src,
889 cplx *restrict vm_bd,
890 cplx *restrict mvn_env,
891 real *restrict opt_vm_cp,
892 real *restrict opt_vm_df,
893 struct cr_cache *restrict *restrict opt_pp_cache
901 const real *restrict vm_cf,
902 const cplx *restrict vm_bc,
904 const real *restrict tdm_c,
905 const real *restrict mv_tdm_zk,
906 const cplx *restrict mvn_src,
907 cplx *restrict vm_bd,
908 cplx *restrict mvn_env,
909 real *restrict opt_vm_cp,
910 real *restrict opt_vm_df,
911 struct cr_cache *restrict *restrict opt_pp_cache
CROCK_API int cr_find_cold_resonance(size_t dim_m, const real *restrict opt_vm_freq_init, size_t dim_z, size_t opt_iz_min_fcut, const real *restrict vn_z, const real *restrict mvn_mod, const real *restrict tdm_c, const real *restrict mv_tdm_zk, cplx *restrict vm_cfreq)
CROCK_API ROCK_CONST ROCK_NODISCARD int cr_version_major(void)
CROCK_API void cr_make_power_out(size_t dim_m, const real *restrict vm_cf, size_t dim_z, const real *restrict mvn_mod, const cplx *restrict mvn_env, real *restrict opt_vm_pout_left, real *restrict opt_vm_pout_right)
CROCK_API int cr_tdm_solve(size_t systems, size_t rows, const cplx *restrict multi_mat, const cplx *restrict multi_vec, cplx *restrict multi_x)
void(* free)(struct cr_cache *self)
Definition: crock.h:182
CROCK_API int cr_step_field(real dt, size_t dim_m, const real *restrict vm_cf, const cplx *restrict vm_bc, size_t dim_z, const real *restrict tdm_c, const real *restrict mv_tdm_zk, const cplx *restrict mvn_src, const real *restrict opt_mvn_losscoef, cplx *restrict vm_bd, cplx *restrict mvn_env, real *restrict opt_vm_cp, real *restrict opt_vm_df, struct cr_cache *restrict *restrict opt_pp_cache)
CROCK_API int cr_step_field_gpu(real dt, size_t dim_m, const real *restrict vm_cf, const cplx *restrict vm_bc, size_t dim_z, const real *restrict tdm_c, const real *restrict mv_tdm_zk, const cplx *restrict mvn_src, cplx *restrict vm_bd, cplx *restrict mvn_env, real *restrict opt_vm_cp, real *restrict opt_vm_df, struct cr_cache *restrict *restrict opt_pp_cache)
Doc see the CPU version.
CROCK_API real cr_make_chi_TE_corr_ins(real r, real d, real w, int16_t num_azi, int16_t num_rad, real *restrict opt_array_chi)
#define ROCK_MALLOC
Definition: crock.h:42
CROCK_API int cr_find_all_cold_resonances(size_t dim_z, size_t opt_iz_min_fcut, const real *restrict vn_z, const real *restrict vn_mod, const real *restrict tdm_c, const real *restrict tdm_zk, size_t dim_freq, size_t *restrict out_dim_freq, cplx *restrict out_cfreq)
CROCK_API int cr_tdm_solve_offload(size_t systems, size_t rows, const cplx *restrict multi_mat, const cplx *restrict multi_vec, cplx *restrict multi_x)
#define ROCK_NODISCARD
Definition: crock.h:45
CROCK_API void cr_update_bc_simple(real dt, size_t dim_m, const real *restrict vm_cf, size_t dim_z, const real *restrict mvn_mod, const cplx *restrict mvn_env, real *restrict vm_bp, cplx *restrict vm_bc)
CROCK_API int cr_make_bcc(real r_center, real r_span, size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_mag_axis, const real *restrict mvn_mod, size_t dim_bcc, real *restrict nvmh_bcc)
CROCK_API real cr_make_chi_TE_corr_holl_imp(real d, real w, int16_t num_azi, int16_t num_rad, real *restrict opt_array_chi)
#define ROCK_CONST
Definition: crock.h:44
double real
Definition: types.h:13
CROCK_API int cr_shoot_beamlet(uint32_t options, real beam_offset_x, const real *restrict beam_init, size_t dim_m, const int16_t *restrict vm_num, const real *restrict vm_cf, const real *restrict vm_cp, size_t dim_z, const real *restrict vn_z, const real *restrict vn_pot, const real *restrict vn_mag_axis, const real *restrict mvn_mod, const cplx *restrict mvn_env, size_t dim_b, size_t dim_bcc, real bcc_r_center, real bcc_r_span, const real *restrict nvmh_bcc, uint32_t *seed, real *restrict vn_rhocd, cplx *restrict mvn_src, real *restrict opt_vn_mrs, real *restrict opt_vn_blt_avg, real *restrict opt_bvn_blt_trj, struct cr_cache *restrict *restrict opt_pp_cache)
CROCK_API int cr_make_mode_corr_ins(size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, const real *restrict vn_geo_rin, const real *restrict vn_geo_rel_w, const real *restrict vn_geo_depth, real *restrict mvn_mod)
CROCK_API void cr_free(void *ptr)
CROCK_API int cr_numa_bless(void *restrict buf, size_t sizeof_type, size_t dim_shape, const size_t *restrict shape)
Set the data of buf to zero.
CROCK_API int cr_make_cold_envelope(size_t dim_m, const cplx *restrict vm_rfc, size_t dim_z, const real *restrict vn_z, const real *restrict mvn_mod, cplx *restrict mvn_env)
CROCK_API int cr_make_mode_coax(size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, const real *restrict vn_geo_rin, real *restrict mvn_mod)
CROCK_API ROCK_PURE ROCK_NODISCARD size_t cr_stride_cplx(size_t dim)
Calculate stride including padding.
CROCK_API int cr_refine_z(real weight, size_t dim_z, const real *restrict vn_z, const real *restrict vn_mrs, size_t dim_z_new, real *restrict vn_z_new)
Remap vn_z into vn_z_ne considering the mesh refinement score.
CROCK_API void cr_make_potential(real pot_outer, real opt_pot_inner, const real *restrict beam_init, size_t dim_z, const real *restrict vn_mag_axis, const real *restrict vn_rhocd, const real *restrict vn_r_outer, const real *restrict opt_vn_r_inner, real *restrict vn_pot)
CROCK_API int cr_deprecated_make_cold_spectrum(size_t dim_z, const real *restrict vn_z, const real *restrict vn_mod, size_t dim_freq, real *restrict freq, real *restrict ampl)
CROCK_API void cr_init_bd(size_t dim_m, const cplx *restrict vm_bc, size_t dim_z, const cplx *restrict mvn_env, cplx *restrict vm_bd)
#define ROCK_PURE
Definition: crock.h:43
CROCK_API ROCK_CONST ROCK_NODISCARD int cr_version_patch(void)
CROCK_API void cr_make_uload(size_t dim_m, size_t dim_z, const cplx *restrict mvn_env, const real *restrict mvn_uuload, real *restrict vn_uload)
CROCK_API int cr_deprecated_search_cold_resonance(const real *restrict opt_ptr_ref_z, size_t dim_m, size_t dim_z, const real *restrict vn_z, const real *restrict mvn_mod, cplx *restrict vm_freq)
CROCK_API int cr_make_mode_holl(size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, real *restrict mvn_mod)
CROCK_API void cr_make_df(real elapsed_time, size_t dim_m, size_t dim_z, const cplx *restrict mvn_new_env, real *restrict mvn_old_env_phase, real *restrict vm_df)
CROCK_API ROCK_NODISCARD int cr_make_mag_axis(size_t dim_coil, const real *restrict z_min, const real *restrict z_max, const real *restrict r_min, const real *restrict r_max, const real *restrict ampere_turns, size_t dim_z, const real *restrict vn_z, real *restrict vn_mag_axis)
Make a vector of B-field on axis of solenoids.
double _Complex cplx
Definition: types.h:14
CROCK_API ROCK_PURE ROCK_NODISCARD size_t cr_stride_real(size_t dim)
Calculate stride including padding.
CROCK_API ROCK_PURE ROCK_NODISCARD const char * cr_errmsg(int err)
CROCK_API ROCK_CONST ROCK_NODISCARD int cr_version_minor(void)
CROCK_API real cr_make_stored_energy_diff(size_t dim_m, size_t dim_z, const real *restrict vn_z, const cplx *restrict mvn_env_new, const cplx *restrict mvn_env_old, real *restrict opt_vm_energy_diff)
Calculate the difference of stored energy.
CROCK_API real cr_make_stored_energy(size_t dim_m, size_t dim_z, const real *restrict vn_z, const cplx *restrict mvn_env, real *restrict opt_vm_energy)
CROCK_API ROCK_PURE ROCK_NODISCARD size_t cr_guess_dim_cold_spectrum(size_t dim_z, const real *restrict vn_z, const real *restrict vn_mod)
#define CROCK_API
Definition: crock.h:33
CROCK_API void cr_make_uuload(size_t dim_m, const int16_t *restrict vm_num, const real *restrict vm_freq, size_t dim_z, const real *restrict vn_radius, const real *restrict mvn_mod, real *restrict mvn_uuload)
CROCK_API int cr_make_mode_corr_holl_imp(size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, const real *restrict vn_geo_rel_w, const real *restrict vn_geo_depth, real *restrict mvn_mod)
CROCK_API int cr_make_cold_spectrum(int max_iter, size_t dim_z, const real *restrict vn_z, const real *restrict vn_mod, const real *restrict tdm_c, const real *restrict tdm_zk, size_t dim_freq, real *restrict freq, real *restrict ampl)
CROCK_API int cr_make_fem(size_t dim_m, size_t dim_z, const real *restrict vn_z, const real *restrict mvn_mod, real *restrict tdm_c, real *restrict mv_tdm_zk)
CROCK_API void cr_init_bp(size_t dim_m, size_t dim_z, const cplx *restrict mvn_env, real *restrict vm_bp)
Read the detailed description!
Definition: crock.h:181
CROCK_API ROCK_CONST ROCK_NODISCARD int cr_simd_lanes(void)
CROCK_API int cr_step_field_offload(real dt, size_t dim_m, const real *restrict vm_cf, const cplx *restrict vm_bc, size_t dim_z, const real *restrict tdm_c, const real *restrict mv_tdm_zk, const cplx *restrict mvn_src, cplx *restrict vm_bd, cplx *restrict mvn_env, real *restrict opt_vm_cp, real *restrict opt_vm_df, struct cr_cache *restrict *restrict opt_pp_cache)
Doc see the CPU version.
CROCK_API void cr_make_bc_simple(size_t dim_m, const real *restrict vm_freq, size_t dim_z, const real *restrict mvn_mod, cplx *restrict vm_bc)
CROCK_API ROCK_MALLOC void * cr_malloc(size_t size)