master
Bill 2 years ago
parent 27ae26db90
commit 6f267f982d

@ -2,7 +2,7 @@
## GLOBAL CONFIGURATION FLAGS ## GLOBAL CONFIGURATION FLAGS
version_string = '0.7.6a' version_string = '0.7.7a'
add_path_to_ldpath = True add_path_to_ldpath = True
rebuild_backend = False rebuild_backend = False
run_backend = True run_backend = True
@ -28,7 +28,8 @@ def init_config():
# os.environ['CXX'] = 'C:/Program Files/LLVM/bin/clang.exe' # os.environ['CXX'] = 'C:/Program Files/LLVM/bin/clang.exe'
os.environ['THREADING'] = '1' os.environ['THREADING'] = '1'
os.environ['AQUERY_ITC_USE_SEMPH'] = '1' os.environ['AQUERY_ITC_USE_SEMPH'] = '1'
if 'AQ_DEBUG' not in os.environ:
os.environ['AQ_DEBUG'] = '0'
if ('__config_initialized__' not in globals() or if ('__config_initialized__' not in globals() or
not __config_initialized__): not __config_initialized__):
import sys import sys
@ -50,6 +51,7 @@ def init_config():
if os_platform == 'win': if os_platform == 'win':
add_dll_dir(cygroot) add_dll_dir(cygroot)
add_dll_dir(os.path.abspath('./msc-plugin')) add_dll_dir(os.path.abspath('./msc-plugin'))
add_dll_dir(os.path.abspath('./deps'))
if build_driver == 'Auto': if build_driver == 'Auto':
try: try:
import vswhere import vswhere

@ -164,6 +164,7 @@ class build_manager:
return True return True
def server(self): def server(self):
print(self.opt)
loc = os.path.abspath('./msc-plugin/server.vcxproj') loc = os.path.abspath('./msc-plugin/server.vcxproj')
self.get_flags() self.get_flags()
self.build_cmd = [['del', 'server.so'], [aquery_config.msbuildroot, loc, self.opt, self.platform]] self.build_cmd = [['del', 'server.so'], [aquery_config.msbuildroot, loc, self.opt, self.platform]]
@ -186,7 +187,7 @@ class build_manager:
def __init__(self) -> None: def __init__(self) -> None:
self.method = 'make' self.method = 'make'
self.cxx = '' self.cxx = ''
self.OptimizationLv = '4' # [O0, O1, O2, O3, Ofast] self.OptimizationLv = '0' # [O0, O1, O2, O3, Ofast]
self.Platform = 'amd64' self.Platform = 'amd64'
self.PCH = os.environ['PCH'] if 'PCH' in os.environ else 1 self.PCH = os.environ['PCH'] if 'PCH' in os.environ else 1
self.StaticLib = 1 self.StaticLib = 1

@ -75,7 +75,8 @@ class projection(ast_node):
): ):
self.force_use_spgb = ( self.force_use_spgb = (
force_use_spgb | force_use_spgb |
context.system_state.cfg.backend_type == Backend_Type.BACKEND_AQuery.value (context.system_state.cfg.backend_type ==
Backend_Type.BACKEND_AQuery.value)
) )
self.subq_type = subq_type self.subq_type = subq_type
super().__init__(parent, node, context) super().__init__(parent, node, context)
@ -1444,10 +1445,10 @@ class outfile(ast_node):
file_pointer = 'fp_' + base62uuid(6) file_pointer = 'fp_' + base62uuid(6)
self.addc(f'FILE* {file_pointer} = fopen("{filename}", "wb");') self.addc(f'FILE* {file_pointer} = fopen("{filename}", "wb");')
self.addc(f'{self.parent.out_table.contextname_cpp}->printall("{sep}", "\\n", nullptr, {file_pointer});') self.addc(f'{self.parent.out_table.contextname_cpp}->printall("{sep}", "\\n", nullptr, {file_pointer});')
if self.context.use_gc: # if self.context.use_gc:
self.addc(f'GC::gc_handle->reg({file_pointer}, 65536, [](void* fp){{fclose((FILE*)fp);}});') # self.addc(f'GC::gc_handle->reg({file_pointer}, 65536, fclose_gc);')
else: # else:
self.addc(f'fclose({file_pointer});') self.addc(f'fclose({file_pointer});')
self.context.ccode += self.ccode self.context.ccode += self.ccode

@ -11,9 +11,10 @@
<Name>msvs-py</Name> <Name>msvs-py</Name>
<RootNamespace>msvs-py</RootNamespace> <RootNamespace>msvs-py</RootNamespace>
<IsWindowsApplication>False</IsWindowsApplication> <IsWindowsApplication>False</IsWindowsApplication>
<InterpreterId>Global|PythonCore|3.9</InterpreterId> <InterpreterId>Global|PythonCore|3.10</InterpreterId>
<LaunchProvider>Standard Python launcher</LaunchProvider> <LaunchProvider>Standard Python launcher</LaunchProvider>
<EnableNativeCodeDebugging>True</EnableNativeCodeDebugging> <EnableNativeCodeDebugging>True</EnableNativeCodeDebugging>
<Environment>AQ_DEBUG=1</Environment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -59,6 +60,9 @@
<Compile Include="..\aquery_config.py" /> <Compile Include="..\aquery_config.py" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<InterpreterReference Include="Global|PythonCore|3.10" />
<InterpreterReference Include="Global|PythonCore|3.11" />
<InterpreterReference Include="Global|PythonCore|3.12" />
<InterpreterReference Include="Global|PythonCore|3.9" /> <InterpreterReference Include="Global|PythonCore|3.9" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />

@ -20,7 +20,7 @@ template<class T, template<typename ...> class VT>
types::GetLongType<T> types::GetLongType<T>
sum(const VT<T>& v) { sum(const VT<T>& v) {
types::GetLongType<T> ret = 0; types::GetLongType<T> ret = 0;
for (const auto& _v : v) for (auto _v : v)
ret += _v; ret += _v;
return ret; return ret;
} }
@ -363,6 +363,32 @@ inline decayed_t<VT, types::GetFPType<types::GetLongType<T>>> vars(const VT<T>&
return ret; return ret;
} }
template<class T, template<typename ...> class VT,
class T2, template<typename ...> class VT2
>
auto corr(const VT<T>& x, const VT2<T2>&y) {
typedef types::Coercion<decays<T>, decays<T2>> InnerType;
typedef types::GetLongType<InnerType> LongType;
typedef types::GetFPType<LongType> FPType;
// assert(x.size == y.size);
const uint32_t& len = x.size;
LongType sx{0}, sy{0}, sxy{0}, sx2{0}, sy2{0};
for (uint32_t i = 0; i < len; ++i){
sx += x[i];
sx2 += x[i] * x[i];
sy += y[i];
sxy += x[i] * y[i];
sy2 += y[i] * y[i];
}
return (sxy - FPType(sx*sy))
/
(len * sqrt(
(sx2 - FPType(sx*sx)/len) * (sy2 - FPType(sy*sy)/len)
)
);
}
template<class T, template<typename ...> class VT> template<class T, template<typename ...> class VT>
inline types::GetFPType<types::GetLongType<decays<T>>> stddev(const VT<T>& arr) { inline types::GetFPType<types::GetLongType<decays<T>>> stddev(const VT<T>& arr) {
return sqrt(var(arr)); return sqrt(var(arr));

@ -36,7 +36,7 @@ public:
// reset scratch space to initial capacity. // reset scratch space to initial capacity.
void cleanup(); void cleanup();
}; };
void fclose_gc(void*);
#ifndef __AQ_USE_THREADEDGC__ #ifndef __AQ_USE_THREADEDGC__
class QUERY_DECLSPEC GC { class QUERY_DECLSPEC GC {
@ -103,7 +103,6 @@ public:
} }
constexpr static void(*_free) (void*) = free; constexpr static void(*_free) (void*) = free;
}; };
#else #else
class GC { class GC {
public: public:

@ -635,3 +635,4 @@ get_procedure(Context* cxt, const char* name) {
} }
void* CreateNULLServer(Context*) { return nullptr; } void* CreateNULLServer(Context*) { return nullptr; }
void fclose_gc(void* fp) { fclose((FILE*)fp); }

@ -67,11 +67,11 @@ typedef void (*module_init_fn)(Context*);
int n_recv = 0; int n_recv = 0;
char** n_recvd = nullptr; char** n_recvd = nullptr;
__AQEXPORT__(void) wait_engine(){ __AQEXPORT__(void) wait_engine() {
PROMPT_ACQUIRE(); PROMPT_ACQUIRE();
} }
__AQEXPORT__(void) wake_engine(){ __AQEXPORT__(void) wake_engine() {
ENGINE_RELEASE(); ENGINE_RELEASE();
} }
@ -108,7 +108,7 @@ have_hge() {
Context* _g_cxt; Context* _g_cxt;
__AQEXPORT__(StoredProcedure) __AQEXPORT__(StoredProcedure)
get_procedure_ex(const char* name){ get_procedure_ex(const char* name) {
return get_procedure(_g_cxt, name); return get_procedure(_g_cxt, name);
} }
@ -134,13 +134,13 @@ void activate_callback_based_trigger(Context* context, const char* cmd)
// This function contains heap allocations, free after use // This function contains heap allocations, free after use
template<class String_T> template<class String_T>
char* to_lpstr(const String_T& str){ char* to_lpstr(const String_T& str) {
auto ret = static_cast<char*>(malloc(str.size() + 1)); auto ret = static_cast<char*>(malloc(str.size() + 1));
memcpy(ret, str.c_str(), str.size()); memcpy(ret, str.c_str(), str.size());
ret[str.size()] = '\0'; ret[str.size()] = '\0';
return ret; return ret;
} }
char* copy_lpstr(const char* str){ char* copy_lpstr(const char* str) {
auto len = strlen(str); auto len = strlen(str);
auto ret = static_cast<char*>(malloc(len + 1)); auto ret = static_cast<char*>(malloc(len + 1));
memcpy(ret, str, len + 1); memcpy(ret, str, len + 1);
@ -639,7 +639,7 @@ extern "C" int __DLLEXPORT__ dllmain(int argc, char** argv) {
cxt->log("ready: %s\n", ready? "true":"false"); cxt->log("ready: %s\n", ready? "true":"false");
while (running) { while (running) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(1ms);
if(ready){ if(ready) {
cxt->log("running: %s\n", running? "true":"false"); cxt->log("running: %s\n", running? "true":"false");
cxt->log("ready: %s\n", ready? "true":"false"); cxt->log("ready: %s\n", ready? "true":"false");
void* handle = dlopen("./dll.so", RTLD_NOW); void* handle = dlopen("./dll.so", RTLD_NOW);

@ -355,7 +355,7 @@ public:
inline vector_type<_Ty> subvec_deep(uint32_t start = 0) const { return subvec_deep(start, size); } inline vector_type<_Ty> subvec_deep(uint32_t start = 0) const { return subvec_deep(start, size); }
vector_type<_Ty> getRef() { return vector_type<_Ty>(container, size); } vector_type<_Ty> getRef() { return vector_type<_Ty>(container, size); }
~vector_type() { ~vector_type() {
if (capacity > 0) GC::gc_handle->reg(container, sizeof(_Ty) * capacity);//free(container); if (capacity > 0) GC::gc_handle->reg(container, sizeof(_Ty) * capacity);//*/free(container);
container = nullptr; container = nullptr;
size = capacity = 0; size = capacity = 0;
} }

Loading…
Cancel
Save